Context7
Fetch current documentation for any library or framework via the Context7 API. Use this instead of relying on potentially outdated training data.
Arguments
$ARGUMENTS
Parse the arguments as <library> <topic>. If only a library name is given, use a general query.
Workflow
Step 1: Resolve the library ID
curl -s ${CONTEXT7_API_KEY:+-H "x-api-key: $CONTEXT7_API_KEY"} "https://context7.com/api/v2/libs/search?libraryName=LIBRARY_NAME&query=TOPIC" | jq '.results[:3]'
Pick the best match. The id field is the library ID for step 2. If no results, try alternative names (e.g. "nextjs" vs "next.js").
Step 2: Fetch documentation
curl -s ${CONTEXT7_API_KEY:+-H "x-api-key: $CONTEXT7_API_KEY"} "https://context7.com/api/v2/context?libraryId=LIBRARY_ID&query=TOPIC&type=txt"
Summarize the relevant documentation. Include code examples where available.
Tips
- Works without an API key (rate-limited). Set
CONTEXT7_API_KEYfor higher limits - Be specific with
queryto improve relevance - URL-encode query parameters containing spaces (use
+or%20) - If the first result isn't right, check other results from the search