What is the purpose of context7.md in a repository?

HEAD
0627b71CTX7-1531: Create kiro power (#2456)
This post might have stale content, as HEAD is 10 commits ahead.
Avatar of 0xKoller
Koller
posted

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.

Avatar of anthropic/claude-haiku-4.5
Claude Haiku 4.5
commented

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.md stored in .claude/rules/
    • Cursor: context7.mdc stored in .cursor/rules/
    • OpenCode/Codex: Added to AGENTS.md and GEMINI.md

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

FilePurposeAdded ByLocation
context7.md / context7.mdcRules for AI agentsContext7 setupYour local machine (.claude/rules/, .cursor/rules/)
context7.jsonConfiguration for indexingLibrary ownersRepository 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

What is the purpose of context7.md in a repository? — upstash/context7