Skip to content
Ultracite
Esc
↑↓navigate↵open⌘Jpreview

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.

…
Ultracite’s rules
Where Codex looks for instructions
  1. 1~/.codex/AGENTS.mdYour instructions for every project. An AGENTS.override.md beside it replaces it.
  2. 2AGENTS.override.mdChecked first in each directory, from the project root down to where you started. When one exists, that directory’s AGENTS.md is skipped.
  3. 3AGENTS.mdUltraciteRead at the root, where init writes Ultracite’s rules, and in each directory on the way to your working directory.
  4. 4project_doc_fallback_filenamesOther names you list in ~/.codex/config.toml, tried after AGENTS.md in each directory.
  5. 5services/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, then AGENTS.md, then any fallback names. Empty files are skipped.
Global
~/.codex/AGENTS.md, or the same file in CODEX_HOME when 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 Rules section, from the root AGENTS.md and 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"
      }
    ]
  }
}
init --hooks codex
  1. 01Codex edits files with apply_patch, and the hook gets the patch in tool_input.command.
  2. 02The hook runs ultracite fix on just the files the patch adds, updates or moves. A patch that only deletes files fixes nothing.
  3. 03If nothing is left, it exits 0 and Codex carries on.
  4. 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 Rules sections in the root AGENTS.md and 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 where ultracite check belongs.

  • Hooks wait for your review

    Codex loads .codex/hooks.json only 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-running init changes the command, Codex asks again.

  • Headless runs start read-only

    codex exec runs in a read-only sandbox unless you pass --sandbox workspace-write. That’s the flag ultracite fix --codex passes, along with --skip-git-repo-check, so Codex can edit the files it’s handed in any project.

  • The Ultracite skill

    Codex scans .agents/skills in every directory from where you start it up to the repository root, plus ~/.agents/skills. That’s where init installs 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.md in the same directory or in ~/.codex: an override replaces AGENTS.md at 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 codex writes a PostToolUse hook to .codex/hooks.json that runs ultracite fix --hook after each apply_patch edit. Codex loads it once you trust the project and review the hook in /hooks. Hooks you haven’t reviewed don’t run, in codex exec either, 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 to codex 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 Auto preset. workspace-write lets Codex run commands in your working directory without asking, and ultracite needs no network once it’s installed. Commands that have to leave the sandbox prompt unless a prefix_rule allows them.

Ship less slop

One command sets up your linter, formatter, editor and agents. Works with Oxlint, Biome and ESLint.