I work on a shared project with many other developers in my organization. Its shared instructions added up to roughly 13,200 tokens, including workflows for Claude Code. My personal Codex harness uses about 670 tokens, a 95% reduction in instruction text, without changing everyone else’s setup.
The shared guide could be trimmed too, but that’s for later. My personal harness has 2 parts: short instruction overrides and automatic worktree setup.
Override the project instructions
Codex loads AGENTS.override.md instead of AGENTS.md in the same directory. Global and parent-directory instructions still apply; an override doesn’t replace the whole chain. See the discovery rules.
I use a root override for shared preferences and ios/AGENTS.override.md for platform essentials. They cover focused checks, existing architecture, precise money handling, simulator sessions, and generated files.
The shared guides stay intact. I read them when a task needs more detail, rather than loading the whole manual for a small change.
Replacing a guide means carrying its essential safeguards into my version. Fewer words, but still enough to prevent expensive mistakes.
I keep these preferences local with .git/info/exclude:
/AGENTS.override.md
/ios/AGENTS.override.md
This keeps them out of commits without changing the team’s .gitignore. Codex automatically copies ignored AGENTS.override.md files into its local managed worktrees, so new tasks get the same instructions.
Automate environment setup
A fresh worktree can be missing ignored configuration and Git LFS binaries. Our Claude Code instructions told the agent to run a shell script that copied local configuration and pulled Git LFS binaries. I moved those steps into Codex’s automatic worktree setup.
For file copying, my repository-root .worktreeinclude contains a path like this:
ios/Developer.xcconfig
Codex copies that ignored file into new local managed worktrees. It skips source symlinks and existing destination files. A plain git worktree add doesn’t run this copier.
For executable setup, I configured a local environment. My saved project opens ios/, so I placed this file at .codex/environments/environment.toml within that directory:
version = 1
name = "iOS"
[setup]
script = "git lfs pull --include='ios/**'"
Use your own environment name and put the configuration under the project directory you open in Codex. I also exclude this personal file through .git/info/exclude:
/ios/.codex/environments/environment.toml
When selected, the environment runs its setup during worktree creation, before the agent starts. git lfs pull reuses cached objects, fetches missing ones, and checks out the versions needed by that branch. Linked worktrees share the LFS cache, though each still needs its own working files.
One catch: creating the configuration didn’t select it.
Our first agent-created sidebar tasks got the overrides and developer configuration, but the creation log showed hasLocalEnvironment=false. All LFS files were still pointers.
I created a task manually in Codex desktop, chose Worktree, and selected my environment before submitting the first prompt. The app saved that choice for the project.
The next agent-created task under the same project inherited it. The logs showed hasLocalEnvironment=true, the setup command finished with code=0, and all LFS files matched their expected hashes.
That’s what worked in my installed app: select once, then verify a fresh agent-created task.
My personal harness uses roughly 95% less instruction text than the shared guides, based on a tokenizer estimate. That leaves more room for code and conversation. A larger Codex context window helps, but I want that space for the actual task.