---
name: context7-c33a8c0db544
description: "Library documentation lookup with tokenization and reranking. Use when user mentions external libraries, frameworks, or packages (e.g., how do I use React hooks, FastAPI authentication, pandas DataFrame). Triggers on library names, package imports, framework questions. Returns top 5 most relevant documentation chunks."
---

# Context7 - Library Documentation

Fetch up-to-date documentation for any library with intelligent chunking and reranking.

## Workflow

### Step 1: Resolve Library ID

First, resolve the library name to a Context7-compatible ID:

```
mcp__context7__resolve-library-id({ libraryName: "<package name>" })
```

Example: `libraryName: "react"` → returns `/facebook/react`

### Step 2: Get Documentation

Fetch docs with topic focus and token budget:

```
mcp__context7__get-library-docs({
  context7CompatibleLibraryID: "<library_id>",
  topic: "<specific topic>",
  tokens: 5000
})
```

### Step 3: Rerank Results

After receiving documentation, apply this mental reranking:

1. **Score by relevance** - Prioritize chunks containing query terms
2. **Consider recency** - Newer API patterns over deprecated ones
3. **Focus on examples** - Code snippets > prose descriptions
4. **Limit to top 5** - Present only the 5 most relevant chunks

## Quick Reference

| Library Type | Example Query | Topic |
|-------------|---------------|-------|
| React/Vue/Angular | "React hooks for state" | "hooks" or "useState" |
| FastAPI/Flask/Django | "FastAPI authentication" | "auth" or "security" |
| Pandas/NumPy | "pandas merge dataframes" | "merge" or "join" |
| SQLAlchemy/Prisma | "SQLAlchemy relationships" | "relationships" |
| Testing libs | "pytest fixtures" | "fixtures" |

## Token Budget Guidelines

- **Quick lookup**: 2000-3000 tokens
- **Deep dive**: 5000-8000 tokens
- **Comprehensive**: 10000+ tokens

## Reranking Script

For programmatic reranking, use the wrapper script:

```bash
# Process context7 output and rerank
python ~/.config/context7/context7_wrapper.py process \
  --query "authentication middleware" \
  --top 5 \
  --input docs.md
```

## Error Handling

If library not found:
1. Try alternative names (e.g., "nextjs" vs "next.js")
2. Check for organization prefix (e.g., "/vercel/next.js")
3. Search for related libraries

## Examples

### React Hooks
```
1. resolve-library-id({ libraryName: "react" })
2. get-library-docs({
     context7CompatibleLibraryID: "/facebook/react",
     topic: "hooks",
     tokens: 5000
   })
```

### FastAPI Auth
```
1. resolve-library-id({ libraryName: "fastapi" })
2. get-library-docs({
     context7CompatibleLibraryID: "/tiangolo/fastapi",
     topic: "security oauth2",
     tokens: 5000
   })
```


---
Source attribution: zach-source
Original project: https://github.com/zach-source/claude-plugins/blob/61adbbc283466a1755a493153bfe79e7df2bdf77/plugins/ai-memory/skills/context7/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2025 Zach Taylor

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: zach-source
Original project: https://github.com/zach-source/claude-plugins/blob/61adbbc283466a1755a493153bfe79e7df2bdf77/plugins/ai-memory/skills/context7/SKILL.md
Attribution basis: Source repository record

Fields of work: Data & Analytics, Development & Engineering
Roles: Backend Developer, Data Scientist, Frontend Developer, Full-Stack Developer, QA / Test Engineer
Specialties: API
Tools: Context7
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: d706e6eb773c8fa7dcd441459e2e837422bcee19a332282ccf57307aa0da81c9
