Claude Code Agent Skill
Relevant source files
The following files were used as context for generating this wiki page:
The Claude Code Agent Skill is a specialized tool designed to provide AI coding agents with accurate, up-to-date information regarding Claude Code features, hooks, plugins, and CLI configurations. It functions as part of the Agent Skills Kit (ASK) ecosystem, allowing agents to perform on-demand, lazy lookups of documentation rather than consuming excessive context window space with large documentation files.
The skill operates by resolving a local, version-pinned mirror of the official Claude Code documentation, which is synchronized every six hours from the canonical source. It utilizes semantic search to find relevant answers and falls back to traditional keyword searches or live web fetches when primary tools are unavailable.
Sources: README.md:1-5, skills/claude-code-docs/SKILL.md:1-7
Architecture and Core Components
The system architecture relies on a multi-stage process to resolve queries, moving from local cached assets to remote fallbacks.
Documentation Synchronization
The documentation is maintained via a synchronization script (sync.ts) that treats the official llms.txt manifest as the source of truth. It rebuilds the local docs/ directory from scratch on every run to ensure that page additions, changes, and deletions are accurately tracked in the git history.
The following flowchart illustrates the synchronization and link-rewriting logic:
The sync.ts script ensures that site-absolute paths (e.g., /en/sub-agents) are rewritten to relative local markdown files (e.g., ../sub-agents.md) to maintain navigability within the mirror.
Sources: sync.ts:9-40, README.md:15-18
Resolution Logic
The skill follows a specific hierarchy when answering a question:
- Resolve Mirror: Uses
ask srcto locate the cached checkout of the documentation. - Semantic Search: Executes
csp searchorask searchto find the most relevant pages based on the query. - Keyword Fallback: Uses
grepto find specific terms if semantic search is unavailable. - Web Fetch Fallback: Fetches the live manifest and individual markdown pages if the local mirror cannot be accessed.
Sources: skills/claude-code-docs/SKILL.md:14-65
Tooling and Integrations
The skill integrates with several command-line interfaces (CLIs) to perform its functions.
| Tool | Purpose | Fallback Mechanism |
|---|---|---|
ask | Resolves version-pinned local mirrors and manages skill installation. | npx -y @pleaseai/ask |
csp | Performs token-efficient semantic search over cached documentation. | npx -y @pleaseai/csp or grep |
WebFetch | Retrieves remote content when local assets are missing. | Integrated via PreToolUse hooks |
Sources: README.md:21-47, skills/claude-code-docs/SKILL.md:1-12
Hook System and URL Rewriting
To improve the quality of data retrieved via web fetching, the plugin implements a PreToolUse hook. This hook intercepts calls to the WebFetch tool specifically for code.claude.com/docs URLs.
Rewrite Logic
Documentation pages are often served as part of a heavy HTML application shell. The hook rewrites standard documentation URLs to their .md equivalents (e.g., /agents becomes /agents.md), allowing the agent to receive clean Markdown content directly.
Implementation Details
Skill Definition
The skill is defined with the following configuration:
- Name:
claude-code-docs - Arguments: A single
[question]string. - Description: Used for answering questions about Claude Code features, MCP, Agent SDK, and CLI settings.
Sources: skills/claude-code-docs/SKILL.md:1-8
Sync Script Parameters
The sync.ts script uses the following configuration for mirroring:
const BASE = "https://code.claude.com/docs";
const CONCURRENCY = 10;
const RETRIES = 3;
Sources: sync.ts:10-12
Verification
The URL rewriting logic is verified via a test suite that ensures fragments are dropped and only valid documentation paths are modified.
# Example test cases
expect_rewrite "https://code.claude.com/docs/en/agents" "https://code.claude.com/docs/en/agents.md"
expect_silent "https://code.claude.com/docs/llms.txt"
Sources: hooks/rewrite-docs-url.test.sh:18-29
Conclusion
The Claude Code Agent Skill provides a robust mechanism for agents to access technical documentation without overwhelming their context window. By combining local mirroring, semantic search through csp, and a specialized URL-rewriting hook system, it ensures that the agent always has access to the most relevant and cleanly formatted documentation available.