
context7-docs
by syz51
My personal claude code settings
SKILL.md
name: context7-docs description: PRIMARY tool for fetching library/framework documentation. PROACTIVELY use instead of WebFetch/WebSearch when user requests docs, API references, setup guides, or code examples for any programming library or framework. Use this skill immediately when detecting queries like "show me X docs", "how do I use Y", "get Z documentation", etc. Token-efficient alternative to MCP servers.
Context7 Documentation Fetcher
Overview
Fetch up-to-date documentation and code examples for any library using Context7's HTTP API. This skill replicates Context7 MCP functionality with token-efficient progressive disclosure.
When to Use This Skill
This skill should be the FIRST choice for library/framework documentation.
Trigger patterns:
- User asks for documentation: "get me the React docs", "show me Next.js docs"
- User needs API references: "how do I use X API", "what's the syntax for Y"
- User wants setup instructions: "how to install Z", "configure W"
- Code generation tasks: Before writing code for a library, fetch its docs first
- User mentions library names: "help with FastAPI", "using Tailwind"
- Troubleshooting with libraries: When fixing bugs or errors related to specific libraries
Benefits over WebFetch/WebSearch:
- Curated, current documentation from official sources
- Structured format optimized for code generation
- Topic filtering for focused results
- Version-specific documentation when needed
Setup
API Key Required: Set CONTEXT7_API_KEY environment variable. Get key from https://context7.com/dashboard
export CONTEXT7_API_KEY="your-api-key"
Quick Start
Two-Step Workflow
- Search for library to get Context7-compatible ID
- Fetch documentation using that ID
Exception: Skip search if user provides exact ID format (/org/project or /org/project/version)
Searching for Libraries
Use scripts/context7_client.py search to resolve library names to Context7 IDs.
Basic search:
python scripts/context7_client.py search "React"
Output format:
Found 3 results for 'React':
1. React
ID: /facebook/react
Description: JavaScript library for building user interfaces
2. React Router
ID: /remix-run/react-router
Description: Declarative routing for React
Selection criteria:
- Exact name matches prioritized
- Description relevance to query intent
- Documentation coverage (higher code snippet count)
- Source reputation (High/Medium preferred)
Common patterns:
# Framework search
python scripts/context7_client.py search "Next.js"
# Returns: /vercel/next.js
# Database client
python scripts/context7_client.py search "MongoDB"
# Returns: /mongodb/docs
# UI library
python scripts/context7_client.py search "shadcn"
# Returns: /shadcn/ui
Fetching Documentation
Use scripts/context7_client.py docs with resolved library ID.
Basic fetch:
python scripts/context7_client.py docs vercel/next.js
With topic filter:
python scripts/context7_client.py docs vercel/next.js --topic routing
With token limit:
python scripts/context7_client.py docs vercel/next.js --tokens 3000
Specific version:
python scripts/context7_client.py docs vercel/next.js/v15.1.8
Combined parameters:
python scripts/context7_client.py docs vercel/next.js --topic "app router" --tokens 2000
Parameters
Library ID Format
- Standard:
/org/project(e.g.,/vercel/next.js) - Versioned:
/org/project/version(e.g.,/vercel/next.js/v15.1.8) - Leading slash optional: Script handles both
vercel/next.jsand/vercel/next.js
Optional Filters
--topic: Focus on specific subject (e.g., "routing", "hooks", "authentication")--tokens: Limit documentation size (default: 5000)- Use lower values (1000-2000) for focused queries
- Use higher values (5000-10000) for comprehensive references
Output Formats
- Default: Formatted markdown documentation
--json: Raw JSON for programmatic parsing
Error Handling
Common errors:
-
"Context7 API key required"
- Set CONTEXT7_API_KEY environment variable
-
"Authentication failed"
- Verify API key is correct
- Check key hasn't been revoked
-
"Library not found"
- Verify library ID is correct
- Try searching first to confirm ID
-
"Rate limited. Retry after X seconds"
- Wait specified duration
- Consider implementing exponential backoff
-
Network errors
- Check internet connectivity
- Verify Context7 API is accessible
Usage Examples
Example 1: Next.js App Router documentation
# Search for Next.js
python scripts/context7_client.py search "Next.js"
# Fetch App Router docs
python scripts/context7_client.py docs vercel/next.js --topic "app router"
Example 2: React hooks with token limit
# Direct fetch (known ID)
python scripts/context7_client.py docs facebook/react --topic hooks --tokens 2000
Example 3: Specific library version
# Search for library
python scripts/context7_client.py search "Tailwind CSS"
# Fetch specific version docs
python scripts/context7_client.py docs tailwindlabs/tailwindcss/v3.4.0
Integration Tips
For code generation
- Search for library if ID unknown
- Fetch docs with relevant topic filter
- Use documentation to generate accurate, up-to-date code
- Consider token limits based on scope
For setup/configuration
- Fetch docs without topic filter for comprehensive guide
- Use higher token limit (5000+) for full instructions
- Look for "getting started" or "installation" sections
For API references
- Use topic filter for specific API sections
- Moderate token limits (2000-3000) for focused references
- Fetch multiple topics separately if needed
Token Efficiency
Progressive disclosure vs MCP:
- MCP: All tools always in context (~2k tokens)
- This skill:
- Metadata: ~100 words (always)
- SKILL.md: <5k words (when triggered)
- Scripts: Executed without loading to context
- References: Loaded only when needed
Best practices:
- Use topic filters to get focused docs
- Adjust token limits based on query scope
- Cache results when appropriate
- Only invoke skill when documentation is actually needed
Resources
scripts/context7_client.py
Python client for Context7 API with CLI interface. Handles authentication, search, and documentation fetching. Can be executed directly without loading to context.
references/api_details.md
Detailed API reference including endpoints, authentication, rate limits, and error codes. Load into context if deeper API understanding is needed for debugging or advanced usage.
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon