Codex gets lint feedback on every patch
Codex reads AGENTS.md from your project root down to the directory you start it in, so Ultracite’s rules are in its instructions from the first message. With init --hooks codex, a hook runs ultracite fix on every file Codex patches and hands back what’s left in the same turn, and ultracite fix --codex hands whatever’s left outside a session to codex exec.
Codex by OpenAIChecked against Codex 0.162.1
# Ultracite Code Standards
This project uses **Ultracite**, a zero-config preset that enforces strict code quality standards through automated formatting and linting.
## Quick Reference
- **Format code**: `npx ultracite fix`
- **Check for issues**: `npx ultracite check`
- **Diagnose setup**: `npx ultracite doctor`
Oxlint + Oxfmt (the underlying engine) provides robust linting and formatting. Most issues are automatically fixable.
…- 1
~/.codex/AGENTS.mdYour instructions for every project. AnAGENTS.override.mdbeside it replaces it. - 2
AGENTS.override.mdChecked first in each directory, from the project root down to where you started. When one exists, that directory’sAGENTS.mdis skipped. - 3
AGENTS.mdUltraciteRead at the root, whereinitwrites Ultracite’s rules, and in each directory on the way to your working directory. - 4
project_doc_fallback_filenamesOther names you list in~/.codex/config.toml, tried afterAGENTS.mdin each directory. - 5
services/api/AGENTS.mdCloser files are joined later, so they take precedence. Directories below your working directory aren’t read.
How Codex reads the rules
Codex builds one instruction chain per run: a global file from ~/.codex, then one file per directory from the project root down to where you started. An AGENTS.override.md beats AGENTS.md in the same directory, so a forgotten override can hide your rules.
- Size limit
- Codex stops adding files once the combined size reaches
project_doc_max_bytes, 32 KiB by default. Ultracite’s rules are about 5 KB. - One per directory
- At most one file per directory:
AGENTS.override.md, thenAGENTS.md, then any fallback names. Empty files are skipped. - Global
~/.codex/AGENTS.md, or the same file inCODEX_HOMEwhen you’ve set it.- When it loads
- Once per run. Restart Codex in the project to pick up an edited
AGENTS.md. - Check it
codex --ask-for-approval never "Summarize the current instructions."has Codex report what it loaded.- Review rules
- GitHub code review follows a
## Code Review Rulessection, from the rootAGENTS.mdand any nested one covering a changed file.
A hook on every apply_patch
init --hooks codex adds a PostToolUse hook to .codex/hooks.json, matched on apply_patch, the tool Codex edits files with. Once you’ve reviewed it, Codex runs it from the session’s working directory after every patch. When problems remain, the hook exits with code 2, and Codex hands them to the model in place of the patch’s own result.
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"command": "npx ultracite fix --hook",
"type": "command"
}
],
"matcher": "apply_patch"
}
]
}
}- 01Codex edits files with
apply_patch, and the hook gets the patch intool_input.command. - 02The hook runs
ultracite fixon just the files the patch adds, updates or moves. A patch that only deletes files fixes nothing. - 03If nothing is left, it exits 0 and Codex carries on.
- 04If problems remain, it prints them and exits 2. The edit stays applied, and the model reads the problems as the tool’s result and fixes them next.
Worth knowing about Codex
Code review reads AGENTS.md too
Codex code review on GitHub follows
## Code Review Rulessections in the rootAGENTS.mdand in any nested one that covers a changed file. OpenAI’s advice is to leave formatting and lint checks out of those rules and in CI, which is whereultracite checkbelongs.Hooks wait for your review
Codex loads
.codex/hooks.jsononly in a project you’ve trusted, and runs each hook only after you review it in/hooks. Trust is tied to the hook’s content, so when re-runninginitchanges the command, Codex asks again.Headless runs start read-only
codex execruns in a read-only sandbox unless you pass--sandbox workspace-write. That’s the flagultracite fix --codexpasses, along with--skip-git-repo-check, so Codex can edit the files it’s handed in any project.The Ultracite skill
Codex scans
.agents/skillsin every directory from where you start it up to the repository root, plus~/.agents/skills. That’s whereinitinstalls the Ultracite skill by default, so Codex finds it with no extra setup.
Codex questions, answered
- Does Codex read AGENTS.md?
- Yes, it’s Codex’s own instructions file. Codex reads
~/.codex/AGENTS.md, then one file per directory from the project root down to your working directory, and joins them so the closer files come later and take precedence. - Why is Codex ignoring my AGENTS.md?
- Look for an
AGENTS.override.mdin the same directory or in~/.codex: an override replacesAGENTS.mdat its level. Codex also skips empty files and builds the chain once per run, so restart it after editing. - Does Codex support hooks?
- Yes.
init --hooks codexwrites aPostToolUsehook to.codex/hooks.jsonthat runsultracite fix --hookafter eachapply_patchedit. Codex loads it once you trust the project and review the hook in/hooks. Hooks you haven’t reviewed don’t run, incodex execeither, unless you pass--dangerously-bypass-hook-trust. - Can Codex fix what Ultracite can’t autofix?
- Run
npx ultracite fix --codex. After the safe fixes, it sends each file with problems left tocodex exec --sandbox workspace-write, up to three tries per file, and lints the file again so the linter decides what counts as fixed. - Do I have to approve every ultracite command in Codex?
- Not in the
Autopreset.workspace-writelets Codex run commands in your working directory without asking, andultraciteneeds no network once it’s installed. Commands that have to leave the sandbox prompt unless aprefix_ruleallows them.
Keep going
- AgentClaude CodeAnthropic’s agentic coding tool that edits files and runs commands from your terminal, IDE or desktop.
- AgentOpenCodeOpen-source coding agent for the terminal, desktop and IDEs, with 75+ model providers.
- AgentCursor CLIThe Cursor agent in your terminal, interactive or headless.
- DocsAgent rulesWhat
initwrites for every agent, and how to keep it current.
Ship less slop
One command sets up your linter, formatter, editor and agents. Works with Oxlint, Biome and ESLint.