
Context7
Pull current third-party library docs through the Context7 CLI so agents stop guessing APIs or stale package versions.
Overview
Context7 is a journey-wide agent skill that fetches up-to-date library documentation via the Context7 CLI whenever a solo builder needs accurate APIs before committing code or installs.
Install
npx skills add https://github.com/am-will/codex-skills --skill context7What is this skill?
- Two-step CLI workflow: context7.py search then context with library id and query
- Documented proactive triggers for APIs, patterns, debugging, and especially version checks when installing dependencies
- CONTEXT7_API_KEY loaded from the skill folder .env (hidden file paths under ~/.agents or ~/.claude skills)
- Replaces guessing library behavior from training cutoff with fetched documentation context
- Designed for React, Next.js, Supabase, and arbitrary npm ecosystems via search metadata id
- 2-step CLI workflow (search, then context)
Adoption & trust: 1.2k installs on skills.sh; 941 GitHub stars; 1/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are about to call a third-party library or pin a version but only have outdated model knowledge and no verified doc excerpt.
Who is it for?
Indie devs on fast-moving stacks (Next.js, Supabase, React ecosystems) who want agents to verify APIs at install and feature time.
Skip if: Fully offline workflows, proprietary internal SDKs not indexed by Context7, or tasks with zero external dependencies.
When should I use this skill?
Working with any external library, installing dependencies, debugging library-specific issues, or needing documentation beyond training cutoff—use proactively per skill description.
What do I get? / Deliverables
You run search plus context commands and inject current documentation context into the implementation or debug session.
- Library search metadata with id
- Fetched documentation context for a targeted query
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Fetch Supabase auth patterns before wiring signup in a new SaaS MVP.
Confirm the current Stripe webhook API shape while adding billing.
Pull Vitest config docs when a library upgrade breaks test setup.
Look up Redis client retry options during a production outage investigation.
Verify a UI library’s quickstart before choosing it for a throwaway prototype.
How it compares
Live documentation fetcher—not a UI component catalog and not a creative image juxtaposition workflow.
Common Questions / FAQ
Who is context7 for?
Solo and indie builders using Codex-compatible agents who integrate external libraries and need current docs instead of hallucinated APIs.
When should I use context7?
Use it journey-wide when implementing Build features, debugging Ship regressions, or investigating Operate incidents involving third-party packages—and always when adding or upgrading dependencies to confirm latest versions.
Is context7 safe to install?
It requires a Context7 API key in a local .env; review the Security Audits panel on this page and restrict key permissions and repo access before enabling network calls.
SKILL.md
READMESKILL.md - Context7
# Context7 API key (required) CONTEXT7_API_KEY= --- name: context7 description: | Fetch up-to-date library documentation via Context7 CLI. 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 #!/usr/bin/env python3 """ Context7 API client for searching libraries and fetching documentation. """ import argparse import json import sys import urllib.request import urllib.parse import urllib.error import os API_BASE = "https://context7.com/api/v2" def make_request(url: str, api_key: str) -> dict | str: """Make an authenticated request to Context7 API.""" headers = {"Authorization": f"Bearer {api_key}"} req = urllib.request.Request(url, headers=headers) try: with urllib.request.urlopen(req, timeout=30) as response: content_type = response.headers.get("Content-Type", "") data = response.read().decode("utf-8") if "application/json" in content_type: return json.loads(data) return data except urllib.error.HTTPError as e: return {"error": f"HTTP {e.code}: {e.reason}", "body": e.read().decode("utf-8")} except urllib.error.URLError as e: return {"error": f"URL Error: {e.reason}"} def search_libraries(library_name: str, api_key: str, query: str = "") -> dict: """Search for libraries by name and optional query.""" params = {"libraryName": library_name} if query: params["query"] = query url = f"{API_BASE}/libs/search?{urllib.parse.urlencode(params)}" return make_request(url, api_key) def get_context(library_id: str, query: str, api_key: str, output_type: str = "txt", tokens: int = None) -> str | dict: """Fetch documentation context for a specific library.""" params = { "libraryId": library_id, "query": query, "type": output_type } if tokens: params["tokens"] = tokens url = f"{API_BASE}/context?{urllib.parse.urlencode(params)}" return make_req