Project Introduction
Relevant source files
The following files were used as context for generating this wiki page:
The claude-code-docs project is an unofficial mirror and automation toolkit for the Claude Code documentation. Its primary purpose is to provide AI coding agents and developers with reliable, offline-capable, and programmatically accessible access to documentation content. It synchronizes every 6 hours from the official source, converting the web-based documentation into a structured Git repository of clean Markdown files.
Sources: README.md:1-5, sync.ts:1-5
The project serves three main roles: a versioned documentation mirror, a Claude Code plugin with URL rewriting capabilities, and an Agent Skills Kit (ASK) provider. By tracking additions and deletions in Git history, it allows users to inspect documentation changes over time and integrate this knowledge directly into AI development workflows without overwhelming context windows.
Sources: README.md:1-12, skills/claude-code-docs/SKILL.md:1-10
Synchronization Architecture
The core logic for maintaining the mirror resides in sync.ts. It utilizes the official llms.txt manifest as the single source of truth to rebuild the documentation tree from scratch during every execution. This ensures that any deletions in the canonical documentation are reflected as Git deletions in the mirror.
Synchronization Flow
The following diagram illustrates how the sync.ts script fetches and processes the documentation.
Sources: sync.ts:10-90
Link Transformation
During synchronization, site-absolute paths (e.g., /en/sub-agents) are transformed into relative paths (e.g., ../sub-agents.md) to ensure links work correctly when browsing the repository on platforms like GitHub. If a link points to a slug not tracked in the manifest, it falls back to the canonical URL.
Sources: sync.ts:18-40
Claude Code Plugin and Hooks
This repository functions as a Claude Code plugin that intercepts documentation requests. It uses a PreToolUse hook to optimize how AI agents consume content.
URL Rewriting Logic
When a tool like WebFetch attempts to access a documentation page, the plugin's hook rewrites the URL from an HTML page to its .md source. This prevents the agent from downloading heavy HTML app shells and provides it with clean, LLM-friendly Markdown.
Sources: hooks/hooks.json:1-15, hooks/rewrite-docs-url.sh:1-15
| Component | Description |
|---|---|
| Matcher | WebFetch |
| Hook Event | PreToolUse |
| Command | bash hooks/rewrite-docs-url.sh |
| Permission | Automatically set to allow with permissionDecisionReason |
| Sources: hooks/hooks.json:4-14, hooks/rewrite-docs-url.sh:37-45 |
Rewriting Examples
The hook handles various URL patterns to ensure consistent access to Markdown sources.
Sources: hooks/rewrite-docs-url.test.sh:17-21
Agent Skills Kit (ASK) Integration
The project includes a skill definition that allows agents to answer technical questions about Claude Code. It leverages semantic search and local caching to minimize token usage.
Search and Resolution Process
The skill follows a specific hierarchy of tools to find information, starting with semantic search and falling back to manual grep or web fetching.
Search Tools Configuration
The skill defines how the agent should interact with the local mirror.
| Tool | Usage | Purpose |
|---|---|---|
ask src | ask src github:pleaseai/claude-code-docs | Resolves the root of a cached checkout. |
csp search | csp search "$question" "$DOCS" --top-k 8 | Performs semantic search over documentation. |
grep | grep -ril "<keyword>" "$DOCS" | Fallback keyword search if csp is unavailable. |
WebFetch | Fetch llms.txt manifest | Ultimate fallback for offline/isolated environments. |
| Sources: skills/claude-code-docs/SKILL.md:16-72, README.md:27-42 |
Core Data Assets
The repository maintains several key files that represent the documentation state.
| File | Description |
|---|---|
llms.txt | The manifest of all documentation pages and one-line summaries. |
llms-full.txt | A single file containing the entire documentation set (approx. 5MB). |
docs/ | A directory of individual Markdown files mirrored from the source. |
hooks/hooks.json | Configuration for the Claude Code tool-interception system. |
| Sources: README.md:5-12, hooks/hooks.json:1-16 |
Summary
The claude-code-docs project provides a robust bridge between official Anthropic documentation and automated developer tools. By combining a 6-hour sync cycle, relative link rewriting, and Claude Code plugin hooks, it ensures that both human developers and AI agents have high-fidelity, low-latency access to the latest Claude Code features and configurations.
Sources: README.md:1-5, sync.ts:1-5