fetching-library-docs
Token-efficient library API documentation fetcher using Context7 MCP with 77% token savings. Fetches code examples, API references, and usage patterns for published libraries (React, Next.js, Prisma, etc). Use when users ask "how do I use X library", need code examples, want API syntax, or are learning a framework's official API. Triggers: "Show me React hooks", "Prisma query syntax", "Next.js routing API". NOT for exploring repo internals/source code (use researching-with-deepwiki) or local files.
Best use case
fetching-library-docs is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. Token-efficient library API documentation fetcher using Context7 MCP with 77% token savings. Fetches code examples, API references, and usage patterns for published libraries (React, Next.js, Prisma, etc). Use when users ask "how do I use X library", need code examples, want API syntax, or are learning a framework's official API. Triggers: "Show me React hooks", "Prisma query syntax", "Next.js routing API". NOT for exploring repo internals/source code (use researching-with-deepwiki) or local files.
Token-efficient library API documentation fetcher using Context7 MCP with 77% token savings. Fetches code examples, API references, and usage patterns for published libraries (React, Next.js, Prisma, etc). Use when users ask "how do I use X library", need code examples, want API syntax, or are learning a framework's official API. Triggers: "Show me React hooks", "Prisma query syntax", "Next.js routing API". NOT for exploring repo internals/source code (use researching-with-deepwiki) or local files.
Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.
Practical example
Example input
Use the "fetching-library-docs" skill to help with this workflow task. Context: Token-efficient library API documentation fetcher using Context7 MCP with 77% token savings. Fetches code examples, API references, and usage patterns for published libraries (React, Next.js, Prisma, etc). Use when users ask "how do I use X library", need code examples, want API syntax, or are learning a framework's official API. Triggers: "Show me React hooks", "Prisma query syntax", "Next.js routing API". NOT for exploring repo internals/source code (use researching-with-deepwiki) or local files.
Example output
A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.
When to use this skill
- Use this skill when you want a reusable workflow rather than writing the same prompt again and again.
When not to use this skill
- Do not use this when you only need a one-off answer and do not need a reusable workflow.
- Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/fetching-library-docs/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How fetching-library-docs Compares
| Feature / Agent | fetching-library-docs | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Token-efficient library API documentation fetcher using Context7 MCP with 77% token savings. Fetches code examples, API references, and usage patterns for published libraries (React, Next.js, Prisma, etc). Use when users ask "how do I use X library", need code examples, want API syntax, or are learning a framework's official API. Triggers: "Show me React hooks", "Prisma query syntax", "Next.js routing API". NOT for exploring repo internals/source code (use researching-with-deepwiki) or local files.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agent for SaaS Idea Validation
Use AI agent skills for SaaS idea validation, market research, customer discovery, competitor analysis, and documenting startup hypotheses.
SKILL.md Source
# Context7 Efficient Documentation Fetcher Fetch library documentation with automatic 77% token reduction via shell pipeline. ## Quick Start **Always use the token-efficient shell pipeline:** ```bash # Automatic library resolution + filtering bash scripts/fetch-docs.sh --library <library-name> --topic <topic> # Examples: bash scripts/fetch-docs.sh --library react --topic useState bash scripts/fetch-docs.sh --library nextjs --topic routing bash scripts/fetch-docs.sh --library prisma --topic queries ``` **Result:** Returns ~205 tokens instead of ~934 tokens (77% savings). ## Standard Workflow For any documentation request, follow this workflow: ### 1. Identify Library and Topic Extract from user query: - **Library:** React, Next.js, Prisma, Express, etc. - **Topic:** Specific feature (hooks, routing, queries, etc.) ### 2. Fetch with Shell Pipeline ```bash bash scripts/fetch-docs.sh --library <library> --topic <topic> --verbose ``` The `--verbose` flag shows token savings statistics. ### 3. Use Filtered Output The script automatically: - Fetches full documentation (934 tokens, stays in subprocess) - Filters to code examples + API signatures + key notes - Returns only essential content (205 tokens to Claude) ## Parameters ### Basic Usage ```bash bash scripts/fetch-docs.sh [OPTIONS] ``` **Required (pick one):** - `--library <name>` - Library name (e.g., "react", "nextjs") - `--library-id <id>` - Direct Context7 ID (faster, skips resolution) **Optional:** - `--topic <topic>` - Specific feature to focus on - `--mode <code|info>` - code for examples (default), info for concepts - `--page <1-10>` - Pagination for more results - `--verbose` - Show token savings statistics ### Mode Selection **Code Mode (default):** Returns code examples + API signatures ```bash --mode code ``` **Info Mode:** Returns conceptual explanations + fewer examples ```bash --mode info ``` ## Common Library IDs Use `--library-id` for faster lookup (skips resolution): ```bash React: /reactjs/react.dev Next.js: /vercel/next.js Express: /expressjs/express Prisma: /prisma/docs MongoDB: /mongodb/docs Fastify: /fastify/fastify NestJS: /nestjs/docs Vue.js: /vuejs/docs Svelte: /sveltejs/site ``` ## Workflow Patterns ### Pattern 1: Quick Code Examples User asks: "Show me React useState examples" ```bash bash scripts/fetch-docs.sh --library react --topic useState --verbose ``` Returns: 5 code examples + API signatures + notes (~205 tokens) ### Pattern 2: Learning New Library User asks: "How do I get started with Prisma?" ```bash # Step 1: Get overview bash scripts/fetch-docs.sh --library prisma --topic "getting started" --mode info # Step 2: Get code examples bash scripts/fetch-docs.sh --library prisma --topic queries --mode code ``` ### Pattern 3: Specific Feature Lookup User asks: "How does Next.js routing work?" ```bash bash scripts/fetch-docs.sh --library-id /vercel/next.js --topic routing ``` Using `--library-id` is faster when you know the exact ID. ### Pattern 4: Deep Exploration User needs comprehensive information: ```bash # Page 1: Basic examples bash scripts/fetch-docs.sh --library react --topic hooks --page 1 # Page 2: Advanced patterns bash scripts/fetch-docs.sh --library react --topic hooks --page 2 ``` ## Token Efficiency **How it works:** 1. `fetch-docs.sh` calls `fetch-raw.sh` (which uses `mcp-client.py`) 2. Full response (934 tokens) stays in subprocess memory 3. Shell filters (awk/grep/sed) extract essentials (0 LLM tokens used) 4. Returns filtered output (205 tokens) to Claude **Savings:** - Direct MCP: 934 tokens per query - This approach: 205 tokens per query - **77% reduction** **Do NOT use `mcp-client.py` directly** - it bypasses filtering and wastes tokens. ## Advanced: Library Resolution If library name fails, try variations: ```bash # Try different formats --library "next.js" # with dot --library "nextjs" # without dot --library "next" # short form # Or search manually bash scripts/fetch-docs.sh --library "your-library" --verbose # Check output for suggested library IDs ``` ## Verification Run: `python3 scripts/verify.py` Expected: `✓ fetch-docs.sh ready` ## If Verification Fails 1. Run diagnostic: `ls -la scripts/fetch-docs.sh` 2. Check: Script exists and is executable 3. Fix: `chmod +x scripts/fetch-docs.sh` 4. **Stop and report** if still failing - do not proceed with downstream steps ## Troubleshooting | Issue | Solution | |-------|----------| | Library not found | Try name variations or use broader search term | | No results | Use `--mode info` or broader topic | | Need more examples | Increase page: `--page 2` | | Want full context | Use `--mode info` for explanations | | Permission denied | Run: `chmod +x scripts/*.sh` | ## References For detailed Context7 MCP tool documentation, see: - [references/context7-tools.md](references/context7-tools.md) - Complete tool reference ## Implementation Notes **Components (for reference only, use fetch-docs.sh):** - `mcp-client.py` - Universal MCP client (foundation) - `fetch-raw.sh` - MCP wrapper - `extract-code-blocks.sh` - Code example filter (awk) - `extract-signatures.sh` - API signature filter (awk) - `extract-notes.sh` - Important notes filter (grep) - `fetch-docs.sh` - **Main orchestrator (ALWAYS USE THIS)** **Architecture:** Shell pipeline processes documentation in subprocess, keeping full response out of Claude's context. Only filtered essentials enter the LLM context, achieving 77% token savings with 100% functionality preserved. Based on [Anthropic's "Code Execution with MCP" blog post](https://www.anthropic.com/engineering/code-execution-with-mcp).
Related Skills
zlibrary-to-notebooklm
自动从 Z-Library 下载书籍并上传到 Google NotebookLM。支持 PDF/EPUB 格式,自动转换,一键创建知识库。
github-actions-docs
Use when users ask how to write, explain, customize, migrate, secure, or troubleshoot GitHub Actions workflows, workflow syntax, triggers, matrices, runners, reusable workflows, artifacts, caching, secrets, OIDC, deployments, custom actions, or Actions Runner Controller, especially when they need official GitHub documentation, exact links, or docs-grounded YAML guidance.
terraform-module-library
Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components.
prompt-library
Curated collection of high-quality prompts for various use cases. Includes role-based prompts, task-specific templates, and prompt refinement techniques. Use when user needs prompt templates, role-play prompts, or ready-to-use prompt examples for coding, writing, analysis, or creative tasks.
docs-architect
Creates comprehensive technical documentation from existing codebases. Analyzes architecture, design patterns, and implementation details to produce long-form technical manuals and ebooks. Use PROACTIVELY for system documentation, architecture guides, or technical deep-dives.
docstring
Write docstrings for PyTorch functions and methods following PyTorch conventions. Use when writing or updating docstrings in PyTorch code.
docs-write
Write documentation following Metabase's conversational, clear, and user-focused style. Use when creating or editing documentation files (markdown, MDX, etc.).
docs-review
Review documentation changes for compliance with the Metabase writing style guide. Use when reviewing pull requests, files, or diffs containing documentation markdown files.
langgraph-docs
Use this skill for requests related to LangGraph in order to fetch relevant documentation to provide accurate, up-to-date guidance.
gws-docs
Read and write Google Docs.
gws-docs-write
Google Docs: Append text to a document.
native-data-fetching
Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, axios, React Query, SWR, error handling, caching strategies, offline support.