Features
AGENTS.md
This page covers the Terminal UI. For the Agents Window, see Rules in the Agents Window.
Project rules are Markdown files that Grok loads into context for every session in a directory tree. Put coding conventions, build and test commands, and architecture notes in an AGENTS.md at your repo root, and Grok follows them without being told each session.
Discovery
Grok loads rules in this order, with deeper files taking precedence on conflicts:
- Global rules in
~/.grok/ - Every directory from the repo root down to the working directory (or only the working directory outside a git repo)
Within each directory, Grok reads any of AGENTS.md, Agents.md, AGENT.md, CLAUDE.md, Claude.md, and CLAUDE.local.md, plus every *.md file in a .grok/rules/ directory. Files ignored by .gitignore are skipped, which keeps personal overrides like CLAUDE.local.md out of shared context.
.claude/rules/ and .cursor/rules/ are read for compatibility, with one limit worth knowing: Grok loads only plain *.md files sitting directly in those directories, and it does not load .mdc files at all. Cursor project rules are written as .mdc, so a rule set written for Cursor produces no rules here. To carry those rules over, copy them into .grok/rules/ as *.md, or move the content into an AGENTS.md. Every rule Grok does load from these directories is loaded in every session: frontmatter such as globs or alwaysApply is stripped rather than applied, and nested subdirectories are not searched.
A nested AGENTS.md scopes to its subtree, so a monorepo can carry different conventions per package:
Text
my-monorepo/
AGENTS.md # repo-wide rules
packages/
frontend/AGENTS.md # "Use React. Prefer CSS modules."
backend/AGENTS.md # "Use Express. Follow REST conventions."
Files are loaded in full, with no size cap; short, specific instructions are followed more reliably than long ones.
Session rules
To add rules for a single run without editing files, pass --rules (Grok appends the text to the system prompt), or --system-prompt-override to replace the system prompt entirely:
Bash
grok --rules "Always use TypeScript. Prefer functional components."
Verification
Bash
grok inspect
This lists each rules file Grok found, with its path and approximate token count.
Last updated: November 23, 2026