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

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.

…
Ultracite’s rules
Where Grok Build looks for instructions
  1. 1~/.grok/rules/*.mdYour rules for every project, then the ~/.claude/ and ~/.cursor/ equivalents while Claude and Cursor compatibility are on.
  2. 2AGENTS.mdUltraciteEvery folder from the repo root down to the working directory, in that order. Needs folder trust.
  3. 3CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE.mdLoaded alongside AGENTS.md in the same folder, not instead of it.
  4. 4.grok/rules/*.mdScanned at each level too, along with .claude/rules/ and .cursor/rules/.
  5. 5Folders 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.md and CLAUDE.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.md a good place for personal notes.
Trust
Project rules load at startup only in a trusted folder: /hooks-trust, --trust or the trust prompt.
Check it
grok inspect lists 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"
      }
    ]
  }
}
init --hooks grok
[permission]
allow = ["Bash(npx ultracite *)"]
  1. 01Grok edits a file, for example with search_replace, which the Write|Edit matcher covers.
  2. 02In a trusted folder, Grok sends the event to the hook as JSON on stdin, and the hook runs ultracite fix on that file.
  3. 03If nothing is left, the hook exits 0 and Grok carries on.
  4. 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.toml permission rules until you trust the folder. /hooks-trust or --trust grants them together and records it in ~/.grok/trusted_folders.toml; headless runs need --trust or 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.json and .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 -p runs one prompt and exits. For CI, Grok’s docs pair --always-approve with --deny rules: 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 skill init installs 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.md from the repo root down to the working directory, along with any CLAUDE.md in 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-trust in the session or start Grok with --trust, then open /hooks to see the hook in the list.
Will Grok Build also run my Claude Code hook?
Grok reads hooks from .claude/settings.json too, but a hook with the same event, command and matcher in several files runs once. The hooks init writes for Claude Code and Grok Build share all three, so a project with both runs ultracite fix once 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.

Ship less slop

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