home / skills / am-will / codex-skills / context7

context7 skill

/skills/context7

This skill fetches up-to-date library documentation from Context7 to ensure current APIs and best practices are applied.

npx playbooks add skill am-will/codex-skills --skill context7

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

Files (3)
SKILL.md
2.1 KB
---
name: context7
description: |
  Fetch up-to-date library documentation via Context7 API. Use PROACTIVELY when:
  (1) Working with ANY external library (React, Next.js, Supabase, etc.)
  (2) User asks about library APIs, patterns, or best practices
  (3) Implementing features that rely on third-party packages
  (4) Debugging library-specific issues
  (5) Need current documentation beyond training data cutoff
  (6) AND MOST IMPORTANTLY, when you are installing dependencies, libraries, or frameworks you should ALWAYS check the docs to see what the latest versions are. Do not rely on outdated knowledge.
  Always prefer this over guessing library APIs or using outdated knowledge.
---

# Context7 Documentation Fetcher

Retrieve current library documentation via Context7 API.

IMPORTANT: `CONTEXT7_API_KEY` IS STORED IN THE .env FILE IN THE SKILL FOLDER THAT THE CONTEXT7 SKILL IS INSTALLED IN. SEARCH FOR IT THERE. .env FILES ARE HIDDEN FILES. 

Example: 
~/.agents/skills/context7/.env
~/.claude/skills/context7/.env

## Workflow

### 1. Search for the library

```bash
python3 ~/.codex/skills/context7/scripts/context7.py search "<library-name>"
```

Example:
```bash
python3 ~/.codex/skills/context7/scripts/context7.py search "next.js"
```

Returns library metadata including the `id` field needed for step 2.

### 2. Fetch documentation context

```bash
python3 ~/.codex/skills/context7/scripts/context7.py context "<library-id>" "<query>"
```

Example:
```bash
python3 ~/.codex/skills/context7/scripts/context7.py context "/vercel/next.js" "app router middleware"
```

Options:
- `--type txt|md` - Output format (default: txt)
- `--tokens N` - Limit response tokens

## Quick Reference

| Task | Command |
|------|---------|
| Find React docs | `search "react"` |
| Get React hooks info | `context "/facebook/react" "useEffect cleanup"` |
| Find Supabase | `search "supabase"` |
| Get Supabase auth | `context "/supabase/supabase" "authentication row level security"` |

## When to Use

- Before implementing any library-dependent feature
- When unsure about current API signatures
- For library version-specific behavior
- To verify best practices and patterns

Overview

This skill fetches up-to-date library documentation via the Context7 API. It helps you find current API signatures, patterns, and best practices for any external library. Use it proactively instead of guessing or relying on outdated training data when working with third-party packages.

How this skill works

The skill authenticates with a Context7 API key from your environment and performs two main actions: search for a library to obtain its Context7 ID, then fetch focused documentation context for a specific query. Commands return library metadata and targeted docs snippets in text or Markdown, with optional token limits to control response size.

When to use it

  • Before implementing features that depend on external libraries or frameworks
  • When installing or upgrading dependencies to verify latest versions and breaking changes
  • When a user asks about library APIs, function signatures, or recommended patterns
  • While debugging library-specific behavior or version-dependent bugs
  • When you need documentation beyond your model’s training cutoff

Best practices

  • Always set CONTEXT7_API_KEY in your environment or a local .env before calling the skill
  • First run a search to get the exact library id, then call context with that id and a concise query
  • Prefer precise queries (function names, error messages, component names) to get focused snippets
  • Use the --type and --tokens options to request Markdown or limit response length for compact answers
  • Cross-check docs snippets against package changelogs or release notes when planning upgrades

Example use cases

  • Search for Next.js docs and fetch details on the app router middleware behavior
  • Lookup React hook lifecycles and cleanup examples for useEffect
  • Fetch Supabase authentication and row-level security guidance for backend setup
  • Verify the latest API signature for a function before writing integration code
  • Investigate library-specific error messages while debugging a failing CI job

FAQ

How do I authenticate the skill?

Set CONTEXT7_API_KEY in your environment or use a local .env file sourced into your shell session.

What commands should I run?

First run 'search "<library>"' to get the library id, then run 'context "<library-id>" "<query>"' to fetch docs. Use --type and --tokens to control format and length.