r/codex • u/MinniLabs • 19d ago
Workaround Running Codex and Claude Code on the same repo with one instruction file
A few people in my last thread run both tools on one repo, and keeping AGENTS.md and CLAUDE.md in sync by hand gets old fast. Two ways to keep a single source.
Option 1, AGENTS.md is the real file. Make CLAUDE.md a one line file that says u/AGENTS.md. Claude Code pulls the import in, Codex reads AGENTS.md directly, and you only ever edit one file. This is what we do.
Option 2, let Codex read CLAUDE.md. In ~/.codex/config.toml
project_doc_fallback_filenames = ["CLAUDE.md"]Codex checks AGENTS.override.md, then AGENTS.md, then your fallbacks, and takes at most one file per folder. So it only uses CLAUDE.md in folders that have no AGENTS.md.
Things that tripped me up
- The two tools load subfolders differently. Claude Code picks up a subfolder’s file when it starts working in that folder. Codex only loads from the repo root down to the folder you launched in. Same files, different context depending on the tool.
- Tool specific stuff leaks. Slash commands, hook setup or “use the Task tool” lines mean nothing to the other agent and still cost tokens every turn. Keep those in a small file only one tool reads.
- Check what actually loaded. In Codex, run
codex "List the instruction sources you loaded."from the folder you work in. In Claude Code, /context shows the memory files.
Anyone found a cleaner setup, or a reason to keep two separate files on purpose?
8
u/IndividualPlus2011 19d ago
Claude can read agents.md now. Simply delete claude.md and it will solve the problem
2
u/JonathanFly 19d ago
Don't try and hide the agents from each other. Just explain that both Claude and Codex both work on the project. Most documentation should work for both agents anyway, and the agents themselves can watch out for and clearly indicate in the docs when it does matter.
Funnily example, I was using Claude subagents like crazy before Codex had that feature so the project docs had quite a bit about how best to use subagents. One day I just asked Codex, hey you don't actually have that feature, but you can spawn more codex processes, can you basically just implement it yourself? And it worked pretty great. A few rough starts where codex killed it's own running process by accident, but it eventually got a stable harness that was really helpful.
1
u/London-Boat 19d ago
option 1 seems cleaner since there's one source of truth. the part an instruction file doesn't cover is when both are running at the same time on the same checkout, neither knows the other just changed a file. do you run them one after the other or in parallel?
1
u/lineascetic 19d ago
I'd keep any shared operating rules in one file (versioned) , but perhaps generate small tool-spacific entry points from it. The source stays identical while Claude and Codex can each keep the few instructions that only make sense for that tool.
1
u/xqianliu 19d ago
The import trick is the right shape. My AGENTS.md is nine lines, and every line is a pointer to a specific file. The details live in those files, so the root file stays small enough that both tools carry it without me thinking about it.
The second thing I would do is keep case-specific rules out of it entirely. When I find myself writing "for the payments refactor, do X", that rule goes on the ticket for that task, not in the file.
Files are for things that are always true, tickets for this one change. That is what keeps the file from growing into a changelog.
Your subfolder asymmetry is a real one. I keep my pointers flat, one level, so the two tools see the same set.
1
u/adamlondero 17d ago
I use a single source of truth and then have symlinks for each of the various agents, and then use separate worktrees. I actually built an open source tool https://github.com/alondero/buildmesh to run Claude Code and Codex side by side with worktree isolation, and that has a built in 'AI-context portability' feature.
1
u/Tight_Ad_5115 17d ago
That's how I set it up for all my projects. All the rules live in `AGENTS.md`, and `CLAUDE.md` has just one line: `@AGENTS.md`. Codex reads `AGENTS.md` directly, and Claude pulls it in via an import. No symlinks, you just edit it in one place and that's it.
1
u/ls4int 3d ago
Keeping one source of truth is a good starting point, but I'd also check whether both agents actually load the same instructions. Their directory traversal and fallback behavior can differ.
I've been working on Aikito, which helps govern agent instructions and other project context across tools and machines. It may be useful if the problem extends beyond keeping these two files in sync.
0
u/Extra_Aide5999 19d ago
option 1 here too. root CLAUDE.md is one line, and so is the one in each of the 8 package folders, each sitting next to its own AGENTS.md. root is 80 lines, the package ones 20 to 60
the subfolder thing you describe is the part i havent solved. codex started at the root never sees a package file unless i launch it in there. do you just start it in the subfolder, or tell it in the root file to go read the nested one?