Context7 CLI (c7
)
A simple and convenient command-line interface (CLI) for interacting with the Context7 API.
Quickly search for projects, get information about them, and query specific topics within a project's context, all directly from your terminal. Provides the c7
command.
⚠️ Important: All data provided by this tool comes directly from the official Context7 API (https://context7.com
). This tool is simply a convenient wrapper and does not generate or host any content itself.
Features
- Query: Ask questions or request information on specific topics within a project's documentation context.
- Search: Discover available projects indexed by Context7 based on keywords.
- Info: Get metadata about a specific project (like its source repository, last update time, etc.).
- Flexible Output: Get query results in plain text (
txt
, default) or structuredjson
. - Save Results: Easily save query output directly to a file (
llms_{project}.{format}
). - User-Friendly: Uses spinners for feedback during API calls and colored output for readability.
Installation
Prerequisites
- Node.js (Version 18+ recommended for native
fetch
, but should work with v16+ if needed) - npm (usually comes with Node.js) or Bun
Install
npm install -g context7
yarn i -g context7
bun i -g context7
Usage
The basic command structure is:
c7 [command] [arguments...] [options...]
Commands
1. Query (Default Command)
Fetches information about a specific topic within a project. This is the default command if no other command (search
, info
) is specified.
Syntax:
c7 <projectname> <query...> [options]
Arguments:
<projectname>
: The exact name of the project (e.g.,nextjs
,react
,uv
). Usec7 search <term>
to find valid names. (Required)<query...>
: The topic, question, or keywords to query within the project's context. (Required)
Options:
--type
,-t
: Specify the output format.txt
(Default)json
--save
,-s
: Save the output to a file namedllms_{projectname}.{format}
in the current directory instead of printing to the console. (Boolean flag)--tokens
,-k
: Specify the maximum number of tokens for the API response. (e.g.,--tokens 1000
). The API default is used if omitted. (Number)
Examples:
# Get info about data fetching in Next.js (default TXT output)
c7 nextjs data fetching strategies
# Get info about state management in React, output as JSON
c7 react state management -t json
# Search for info on installation in the 'uv' project and save to llms_uv.txt
c7 uv installation steps --save
# Query Node.js streams and save the result as llms_nodejs.json
c7 nodejs streams api -t json -s
# Query Next.js data fetching and use only 1000 tokens
c7 nextjs data fetching -k 1000
2. Search
Searches for available Context7 projects based on a keyword in their title. It filters out projects whose internal path contains a /
, as these are often duplicates or not directly queryable via this tool.
Syntax:
c7 search <term>
Arguments:
<term>
: The keyword to search for in project titles (e.g.,react
,python
,aws
). (Required)
Example:
c7 search next
# Output might look like:
# --- Search Results (Use "Project Name" for queries) ---
# - Next.js (Project Name: nextjs)
# -------------------------------------------------------
# Example query: c7 nextjs <your query>
3. Info
Displays metadata associated with a specific project.
Syntax:
c7 info <projectname>
Arguments:
<projectname>
: The exact project name (e.g.,nextjs
,react
). Use the name shown in parentheses from thesearch
command results. (Required)
Example:
c7 info react
# Output will show details like Title, Project Name, Docs Source, Last Update, etc.
Getting Help
You can always get help on commands and options:
c7 --help # General help for all commands
c7 query --help # Help specifically for the query command (same as default)
c7 search --help # Help for the search command
c7 info --help # Help for the info command
Development
- Clone the repository.
- Install dependencies (
npm install
orbun install
). - Link for local testing (
npm link
orbun link
). - Make your changes!