Understanding the Mirrored Content
Relevant source files
The following files were used as context for generating this wiki page:
The claude-code-docs project serves as an unofficial, high-fidelity mirror of the Anthropic Claude Code documentation. Its primary purpose is to provide AI coding agents and developers with a structured, git-tracked version of the documentation that is optimized for programmatic access, semantic search, and clean markdown retrieval.
The system operates by synchronizing content from the canonical source (code.claude.com/docs) every six hours. It transforms the original web-based content into a local hierarchy of markdown files, ensuring that page additions, modifications, and deletions are accurately reflected in the repository's git history. This mirrored content is then consumed by tools like ASK (Agent Skills Kit) and Claude Code plugins to provide context-aware documentation assistance.
Sources: README.md:1-12, sync.ts:1-5
Core Synchronization Logic
The synchronization process, implemented in sync.ts, treats the llms.txt file as the absolute source of truth for the documentation manifest. The script performs a complete rebuild of the docs/ directory on every successful run to ensure parity with the source.
The Sync Workflow
- Manifest Retrieval: Fetches the
llms.txtmanifest from the base URL. - Validation: Ensures the manifest contains at least 10 pages to prevent accidental mass deletions due to parsing errors.
- Local Updates: Updates the root
llms.txtandllms-full.txt(the consolidated docs bundle). - Content Mirroring: Iterates through URLs found in the manifest, fetches the markdown source, and applies link rewriting.
- Concurrency Management: Uses a worker pool (default concurrency of 10) to process pages efficiently.
The diagram above illustrates the sequential steps taken by the sync.ts script to maintain the mirror.
Sources: sync.ts:55-87, README.md:16-18
Link Transformation
Since the source pages use site-absolute paths (e.g., /en/sub-agents), they do not resolve correctly when browsing local files on platforms like GitHub. The rewriteLinks function converts these into relative markdown links (e.g., ../sub-agents.md). If a link points to a slug not present in the mirrored set, it reverts to the canonical absolute URL.
Sources: sync.ts:15-37
Document Retrieval and Integration
The mirrored content is designed to be integrated into developer workflows via the ASK (Agent Skills Kit) and a dedicated Claude Code plugin.
Tooling Integration Table
| Tool | Component | Functionality |
|---|---|---|
| ASK | ask src | Resolves the cached path of the documentation mirror. |
| ASK | ask search | Performs semantic search using csp over the mirrored docs/ folder. |
| Claude Code | PreToolUse Hook | Intercepts WebFetch calls to rewrite HTML URLs to .md sources. |
| Claude Code | Skill | Provides a /claude-code-docs command to answer questions from the mirror. |
Sources: README.md:21-48, hooks/hooks.json:4-14, skills/claude-code-docs/SKILL.md:1-10
URL Rewriting Mechanism
To avoid the overhead of parsing the HTML app shell during a WebFetch, the project includes a shell script hook that intercepts documentation requests. It identifies URLs belonging to code.claude.com/docs and appends the .md extension.
The sequence diagram shows how the rewrite-docs-url.sh hook modifies tool inputs before execution.
Sources: hooks/rewrite-docs-url.sh:10-40, README.md:52-60
Content Discovery and Search
The mirrored content supports two primary discovery methods: semantic search and keyword-based filtering.
Semantic Search with csp
The ask search command delegates to csp (Code Search Please) for token-efficient semantic search. It is configured to index the individual markdown files in the docs/ directory while ignoring the 5MB llms-full.txt file to prevent result duplication.
Skill Execution Flow
When the /claude-code-docs skill is invoked, it follows a specific resolution hierarchy:
- Resolve docs path via
ask src. - Attempt semantic search via
csp. - Fallback to
grepfor keyword variants ifcspis unavailable. - Final fallback to direct
WebFetchof the manifest and individual pages.
Sources: README.md:38-48, skills/claude-code-docs/SKILL.md:12-50
Summary
The mirrored content system provides a robust infrastructure for documentation access by decoupling the data (markdown files) from the presentation (HTML website). By leveraging a manifest-driven sync process and providing integration hooks for AI agents, it ensures that technical information about Claude Code remains accurate, searchable, and easily consumable by both human developers and automated tools.
Sources: README.md:1-8, sync.ts:1-5