/t · guide · grok build

A config analyzer for .grokrules (and .grok/GROK.md).

M
Matthew Diakonov
5 min read

When xAI shipped Grok Build (May 14, 2026), the team deliberately matched Anthropic's skill and instruction-file format. The official xAI docs say so: Grok also reads CLAUDE.md, AGENTS.md, and the .claude/rules/ family alongside its own .grok/GROK.md. That's why ccmd doesn't need a separate "Grok mode": the patterns that rot a CLAUDE.md (long compound rules, vague qualifiers, ISO dates near the top, prohibitions without a reason) are exactly the patterns that rot a .grokrules.

The rest of this page walks through what the analyzer does to a real paste, with the actual file ccmd flags as a worked example. The whole thing takes about 200 ms in your browser.

1. The input

Here is a representative .grokrules from a real-feeling Next.js payments project. It looks fine on first read. It scores 4 of 12 on the rubric and ships 7 findings.

.grokrules

2. How ccmd decides this is a .grokrules

The detector lives at src/lib/analyzer.ts:45. It inspects the first 300 characters of the pasted text and picks .grokrules when it sees either the literal string .grokrules or a markdown heading like # grok. Otherwise it falls through to CLAUDE.md. The rubric and heuristics that run next are identical, so a wrong label changes only the badge at the top of the report.

src/lib/analyzer.ts

3. What the rubric actually checks

Four passes run against the file, in order:

1

Per-line scan (bloat, vague, aspirational, cache-bust)

Each non-blank line is measured. Lines over 28 words are flagged as bloat. Lines containing 'appropriately', 'carefully', 'cleanly', 'good', 'best' (the 11 banned vague terms) get a 'vague' finding. Unbounded 'always' or 'never' without an 'unless' or 'except' is flagged aspirational. ISO dates in the first 20 lines are flagged as cache-busters that invalidate prompt caching every session.

2

Duplicate detection

Lowercased non-trivial lines are hashed; the second occurrence gets a 'duplicate' finding pointing back at the line number of the first. Cuts the kind of 'I forgot I already said that' redundancy that happens when teams concatenate rules from multiple authors.

3

Missing-why scan

Any line starting with DO NOT / NEVER / don't gets a four-line lookahead; if the next four lines don't contain 'because', 'why', 'reason', 'past', 'got burned', 'incident', or 'happened', the prohibition is flagged. Agents follow unannotated prohibitions until they hit an edge case, then guess. The fix is one Why: line citing the past incident.

4

Karpathy 12-rule scorecard

The 12 community-extended rules (plan-before-coding, simplicity, surgical changes, goal-driven execution, ask-when-unclear, no-orthogonal-damage, tests as truth, concise output, stack awareness, tool preference, failure-mode coverage, self-improvement loop) each have a regex test. The pass count goes in the report header; missing rules show up as a 'consider adding' list at the bottom of the rendered analyzer.

4. The output for the sample above

Same file, run through the analyzer. The actual UI renders a richer panel; the shape of the data is below.

ccmd · report

Read top to bottom: L3 and L4both flag the same line for different reasons (an unbounded "Always" and a vague "appropriately"); fix one and the other often goes away. The two missing-why findings on L8 and L9 are the cheapest fix on the page: one line each. The bloat finding on L13 is a 34-word stack paragraph that wants to be three short rules. The cache-bust on L17 alone is worth more than the rest combined: a timestamp that close to the top of a file Grok Build (or Claude Code) caches every session is paying full input-token cost every turn for no behavior change.

every turn

every API call sends the full context including CLAUDE.md, so a sloppy 8k file silently taxes every turn

caymanjim, Hacker News thread 47581701

5. What the other tools in this corner do (and don't)

Featuregenerators & cost CLIsccmd
Scores an existing .grokrulesno — template onlyyes — line by line
Same rubric across CLAUDE.md / AGENTS.md / .cursorrules / .grokrulessingle-formatpolyglot from day one
Reports per-turn token costpost-hoc only (ccusage style)live, before you ship the file
Flags missing-why prohibitionsnot implementedDO NOT / NEVER with 4-line lookahead
Runs in browser, no uploadvariesyes — all logic in src/lib/analyzer.ts
Karpathy 12-rule scorecardnot implementeddefault rubric

6. Fixes that move the score

For the sample file above, the four changes that get the rubric from 4 / 12 to 9 / 12 and cut roughly 60 tokens per turn:

  • Move the date out of line 17. Compute "today" at runtime from a hook or strip the line entirely. Saves the cache hit and removes the single highest-severity finding.
  • Add a Why: under each Never. "Never use any" becomes "Never use any. Why: silent runtime errors in checkout flow on 2026-03, took 4 hours to trace." One line each, two findings gone.
  • Split the 34-word stack paragraph. Three short rules: framework, payments boundary, migration rule. The second half of the original line was getting ignored anyway.
  • Drop "appropriately" and "carefully". Replace with concrete tests. "Handle edge cases appropriately" becomes "Cover the four edge cases in cases.test.ts."

Add a Tests-as-Truth line (rule 7), a stack name (rule 9, already half-present), and one self-improvement instruction (rule 12: "when you hit a behavior you don't expect, write the rule to this file before fixing"), and the file scores 9 / 12. The token saving is real but secondary; the larger win is that Grok Build (and Claude Code, and Codex, and Cursor, all reading the same file) stop ignoring half the rules.

Want a second pair of eyes on your .grokrules?

15 minutes, walk through your file, leave with a shortlist of cuts. Free.

Frequently asked questions

Is .grokrules the official Grok Build file name?

Not exactly. xAI's own docs (docs.x.ai/build) describe project-level instructions as `.grok/GROK.md`, and Grok Build also reads `CLAUDE.md` and `AGENTS.md` for compatibility with Claude Code and Codex. `.grokrules` is the community-fork name (modelled on `.cursorrules`) that some teams use as a shorter, repo-root file. ccmd accepts either, because its detector keys off content, not filename.

How does ccmd know my pasted file is .grokrules and not CLAUDE.md?

The analyzer checks the first 300 characters for the literal string `.grokrules` or a `# grok` heading; if either is present it labels the file as .grokrules. Otherwise it falls back to CLAUDE.md. The rubric and heuristics are identical either way, so a misdetection doesn't change the findings, only the label at the top of the report.

Is the rubric different for Grok Build vs Claude Code?

No. xAI shipped Grok Build with deliberate compatibility for the Anthropic skill and instruction format, so a rule that's bad in a CLAUDE.md is bad in a .grokrules. The 12 checks (Karpathy's 12 rules: plan-before-coding, simplicity, surgical changes, goal-driven execution, ask-when-unclear, no-orthogonal-damage, tests as truth, concise output, stack awareness, tool preference, failure-mode coverage, self-improvement loop) all apply.

What counts as bloat in a .grokrules?

Any single rule line over 28 words. The threshold is set in src/lib/analyzer.ts:150. Long compound rules with multiple clauses get treated as one signal by the model and frequently the second half gets ignored; ccmd flags them and suggests splitting into 2-3 shorter directives.

Why does ccmd flag the date at the top of my .grokrules?

An ISO date or 'today is...' line in the first 20 lines is a 'cache_bust' finding. Anthropic and xAI both use prompt caching to amortize the cost of long instruction files. A timestamp that changes every session invalidates the cache, so every turn pays full re-read cost for the entire instruction file. Move the date to the bottom or compute it at runtime.

Does ccmd upload my .grokrules anywhere?

No. The analyzer runs entirely in your browser. There's no POST, no SSR call. You can open DevTools and watch the network tab while you paste. The same code path is used for CLAUDE.md and AGENTS.md.

Can I run this in CI on my .grokrules?

The hosted analyzer is browser-only. A paid tier ships continuous monitoring with PR diff comments and a weekly drift email; if you want a self-hosted CI check today, the rubric in src/lib/analyzer.ts is short enough to port. Book a call below if you want help wiring it.

Next: the 12-rule rubric in full, or paste your file on the analyzer.

How did this page land for you?

React to reveal totals

Comments ()

Leave a comment to see what others are saying.

Public and anonymous. No signup.