home / skills / choiruladamm / claude-context7-skill / claude-context7-skill

claude-context7-skill skill

/SKILL.md

This skill fetches up-to-date Context7 documentation for specified libraries, enabling accurate code examples, setup steps, and API references.

npx playbooks add skill choiruladamm/claude-context7-skill --skill claude-context7-skill

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.3 KB
---
name: context7-documentation-fetcher
description: Automatically fetches up-to-date library documentation from Context7 when code generation, setup instructions, or API documentation is needed
---

# Context7 Documentation Fetcher

## Overview

This skill automatically fetches up-to-date, version-specific documentation from Context7 whenever you need:
- Code generation for specific libraries
- Setup or configuration steps
- Library/API documentation
- Framework-specific implementations

Claude will automatically invoke this skill when it detects you're asking about libraries, frameworks, or need accurate API documentation.

## When This Skill Is Used

Claude automatically uses this skill when:
- You ask for code examples using specific libraries (e.g., "Create a form with React Hook Form")
- You request setup instructions (e.g., "How to setup Next.js 15 app router?")
- You need API documentation (e.g., "Show me Supabase auth methods")
- You mention library names in your questions
- You ask "how to" questions about frameworks or libraries

## How It Works

1. **Detect Library**: Claude identifies which library/framework you need docs for
2. **Search Context7**: Queries Context7 API to find the exact library ID
3. **Fetch Docs**: Retrieves up-to-date documentation with relevant code examples
4. **Generate Code**: Uses fresh docs to provide accurate, non-hallucinated code

## Supported Libraries

This skill can fetch documentation for any library available in Context7, including:
- **Frontend**: React, Next.js, Vue, Nuxt, Svelte, Astro
- **State Management**: Zustand, Redux, TanStack Query, Jotai
- **Forms**: React Hook Form, Formik, Zod
- **Backend**: Express, Fastify, Hono, tRPC
- **Database**: Supabase, Prisma, Drizzle, MongoDB
- **UI Libraries**: Tailwind CSS, shadcn/ui, Radix UI, Mantine
- **And many more...**

## Examples

### Example 1: Form Validation
**User**: "Create a login form with React Hook Form and Zod validation"

**What happens**:
1. Skill searches Context7 for "react hook form" and "zod"
2. Fetches docs with topic="validation" and topic="integration"
3. Claude generates accurate code using current API methods

### Example 2: Next.js Setup
**User**: "Setup Next.js 15 with app router and server actions"

**What happens**:
1. Skill searches for "next.js"
2. Fetches docs with topic="app router" and topic="server actions"
3. Claude provides step-by-step setup with correct configuration

### Example 3: Database Integration
**User**: "How do I setup Supabase authentication?"

**What happens**:
1. Skill searches for "supabase"
2. Fetches docs with topic="authentication"
3. Claude shows current auth methods and code examples

## Technical Details

### API Integration
The skill uses Context7's REST API:
- **Search Endpoint**: `GET /api/v1/search?query={library_name}`
- **Docs Endpoint**: `GET /api/v1/{library_id}?topic={topic}&tokens={limit}`

### Configuration
- **API Key**: Pre-configured (secure)
- **Default Token Limit**: 5000 tokens per request
- **Response Format**: Plain text suitable for direct display
- **Rate Limits**: Follows Context7 free tier limits

### Error Handling
If a library is not found or docs are unavailable:
1. Claude will inform you the library isn't available in Context7
2. Claude will fall back to its training knowledge with appropriate caveats
3. Claude may suggest alternative libraries that are available

## Best Practices

1. **Be Specific**: Mention the exact library name for best results
   - Good: "Create form with React Hook Form"
   - Less good: "Create a form" (skill won't know which library to fetch)

2. **Include Version**: If you need a specific version, mention it
   - "Using Next.js 15..." (skill will attempt to fetch that version)

3. **Mention Topics**: Include relevant topics for focused docs
   - "Next.js server actions" → fetches server actions docs specifically
   - "Supabase realtime" → fetches realtime-specific documentation

## Limitations

- Only fetches from libraries available in Context7's database
- Limited to Context7's free tier rate limits (generous for daily use)
- Cannot access private/proprietary documentation
- Requires internet connection to fetch docs

## Resources

For more information about Context7:
- Website: https://context7.com
- GitHub: https://github.com/upstash/context7
- Add Libraries: https://context7.com/add-library

Overview

This skill automatically fetches up-to-date, version-specific library documentation from Context7 whenever accurate code generation, setup instructions, or API references are needed. It prevents hallucinated APIs by sourcing official docs and returns focused snippets and examples tailored to the requested library and topic. Claude invokes it automatically when library names, frameworks, or API usage are detected.

How this skill works

The skill detects which library or framework you referenced and queries Context7 to find the exact library ID. It then retrieves documentation for the specified topic and version limits, returning plain-text docs and examples. Claude uses those fresh docs to generate accurate code, setup steps, or API explanations and falls back to model knowledge with caveats if docs are unavailable.

When to use it

  • When you need precise code examples for a specific library or version
  • When asking for setup or configuration steps (framework bootstraps, build tools)
  • When you require current API documentation or method signatures
  • When integrating multiple libraries and you want authoritative examples
  • When you want to avoid hallucinated or outdated API usage

Best practices

  • Specify the exact library name and, if relevant, the version
  • Mention the specific topic (e.g., "authentication", "app router", "validation") for focused results
  • Ask for code examples and include target environment (browser, Node, serverless)
  • Request token-limited excerpts if you want concise snippets instead of full pages
  • If a library is uncommon, allow the skill to search similar libraries or suggest alternatives

Example use cases

  • Create a login form with React Hook Form and Zod validation, returning current API usage and examples
  • Setup Next.js 15 with app router and server actions, including correct configuration files
  • Show Supabase authentication methods and sample client/server code for the current API
  • Integrate TanStack Query with React and provide hook signatures and cache examples
  • Generate migration instructions from Prisma to Drizzle using up-to-date CLI and schema syntax

FAQ

What happens if Context7 does not have the library?

If the library is not found, the skill notifies you and Claude falls back to model knowledge with clear caveats and may suggest alternative libraries available in Context7.

Can I request docs for a specific version?

Yes. Mention the version in your request and the skill will attempt to fetch version-specific documentation where Context7 provides it.