Convert CLAUDE.md to AGENTS.md (and back)
Claude Code and most other coding agents can now share one file, but the rules for which file wins are easy to get wrong. Per the Claude Code docs, when a repository has both an AGENTS.md and a CLAUDE.md, Claude Code reads only CLAUDE.md, unless CLAUDE.md imports AGENTS.md.
The setup that avoids drift is a single AGENTS.md with your shared rules and a CLAUDE.md that contains @AGENTS.md plus anything Claude-specific. The converter produces exactly that when bridge files is on.
Input
Everything runs in your browser. Files are never uploaded.
Output
Converted files appear here. Conversion report
How each rule type converts
| In CLAUDE.md (Claude Code) | Becomes | Result |
|---|---|---|
Root CLAUDE.md | AGENTS.md | Kept |
Nested dir/CLAUDE.md | Nested dir/AGENTS.md | Kept |
.claude/rules/*.md with paths | Section with an “applies to files matching …” note | Adapted |
.claude/rules/*.md without paths | Section in AGENTS.md | Kept |
@path imports | Kept as text and flagged; imported files are not inlined | Adapted |
Steps
- Drop CLAUDE.md, any nested CLAUDE.md files and your
.claude/rulesfolder into the converter. - Leave bridge files on to get a CLAUDE.md and GEMINI.md that import AGENTS.md.
- Check the report for flagged
@imports. Either add the imported files as sources too or keep the import in CLAUDE.md. - To go the other way, set From to AGENTS.md and To to Claude Code.
Worked example
This output is generated by the same converter you use above, from an illustrative rule set.
Input
CLAUDE.md
# Acme monorepo
@docs/architecture.md
- Use pnpm workspaces. Run `pnpm -r test` before committing.
- Keep pull requests under 400 changed lines. .claude/rules/api.md
---
paths:
- "apps/api/**/*.ts"
---
- Every route handler validates input with zod.
- Log with the shared logger, never console.log. apps/web/CLAUDE.md
- This app uses Astro. Pages live in src/pages. Output
AGENTS.md
## Acme monorepo
@docs/architecture.md
- Use pnpm workspaces. Run `pnpm -r test` before committing.
- Keep pull requests under 400 changed lines.
## Api
_Applies when working on files matching `apps/api/**/*.ts`._
- Every route handler validates input with zod.
- Log with the shared logger, never console.log. apps/web/AGENTS.md
- This app uses Astro. Pages live in src/pages. CLAUDE.md
@AGENTS.md GEMINI.md
@AGENTS.md Report for this example
- info Acme monorepo: Contains @ file references (@docs/architecture.md). CLAUDE.md and GEMINI.md import a referenced file's content; Cursor's agent reads it on demand; other tools see plain text. Referenced files are not copied, so check they exist in the target setup.
- kept Acme monorepo: Merged into AGENTS.md (always on).
- adapted Api: AGENTS.md has no way to mark a rule as file-scoped, so it was inlined with a note: Applies when working on files matching `apps/api/**/*.ts`.
- kept apps/web instructions: Written to apps/web/AGENTS.md (nested files apply to their directory).
- info Bridge files: CLAUDE.md and GEMINI.md only import AGENTS.md, so there is one file to maintain. Recent Claude Code versions can also read AGENTS.md directly when no CLAUDE.md exists.
Things to watch for
- Path-scoped
.claude/ruleslose their scoping in AGENTS.md. If that matters, keep those files in.claude/rules; they load alongside an imported AGENTS.md. CLAUDE.local.mdis for personal, uncommitted preferences. The converter flags it; you probably don't want it in a shared AGENTS.md.- Reading AGENTS.md directly needs Claude Code v2.1.277 or later, and some sessions can't read it. The
@AGENTS.mdimport works in both cases, so the bridge file is the safer default. - Imports don't save context: the docs note imported files load together with the CLAUDE.md that imports them.
FAQ
Does Claude Code read AGENTS.md?
Yes, recent versions read AGENTS.md when there is no CLAUDE.md in the working directory or above it. With a CLAUDE.md present, add @AGENTS.md to it to load both.
Should I symlink CLAUDE.md to AGENTS.md instead?
A symlink also works for many tools, but an import line is easier to review in pull requests and lets CLAUDE.md add Claude-specific instructions below it.
Will GEMINI.md work the same way?
Gemini CLI supports @file imports in GEMINI.md, and it can also be configured with context.fileName to read AGENTS.md directly.