Make Grok Build follow your AGENTS.md project rules
Make Grok Build follow your AGENTS.md project rules
Grok Build loads Markdown project rules into every session in a directory tree. Put conventions, build and test commands, and architecture notes in those files so you do not restate them each turn.
Where the files go
Grok walks rules in this order. Deeper files win on conflicts:
- Global rules under
~/.grok/ - Every directory from the repo root down to your working directory (or only the working directory outside a git repo)
In each directory it reads any of AGENTS.md, Agents.md, AGENT.md, CLAUDE.md, Claude.md, and CLAUDE.local.md, plus every *.md file in .grok/rules/ (.claude/rules/ and .cursor/rules/ are read for compatibility).
Files ignored by .gitignore are skipped. That keeps personal overrides such as CLAUDE.local.md out of shared context when they are gitignored.
A nested AGENTS.md scopes to its subtree, so a monorepo can carry different rules per package:
my-monorepo/
AGENTS.md
packages/
frontend/AGENTS.md
backend/AGENTS.md
Files load in full with no size cap. Short, specific instructions are followed more reliably than long ones.
One-off rules for a single run
Append text for one invocation:
grok --rules "Always use TypeScript. Prefer functional components."
Replace the system prompt entirely with --system-prompt-override when you need a hard reset for that run.
Verify what loaded
From the project directory:
grok inspect
grok inspect lists each rules file Grok found, with path and approximate token count, plus config sources, skills, plugins, hooks, and MCP servers. If your file is missing from that list, check the name, the cwd, and whether .gitignore excluded it.
Pitfalls
- Start
grokfrom the package you care about, or the nestedAGENTS.mdfor that package may never enter the walk. - Consumer Projects on grok.com are a different product. This page is Grok Build / CLI only. For grok.com Projects, see Create a Grok Project and keep files in one workspace.
- Cross-session memory (
[memory] enabled,/remember,/flush) is separate from project rules. Rules load every session in the tree; memory is opt-in and off by default.