context7-cli
Use the local Context7 CLI in this repo to search libraries and fetch Context7 context for skills or documentation tasks. Trigger when you need to run `c7 search`/`c7 context`, resolve library IDs, or retrieve text/json outputs from Context7 via the CLI.
When & Why to Use This Skill
The Context7 CLI skill empowers Claude to interact with the Context7 platform for efficient library discovery and context retrieval. By leveraging a local CLI, it provides authoritative documentation snippets and library metadata, enabling more accurate code generation, debugging, and technical documentation tasks through deterministic data fetching. This skill is essential for developers and AI agents who need reliable, up-to-date information on software libraries to improve the quality of their technical output.
Use Cases
- Library Discovery: Quickly search for and identify the correct library IDs and versions for project dependencies using the 'c7 search' command.
- Context-Aware Coding: Fetch specific API documentation and usage examples (e.g., React hooks or cleanup functions) to ensure code accuracy and adherence to best practices.
- Technical Documentation: Retrieve authoritative context snippets to automatically generate or update technical guides, API references, and README files.
- Workflow Automation: Integrate deterministic CLI outputs into downstream development pipelines or agentic reasoning steps for complex software engineering tasks.
- Troubleshooting and Research: Resolve library IDs and retrieve structured JSON or text outputs to debug integration issues or research library capabilities.
| name | context7-cli |
|---|---|
| description | Use the local Context7 CLI in this repo to search libraries and fetch Context7 context for skills or documentation tasks. Trigger when you need to run `c7 search`/`c7 context`, resolve library IDs, or retrieve text/json outputs from Context7 via the CLI. |
Context7 CLI
Overview
Use the local agent-skills CLI (subcommand c7) to query Context7 for library discovery and context snippets. Prefer this tool when a task needs authoritative library context and you want a deterministic CLI output that can be piped into downstream steps.
Quick Start
- Ensure
CONTEXT7_API_KEYis set or pass--api-key. - If
agent-skillsis already installed, use it directly:
command -v agent-skills
agent-skills c7 search --library-name react --query "useEffect cleanup"
- Otherwise, run the CLI from the repo:
go run ./cmd/agent-skills c7 search --library-name react --query "useEffect cleanup"
For repeated calls, build once:
go build -o bin/agent-skills ./cmd/agent-skills
./bin/agent-skills c7 context --library-id /facebook/react --query "useEffect cleanup"
Or install remotely (requires Go) only if the binary is missing:
if ! command -v agent-skills >/dev/null 2>&1; then
go install github.com/strantalis/agent-skills/cmd/agent-skills@latest
fi
agent-skills c7 search --library-name react --query "useEffect cleanup"
Tasks
Search for libraries
Use this to discover candidate library IDs.
go run ./cmd/agent-skills c7 search --library-name react --query "useEffect cleanup"
- Default output is JSON. Use
--format jsonlfor JSON lines or--format textfor tab-separated lines. - Use
--limitto reduce results when you only need the top few.
Fetch context
Prefer explicit --library-id for determinism.
go run ./cmd/agent-skills c7 context --library-id /facebook/react --query "useEffect cleanup"
If you only have a name, you may use --library-name. If multiple libraries match, use --select=interactive or --select=first, or provide --library-id for determinism.
go run ./cmd/agent-skills c7 context --library-name react --query "useEffect cleanup"
Output formats
- Use
--format jsonwhen another tool or step needs structured output. - Use
--format jsonlfor streaming or piping one JSON object per line. - Use
--format textfor direct reading or quick copy/paste.
Flags (global to c7)
--api-key(orCONTEXT7_API_KEY): Context7 API key.--base-url: Override the Context7 base URL.--timeout: HTTP timeout (default 30s).--retries: Retry count for 202/429/5xx responses.--cache-dir: Enable disk cache when set.--cache-ttl: Cache TTL (default 24h, only used when cache-dir is set).
Troubleshooting
- 401/403: Missing or invalid API key. Set
CONTEXT7_API_KEYor pass--api-key. - 429: Rate limited. The client retries automatically; reduce request rate if persistent.
- 202: Context is still processing; retries will handle this automatically.
Reference
See references/api_reference.md for the full command reference and examples.