Fetch and cache API documentation in AI-readable markdown format.
Fetch and cache API documentation in markdown format for offline access across all projects. Use when starting with a new library or when you need quick reference without browsing docs online.
/plugin marketplace add unclecode/claude-code-tools/plugin install unclecode-cc-toolkit@unclecode-toolsFetch and cache API documentation in AI-readable markdown format.
$ARGUMENTS
Library name, URL, or package identifier (e.g., "openai", "stripe", "https://docs.stripe.com")
Download and cache API documentation locally for quick reference across all projects. Docs are stored globally in the plugin directory and available in all chat sessions.
Global (available across all projects):
~/.claude/plugins/marketplaces/unclecode-tools/plugins/unclecode-cc-toolkit/api-docs/
Extract from query:
Normalize library name:
Check for existing documentation:
ls ~/.claude/plugins/marketplaces/unclecode-tools/plugins/unclecode-cc-toolkit/api-docs/{library}/
If directory exists:
ls -lah api-docs/{library}/## Documentation Exists
**Library**: {library}
**Location**: api-docs/{library}/
**Last Updated**: {date from stat}
**Files**: {file count} files, {total size}
Documentation already cached. Would you like to:
1. Use existing docs (skip)
2. Update/re-fetch docs
3. View what's cached
Wait for user response.
If doesn't exist:
Try these methods in order:
If library name provided (no URL):
# Search for library
curl -X GET "https://context7.com/api/v1/search?query={library}" \
-H "Authorization: Bearer CONTEXT7_API_KEY"
# Get library ID from response
# Then fetch docs
curl -X GET "https://context7.com/api/v1/{library_id}/docs?type=txt&tokens=5000" \
-H "Authorization: Bearer CONTEXT7_API_KEY"
Note: Free tier available (no API key needed but rate-limited)
Save response to: api-docs/{library}/context7-docs.md
If successful, skip to Step 4.
If URL provided OR Context7 doesn't have it:
{domain}/llms.txt:curl -s https://{domain}/llms.txt
api-docs/{library}/{filename}.mdIf successful, skip to Step 4.
If neither Context7 nor llms.txt available:
Fetch the docs page HTML
Convert HTML to markdown using a clean method:
Save to: api-docs/{library}/scraped-docs.md
Add note at top of file:
<!-- Scraped from {URL} on {date} -->
<!-- May need manual review for accuracy -->
Create api-docs/{library}/metadata.json:
{
"library": "library-name",
"source": "context7|llms.txt|web-scraped",
"sourceUrl": "original-url",
"fetchedAt": "2025-01-23T10:30:00Z",
"fileCount": 3,
"totalSize": "250KB",
"version": "4.0.0" (if specified)
}
If multiple files were fetched, create api-docs/{library}/INDEX.md:
# {Library} API Documentation
**Fetched from**: {source}
**Date**: {date}
**Version**: {version if known}
## Files
- [context7-docs.md](./context7-docs.md) - Main documentation
- [api-reference.md](./api-reference.md) - API reference
- [guides.md](./guides.md) - Usage guides
## Quick Links
{Parse and list major sections/topics}
Show summary:
## Documentation Fetched Successfully
**Library**: {library}
**Source**: {Context7 | llms.txt | Web}
**Location**: ~/.claude/plugins/.../api-docs/{library}/
**Files Saved**: {count} files ({total size})
### What's Available:
{List files with brief description}
### Usage:
These docs are now available globally across all projects.
To reference in your code:
- Ask Claude to "check {library} docs"
- Use /pp-triage for debugging with library context
- Docs automatically available in all future sessions
### Next Steps:
- View docs: cat api-docs/{library}/INDEX.md
- Update later: /pp-fetch-docs {library} (will prompt to update)
# Fetch by library name (tries Context7 first)
/pp-fetch-docs openai
/pp-fetch-docs stripe
/pp-fetch-docs nextjs
# Fetch by URL (tries llms.txt, then scrapes)
/pp-fetch-docs https://docs.stripe.com
/pp-fetch-docs https://platform.openai.com/docs
# Fetch specific version
/pp-fetch-docs openai@4.0
/pp-fetch-docs react@18
# Update existing docs
/pp-fetch-docs openai
> "Documentation exists. Update? (yes/no)"
> yes
> (re-fetches and overwrites)
If all methods fail:
## Unable to Fetch Documentation
**Library**: {library}
**Attempted**:
- ❌ Context7: Library not found
- ❌ llms.txt: Not available at {domain}
- ❌ Web scraping: {error reason}
### Suggestions:
1. Check library name spelling
2. Provide full URL to documentation
3. Try alternative library name (e.g., "@openai/sdk" vs "openai")
4. Manually download docs and save to:
~/.claude/plugins/.../api-docs/{library}/docs.md
Would you like me to:
- Search for alternative library names?
- Try a different URL?
- Help you manually organize docs?
For Context7 higher rate limits:
export CONTEXT7_API_KEY="your-key"When to fetch:
Storage management:
rm -rf api-docs/{library}/ls api-docs/