What is the purpose of context7.md in a repository?
What is the use or the need for a repo to add a context7.md to his repo? When context7 starts rescoring/reanalyzing it looks for it.
Based on my exploration of the codebase, I can now provide you with a comprehensive answer:
##What is context7.md and Why Repos Need It
There are actually two separate things here:
###1. context7.md (or context7.mdc) - Configuration Rules for AI Agents
This is a rule file installed in your local coding agent** (Claude, Cursor, etc.) when you run npx ctx7 setup. It's not something you add to your repository.
Purpose:
- Contains instructions that guide your AI coding assistant (Claude Code, Cursor, etc.) on when and how to use Context7
- Tells the AI agent to fetch current documentation for library-related questions instead of relying on outdated training data
- Different agents get different files:
- Claude Code:
context7.mdstored in.claude/rules/ - Cursor:
context7.mdcstored in.cursor/rules/ - OpenCode/Codex: Added to
AGENTS.mdandGEMINI.md
- Claude Code:
Example rule content:
Use Context7 MCP to fetch current documentation whenever the user asks about a library,
framework, SDK, API, CLI tool, or cloud service -- even well-known ones like React,
Next.js, Prisma, Express, Tailwind, Django, or Spring Boot...
###2. context7.json - Configuration for Library Owners
This is what library owners/maintainers add to their repository's root.
Purpose:
- Tells Context7's indexing system how to parse your library's documentation
- Controls which folders/files to include or exclude
- Allows library owners to claim ownership and manage settings
- Works similarly to
robots.txt
When Context7 starts analyzing/rescoring:
When Context7 crawls or re-indexes a library, it looks for context7.json to understand:
- What documentation folders to include
- What to exclude
- Project metadata (title, description)
- Rules for agents to follow
- Previous versions to index
##Summary
| File | Purpose | Added By | Location |
|---|---|---|---|
context7.md / context7.mdc | Rules for AI agents | Context7 setup | Your local machine (.claude/rules/, .cursor/rules/) |
context7.json | Configuration for indexing | Library owners | Repository root |
So if you're a library maintainer looking to optimize how your docs appear in Context7, you add context7.json to your repo. If you're a user setting up Context7 in your IDE, the CLI creates the rule files automatically.
END OF POST