home / skills / openclaw / skills / context7-api

context7-api skill

/skills/am-will/context7-api

This skill fetches up-to-date library documentation via Context7 API to ensure accurate APIs, patterns, and best practices.

npx playbooks add skill openclaw/skills --skill context7-api

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

Files (3)
SKILL.md
1.7 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
  Always prefer this over guessing library APIs or using outdated knowledge.
---

# Context7 Documentation Fetcher

Retrieve current library documentation via Context7 API.

## Workflow

### 1. Search for the library

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

Example:
```bash
python3 ~/.claude/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 ~/.claude/skills/context7/scripts/context7.py context "<library-id>" "<query>"
```

Example:
```bash
python3 ~/.claude/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 from the Context7 API to provide current, authoritative information about third-party packages. It is designed to be used proactively whenever working with external libraries so answers reflect the latest APIs, patterns, and best practices rather than outdated training data. The skill is implemented as a small CLI that searches libraries and retrieves contextual documentation snippets for specific queries.

How this skill works

You first search for a library to obtain its Context7 identifier, then request documentation context for a precise query using that identifier. The CLI returns searchable metadata and formatted context (plain text or markdown) and supports limiting output size via token limits. Use the search step to locate the exact repo or package, then the context step to fetch targeted docs, examples, or API details.

When to use it

  • Before implementing features that depend on any external library (React, Next.js, Supabase, etc.).
  • When a user asks about library APIs, signature changes, or recommended patterns.
  • To debug behavior that might be version- or implementation-specific.
  • When you need documentation published after your model training cutoff.
  • To confirm best practices and migration paths for updated libraries.

Best practices

  • Always run a search for the exact library name or repository to get the correct identifier before fetching context.
  • Frame queries narrowly (specific function, hook, or pattern) to receive concise, relevant documentation snippets.
  • Prefer fetched docs over in-model guesses for API signatures and behavior.
  • Use token limits to keep responses focused when you only need a short excerpt.
  • Choose the output format (txt or md) that best fits the consumer workflow or downstream display.

Example use cases

  • Search and retrieve the current Next.js app router middleware docs when implementing route-level middleware.
  • Fetch React hook cleanup semantics for useEffect to ensure correct lifecycle handling.
  • Pull Supabase authentication and row-level security guidelines when integrating auth and database rules.
  • Confirm breaking changes or new parameters for a library before upgrading dependencies.
  • Provide precise code examples from upstream docs when answering developer questions in chat or code reviews.

FAQ

What are the main steps to use this skill?

Search for the library to get its identifier, then request context for a specific query using that identifier. Optionally set output format and token limits.

How do I keep responses short?

Use narrow queries and the token limit option to return only the most relevant excerpt.

When should I prefer this over built-in knowledge?

Always prefer this skill for library APIs, patterns, or behaviors that may have changed since your model's training cutoff or for any version-specific questions.