Claude Code Plugins

Community-maintained marketplace

Feedback

Fetches library documentation from Context7 and saves it to ai_docs/ in organized category-based folders. Supports version management, topic-specific documentation, and refreshing existing docs. Automatically invoked for requests to fetch or save library documentation.

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name doc-fetcher
description Fetches library documentation from Context7 and saves it to ai_docs/ in organized category-based folders. Supports version management, topic-specific documentation, and refreshing existing docs. Automatically invoked for requests to fetch or save library documentation.

Doc Fetcher Skill

Expert skill for fetching library documentation from Context7 and organizing it in the ai_docs/ directory with proper categorization and metadata tracking.

When to Use This Skill

Use this skill when the user:

  • Requests to fetch documentation for a library or framework
  • Asks to save library docs for future reference
  • Wants to update or refresh existing documentation
  • Needs specific topic documentation (e.g., "fetch Next.js routing docs")
  • Asks about downloading or storing API documentation

Trigger phrases:

  • "Fetch the LangGraph documentation"
  • "Get Next.js docs and save them to ai_docs"
  • "Download Playwright documentation"
  • "Refresh the React docs"
  • "Fetch Next.js routing documentation"
  • "Get the latest version of the Prisma docs"
  • "/fetch-docs langgraph" (explicit slash command)

What This Skill Does

Fetches library documentation from Context7 and organizes it in ai_docs/ with:

  1. Category-based organization (frameworks/, ai-ml/, databases/, etc.)
  2. Metadata tracking (.meta.json) for version and fetch history
  3. Topic-specific documentation files
  4. Version management (latest vs specific versions)
  5. Automatic refresh and update capabilities

Output:

  • Markdown documentation files in ai_docs/{category}/{library}/
  • Metadata tracking in .meta.json for each library
  • Support for multiple topics per library
  • Version-specific subdirectories when needed

Core Workflow

Step 1: Resolve Library ID

Before fetching documentation, resolve the library name to a Context7-compatible library ID:

Tool: mcp__context7__resolve-library-id
Input: { "libraryName": "Next.js" }
Output: List of matching libraries with IDs like "/vercel/next.js"

Selection criteria:

  • Prioritize exact name matches
  • Check documentation coverage (Code Snippet count)
  • Consider trust score (7-10 is authoritative)
  • If ambiguous, ask user to clarify

Skip this step if:

  • User provides explicit Context7 ID (e.g., "/vercel/next.js")
  • Library was previously fetched (ID stored in .meta.json)

Step 2: Determine Category

Categorize the library using references/categories.md:

Common categories:

  • frameworks/ - Web and application frameworks
  • ai-ml/ - AI, ML, and LLM libraries
  • databases/ - Database systems and ORMs
  • frontend/ - Frontend libraries and tools
  • backend/ - Backend utilities and tools
  • testing/ - Testing frameworks
  • devops/ - DevOps and infrastructure
  • utilities/ - General-purpose utilities

If category unclear:

  1. Check references/categories.md for common mappings
  2. Use library description from Context7 to infer category
  3. Default to utilities/ for general-purpose libraries
  4. Ask user if truly ambiguous

Step 3: Normalize Directory Name

Transform library name to valid directory name:

Rules:

  1. Lowercase everything: Next.js -> nextjs
  2. Remove special characters: shadcn/ui -> shadcn-ui
  3. Replace spaces with hyphens: Material UI -> material-ui
  4. Keep hyphens from original: date-fns -> date-fns

Examples:

  • "Next.js" -> nextjs
  • "LangGraph" -> langgraph
  • "shadcn/ui" -> shadcn-ui
  • "@angular/core" -> angular-core

Step 4: Fetch Documentation

Fetch documentation using Context7:

Tool: mcp__context7__get-library-docs
Input: {
  "context7CompatibleLibraryID": "/vercel/next.js",
  "tokens": 5000,                    // Default 5000, adjustable
  "topic": "routing"                 // Optional, omit for general docs
}

Token guidelines:

  • Default: 5000 tokens (good balance of detail and context usage)
  • Large topics (e.g., "complete API reference"): 8000-10000 tokens
  • Specific topics (e.g., "hooks"): 3000-5000 tokens
  • Overview/getting started: 3000 tokens

Topic parameter:

  • Omit for general/overview documentation
  • Specify for focused documentation (e.g., "routing", "hooks", "API reference")
  • Topic becomes the filename (routing.md, hooks.md, etc.)

Step 5: Create Directory Structure

Create the appropriate directory structure:

For latest version (default):

ai_docs/{category}/{library}/

For specific version:

ai_docs/{category}/{library}/{version}/

Example paths:

  • ai_docs/frameworks/nextjs/ (latest)
  • ai_docs/frameworks/nextjs/v14/ (specific version)
  • ai_docs/ai-ml/langgraph/ (latest)

Step 6: Save Documentation

Save the fetched documentation to appropriate file:

File naming:

  • General/overview: README.md
  • Specific topic: {topic-normalized}.md

Topic normalization:

  • Lowercase all words
  • Replace spaces with hyphens
  • Remove special characters except hyphens
  • Examples:
    • "API Routes" -> api-routes.md
    • "Server Components" -> server-components.md
    • "State Graphs" -> state-graphs.md

Full path examples:

  • ai_docs/frameworks/nextjs/README.md (general docs)
  • ai_docs/frameworks/nextjs/routing.md (routing topic)
  • ai_docs/ai-ml/langgraph/state-graphs.md (state graphs topic)

Step 7: Update Metadata

Create or update .meta.json in the library directory:

Structure:

{
  "library_name": "Next.js",
  "context7_id": "/vercel/next.js",
  "category": "frameworks",
  "last_updated": "2025-10-23T14:30:00Z",
  "version": "latest",
  "fetches": [
    {
      "topic": "general",
      "file": "README.md",
      "tokens": 5000,
      "fetched_at": "2025-10-23T14:30:00Z"
    }
  ]
}

Operations:

  • New library: Create .meta.json with first fetch
  • Existing library, new topic: Append to fetches array
  • Refresh existing topic: Update existing fetch entry with new timestamp
  • Always update last_updated field

Step 8: Report to User

Provide clear confirmation:

Success message template:

Fetched {library_name} documentation and saved to:
- Location: ai_docs/{category}/{library}/{file}
- Topic: {topic or "general overview"}
- Tokens: {token_count}
- Version: {version or "latest"}

You can now reference this documentation directly from ai_docs/.

Example:

Fetched Next.js documentation and saved to:
- Location: ai_docs/frameworks/nextjs/routing.md
- Topic: routing
- Tokens: 3500
- Version: latest

You can now reference this documentation directly from ai_docs/.

Advanced Features

Refresh Existing Documentation

When user requests refresh or update:

  1. Check for existing .meta.json
  2. Locate existing fetch entry for same topic
  3. Re-fetch using same Context7 ID and topic
  4. Overwrite existing file
  5. Update metadata with new timestamp
  6. Report what was refreshed

Example:

User: "Refresh the Next.js routing docs"

1. Load ai_docs/frameworks/nextjs/.meta.json
2. Find fetch entry with topic="routing"
3. Re-fetch from /vercel/next.js with topic="routing"
4. Overwrite ai_docs/frameworks/nextjs/routing.md
5. Update fetched_at timestamp in metadata
6. Confirm: "Refreshed Next.js routing documentation (was last updated 2 days ago)"

Version Management

When user specifies a version:

Pattern 1: User provides version explicitly

User: "Fetch Next.js v14 documentation"

1. Resolve to /vercel/next.js/v14.3.0-canary.87 (or closest match)
2. Create ai_docs/frameworks/nextjs/v14/ directory
3. Save to ai_docs/frameworks/nextjs/v14/README.md
4. Store version in .meta.json as "v14.3.0-canary.87"

Pattern 2: Latest version (default)

User: "Fetch Next.js documentation"

1. Resolve to /vercel/next.js (latest)
2. Save to ai_docs/frameworks/nextjs/README.md (no version subfolder)
3. Store version in .meta.json as "latest"

Pattern 3: Multiple versions

ai_docs/frameworks/nextjs/
 README.md           # Latest version
 .meta.json         # Latest version metadata
 v14/
    README.md
    .meta.json     # v14-specific metadata
 v13/
     README.md
     .meta.json     # v13-specific metadata

Multiple Topics

Fetch multiple topics in sequence:

User: "Fetch Next.js docs for routing, API routes, and server components"

Actions:
1. Fetch routing -> ai_docs/frameworks/nextjs/routing.md
2. Fetch API routes -> ai_docs/frameworks/nextjs/api-routes.md
3. Fetch server components -> ai_docs/frameworks/nextjs/server-components.md
4. Update .meta.json with all three fetches
5. Report all three files created

Metadata after multiple topics:

{
  "library_name": "Next.js",
  "context7_id": "/vercel/next.js",
  "category": "frameworks",
  "last_updated": "2025-10-23T15:45:00Z",
  "version": "latest",
  "fetches": [
    {
      "topic": "general",
      "file": "README.md",
      "tokens": 5000,
      "fetched_at": "2025-10-23T14:00:00Z"
    },
    {
      "topic": "routing",
      "file": "routing.md",
      "tokens": 3500,
      "fetched_at": "2025-10-23T15:30:00Z"
    },
    {
      "topic": "api routes",
      "file": "api-routes.md",
      "tokens": 2800,
      "fetched_at": "2025-10-23T15:35:00Z"
    },
    {
      "topic": "server components",
      "file": "server-components.md",
      "tokens": 4200,
      "fetched_at": "2025-10-23T15:45:00Z"
    }
  ]
}

Error Handling

Library Not Found

Symptom: Context7 resolve-library-id returns no matches

Response:

I couldn't find "{library_name}" in Context7's library database.

Possible solutions:
1. Try a different name (e.g., "React" instead of "ReactJS")
2. Check the official library name on GitHub or npm
3. The library may not be in Context7's database yet
4. Try fetching from official docs manually and I can help organize it

Would you like me to search for similar libraries?

Ambiguous Library Name

Symptom: Multiple strong matches from resolve-library-id

Response:

Found multiple matches for "{library_name}":
1. /vercel/next.js - Next.js web framework (Trust: 10, Coverage: High)
2. /another-org/next - Different library (Trust: 5, Coverage: Low)

Which one would you like to fetch? (I recommend #1 based on trust score)

Category Unclear

Symptom: Library doesn't match any category in references/categories.md

Response:

I need help categorizing "{library_name}".

Based on the description: "{library_description}"

Which category fits best?
1. frameworks/ - Web/app frameworks
2. utilities/ - General-purpose utilities
3. Other (please specify)

Fetch Failure

Symptom: get-library-docs returns error or empty content

Response:

Failed to fetch documentation for {library_name}.

Error: {error_message}

Possible causes:
1. Library ID may be incorrect
2. Context7 service may be temporarily unavailable
3. Documentation may not be available for this version

Would you like me to:
1. Try again with different parameters
2. Attempt to fetch from official docs URL instead
3. Search for alternative documentation sources

File Write Error

Symptom: Cannot create directory or write file

Response:

Error saving documentation to ai_docs/{path}

Error: {error_message}

Please check:
1. Write permissions for ai_docs/ directory
2. Available disk space
3. Path validity (Windows path length limits, special characters)

I can retry after you've checked these issues.

Usage Examples

Example 1: Simple Fetch

User: "Fetch the LangGraph documentation"

Actions:

  1. Resolve "LangGraph" -> /langchain-ai/langgraph
  2. Determine category: ai-ml (from references/categories.md)
  3. Normalize name: langgraph
  4. Fetch general docs (no topic specified, 5000 tokens)
  5. Create ai_docs/ai-ml/langgraph/
  6. Save to ai_docs/ai-ml/langgraph/README.md
  7. Create .meta.json with fetch metadata

Response:

Fetched LangGraph documentation and saved to:
- Location: ai_docs/ai-ml/langgraph/README.md
- Topic: general overview
- Tokens: 5000
- Version: latest

You can now reference this documentation directly from ai_docs/.

Example 2: Topic-Specific Fetch

User: "Get Next.js routing documentation"

Actions:

  1. Resolve "Next.js" -> /vercel/next.js
  2. Category: frameworks
  3. Normalize: nextjs
  4. Fetch with topic="routing" (3500 tokens)
  5. Check if ai_docs/frameworks/nextjs/ exists:
    • If yes: Add to existing directory
    • If no: Create directory
  6. Save to ai_docs/frameworks/nextjs/routing.md
  7. Update or create .meta.json

Response:

Fetched Next.js routing documentation and saved to:
- Location: ai_docs/frameworks/nextjs/routing.md
- Topic: routing
- Tokens: 3500
- Version: latest

Added to existing Next.js documentation directory.

Example 3: Refresh Existing Docs

User: "Refresh the React documentation"

Actions:

  1. Check ai_docs/frameworks/react/.meta.json exists
  2. Load metadata to get Context7 ID: /facebook/react
  3. Re-fetch general docs (same parameters as original)
  4. Overwrite ai_docs/frameworks/react/README.md
  5. Update last_updated and fetch entry in metadata

Response:

Refreshed React documentation:
- Location: ai_docs/frameworks/react/README.md
- Previously updated: 5 days ago
- New fetch timestamp: 2025-10-23T16:20:00Z
- Tokens: 5000

Documentation is now up to date.

Example 4: Specific Version

User: "Fetch Next.js v14 documentation"

Actions:

  1. Resolve "Next.js v14" -> /vercel/next.js/v14.3.0-canary.87
  2. Category: frameworks
  3. Normalize: nextjs
  4. Extract version: v14
  5. Create ai_docs/frameworks/nextjs/v14/
  6. Save to ai_docs/frameworks/nextjs/v14/README.md
  7. Create version-specific .meta.json

Response:

Fetched Next.js v14 documentation and saved to:
- Location: ai_docs/frameworks/nextjs/v14/README.md
- Topic: general overview
- Tokens: 5000
- Version: v14.3.0-canary.87

Version-specific documentation saved to separate directory.

Example 5: Multiple Topics

User: "Fetch Playwright docs for testing, selectors, and debugging"

Actions:

  1. Resolve "Playwright" -> /microsoft/playwright
  2. Category: testing
  3. Normalize: playwright
  4. Fetch three topics in sequence:
    • testing -> testing.md
    • selectors -> selectors.md
    • debugging -> debugging.md
  5. Update .meta.json with all three fetches

Response:

Fetched Playwright documentation (3 topics) and saved to:

1. ai_docs/testing/playwright/testing.md
   - Topic: testing
   - Tokens: 4000

2. ai_docs/testing/playwright/selectors.md
   - Topic: selectors
   - Tokens: 3200

3. ai_docs/testing/playwright/debugging.md
   - Topic: debugging
   - Tokens: 3500

All topics saved. Total documentation: 3 files, 10,700 tokens.

Example 6: Slash Command

User: /fetch-docs langgraph

Actions: Same as Example 1 (simple fetch), but triggered via explicit slash command

Note: The /fetch-docs slash command provides a structured interface for this skill

Integration with Existing Documentation

Migration from Flat Structure

If ai_docs/ already exists with flat structure:

Existing structure:

ai_docs/
 langgraph/
    README.md
 nextjs/
     README.md

Migration approach:

  1. Detect existing libraries
  2. Determine categories for each
  3. Ask user: "I found existing docs. Should I reorganize into category structure?"
  4. If yes:
    • Move langgraph/ -> ai-ml/langgraph/
    • Move nextjs/ -> frameworks/nextjs/
    • Create .meta.json for each with inferred metadata
  5. Report migration results

After migration:

ai_docs/
 ai-ml/
    langgraph/
        README.md
        .meta.json
 frameworks/
     nextjs/
         README.md
         .meta.json

Coexistence with Manual Documentation

If user has manually added documentation:

Scenario:

ai_docs/
 custom-notes/
     my-research.md

Approach:

  1. Don't modify directories that don't have .meta.json
  2. Create category-based structure alongside manual docs
  3. Inform user about mixed structure

Result:

ai_docs/
 custom-notes/           # User's manual docs (untouched)
    my-research.md
 ai-ml/                  # Skill-managed docs
     langgraph/
         README.md
         .meta.json

Slash Command Integration

This skill can be invoked via /fetch-docs slash command (see .claude/commands/):

Usage:

/fetch-docs <library-name> [options]

Options:
  --topic=<topic>           # Fetch specific topic
  --version=<version>       # Fetch specific version
  --tokens=<count>          # Override default token count (5000)
  --refresh                 # Refresh existing documentation

Examples:
  /fetch-docs langgraph
  /fetch-docs nextjs --topic=routing
  /fetch-docs react --version=18
  /fetch-docs playwright --topic=testing --tokens=8000
  /fetch-docs nextjs --refresh

Slash command behavior:

  • Parses arguments and invokes this skill
  • Provides structured interface for common operations
  • Supports batch operations (future enhancement)

Best Practices

Token Allocation

Recommended token counts by use case:

  • Quick reference: 3000 tokens
  • General overview: 5000 tokens (default)
  • Comprehensive topic: 7000-8000 tokens
  • Full API reference: 10,000+ tokens

Token efficiency:

  • Fetch specific topics instead of everything
  • Use topic parameter to focus documentation
  • General README.md should be broad overview
  • Deep-dive topics should be separate files

Category Selection

When in doubt:

  1. Primary use case determines category
  2. Libraries can belong to multiple categories in theory, but choose ONE
  3. Most specific category wins (e.g., Next.js is frameworks/ not frontend/)
  4. Consistency matters - check existing structure first

Metadata Hygiene

Always:

  • Update last_updated timestamp on any fetch
  • Append new fetches to array (don't replace)
  • Preserve version information
  • Include token count (helps estimate context usage)

Never:

  • Delete existing fetch entries (keep history)
  • Modify Context7 ID (breaking change)
  • Skip metadata updates (causes sync issues)

File Organization

Do:

  • Use README.md for general/overview documentation
  • Create topic-specific files for focused content
  • Keep version-specific docs in subdirectories
  • Normalize all filenames consistently

Don't:

  • Mix versions in same directory
  • Create deeply nested subdirectories (max 2 levels: category/library or category/library/version)
  • Use spaces or special characters in filenames
  • Create generic filenames like "docs.md" or "info.md"

Performance

Target: <5 seconds for typical fetch operation

Factors affecting speed:

  • Context7 API response time: 1-3 seconds
  • File I/O operations: <1 second
  • Metadata updates: <1 second
  • Library resolution: 1-2 seconds

Optimization:

  • Cache resolved library IDs in memory (avoid re-resolving)
  • Batch multiple topics if possible
  • Skip resolution if Context7 ID already known

Validation Checklist

Before confirming successful fetch:

  • Library ID successfully resolved (or provided by user)
  • Category determined (from mapping or user input)
  • Directory created at correct path
  • Documentation file saved with correct name
  • .meta.json created or updated
  • All timestamps in ISO 8601 format
  • File paths use forward slashes (cross-platform compatibility)
  • Success message displayed to user

Troubleshooting

Issue: Skill not auto-triggering

  • Verify you're using trigger phrases like "fetch docs" or "get documentation"
  • Try explicit slash command: /fetch-docs <library>
  • Check .claude/skills/doc-fetcher/SKILL.md exists

Issue: Category not recognized

  • Check references/categories.md for mappings
  • Add custom mapping if needed
  • Default to utilities/ category

Issue: Version directory already exists

  • Check if refresh intended (overwrite existing)
  • Confirm version number format matches
  • May need to manually clean up old versions

Issue: Metadata file corrupted

  • Delete .meta.json and re-fetch
  • Skill will recreate metadata from scratch
  • Original documentation files preserved

For detailed examples: See references/example-structure.md For category mappings: See references/categories.md