Grok Build edits, fixed before the next step
Grok Build reads Ultracite’s rules from AGENTS.md, alongside any CLAUDE.md, once you trust the folder. init --hooks grok adds a PostToolUse hook that runs ultracite fix on each file Grok edits, and Grok hands what’s left to the model in the same turn.
Grok Build by xAIChecked against October 2026
# 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
~/.grok/rules/*.mdYour rules for every project, then the~/.claude/and~/.cursor/equivalents while Claude and Cursor compatibility are on. - 2
AGENTS.mdUltraciteEvery folder from the repo root down to the working directory, in that order. Needs folder trust. - 3
CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE.mdLoaded alongsideAGENTS.mdin the same folder, not instead of it. - 4
.grok/rules/*.mdScanned at each level too, along with.claude/rules/and.cursor/rules/. - 5
Folders it visits laterWhen Grok reads or edits files outside that chain, it notes the instruction files there and reads them when they apply.
How Grok Build reads the rules
Grok Build loads every recognized instructions file from the repo root down to the working directory, so AGENTS.md and CLAUDE.md in the same folder both count. Deeper files come later in its context and win when instructions conflict.
- File names
AGENTS.md,Agents.md,AGENT.md,CLAUDE.md,Claude.mdandCLAUDE.local.md. Every match in a folder loads.- Precedence
- Files load from the root down, so the one nearest the working directory wins a conflict.
- Size
- No cap and no truncation: each file loads in full.
- Gitignore
- Ignored files are skipped, which makes a gitignored
CLAUDE.local.mda good place for personal notes. - Trust
- Project rules load at startup only in a trusted folder:
/hooks-trust,--trustor the trust prompt. - Check it
grok inspectlists each rules file Grok found, with its path and approximate token count.
A trusted hook after every file edit
init --hooks grok writes .grok/hooks/ultracite.json in Claude Code’s hook format. Grok maps the Write|Edit matcher onto its own file tools, and when the hook exits with code 2, Grok gives the model its stderr along with the tool result. The allow rule below lets Grok run npx ultracite commands of its own without a prompt.
{
"hooks": {
"PostToolUse": [
{
"hooks": [
{
"command": "npx ultracite fix --hook",
"timeout": 30,
"type": "command"
}
],
"matcher": "Write|Edit"
}
]
}
}[permission]
allow = ["Bash(npx ultracite *)"]- 01Grok edits a file, for example with
search_replace, which theWrite|Editmatcher covers. - 02In a trusted folder, Grok sends the event to the hook as JSON on stdin, and the hook runs
ultracite fixon that file. - 03If nothing is left, the hook exits 0 and Grok carries on.
- 04If problems remain, the hook prints them to stderr and exits 2, and the model reads them with the tool result before its next step.
Worth knowing about Grok Build
One trust grant covers rules and hooks
Grok skips a project’s hooks, startup instructions, skills and
.grok/config.tomlpermission rules until you trust the folder./hooks-trustor--trustgrants them together and records it in~/.grok/trusted_folders.toml; headless runs need--trustor an earlier grant.Claude Code and Cursor setups carry over
Besides its own files, Grok reads
.claude/rules/and.cursor/rules/, hooks from.claude/settings.jsonand.cursor/hooks.json, and permission rules from.claude/settings.json. Compatibility with each vendor is on by default and can be turned off in~/.grok/config.toml.Headless runs with hard limits
grok -pruns one prompt and exits. For CI, Grok’s docs pair--always-approvewith--denyrules: a deny always wins, and hooks still run in always-approve mode.The Ultracite skill
Grok Build loads skills from
.grok/skills/,.claude/skills/and.cursor/skills/, and scans.agents/skills/at each level between the working directory and the repo root, so it finds the Ultracite skillinitinstalls there. Project skills load only in a trusted folder.
Grok Build questions, answered
- Does Grok Build read AGENTS.md?
- Yes. At startup it loads every
AGENTS.mdfrom the repo root down to the working directory, along with anyCLAUDE.mdin the same folders. Startup loading needs folder trust, so trust the project first. - Why isn’t the Ultracite hook running in Grok Build?
- Grok skips project hooks until you trust the folder. Run
/hooks-trustin the session or start Grok with--trust, then open/hooksto see the hook in the list. - Will Grok Build also run my Claude Code hook?
- Grok reads hooks from
.claude/settings.jsontoo, but a hook with the same event, command and matcher in several files runs once. The hooksinitwrites for Claude Code and Grok Build share all three, so a project with both runsultracite fixonce per edit. - What does exit code 2 mean for a Grok Build PostToolUse hook?
- The tool has already run, so nothing is blocked: Grok hands the hook’s full stderr to the model. That’s a change from earlier versions, where it was a recorded failure, and Grok’s docs warn that a checker using exit 2 for other reasons now reaches the model too.
- How do I check which rules Grok Build loaded?
- Run
grok inspect. It lists each instructions file Grok found, with its path and an approximate token count.
Keep going
- AgentCodexOpenAI’s coding agent for the terminal, IDEs, the ChatGPT desktop app and cloud tasks.
- AgentGitHub CopilotGitHub’s coding assistant: agent mode in editors, a CLI, and a cloud agent that opens pull requests.
- AgentDroidFactory’s coding agent CLI, run interactively or headless in CI.
- 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.