Learning resourcesReviewed · xAI

Grok project rules: AGENTS.md guide

This guide shows developers how to configure reusable instructions for Grok, with deeper rule files able to override shared project conventions. It covers instruction-file discovery, session-specific options and the grok inspect command.

Researched 23 Nov 2026

In short.

This guide teaches developers and repository maintainers how to configure Grok project rules, but provides no measured evidence of how reliably those rules are followed. It documents persistent Markdown instructions, directory-based precedence, compatibility with several instruction-file conventions and temporary command-line rules. The guidance is actionable for configuring instruction loading; installation, pricing, version compatibility and actual runtime behavior remain unassessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage includes the complete AGENTS.md documentation page at [https://docs.x.ai/build/features/project-rules.md], including discovery, session rules and inspection. Linked pages are excluded. No license or related notice appears in the supplied page. Installation, pricing, release compatibility and runtime behavior are not established; no commands were executed.

The overview

Identity

The resource is xAI's AGENTS.md feature guide for Grok at [https://docs.x.ai/build/features/project-rules.md]. It explains how Markdown files supply recurring instructions to coding sessions, including conventions, build and test commands, and architecture notes.

Assessment

The guide is useful for understanding which instruction files Grok should load and how to inspect their discovery. It provides concrete paths, supported filenames, precedence rules and commands.

Its verification command reports discovered files and approximate token counts. That establishes what the command is intended to show; it does not demonstrate whether Grok obeys the instructions during coding.

Users

The guide suits developers who repeatedly give Grok the same project guidance and maintainers who want shared conventions stored alongside their code. Monorepo teams can use nested files for package-specific instructions.

Beginners get a repository-root starting point. Experienced developers get details about discovery boundaries, ignored files, compatible rule directories and system-prompt options.

Capabilities

Documented capabilities include persistent project instructions, global instructions under ~/.grok/, nested rules scoped to directory subtrees, temporary instructions through --rules, and complete system-prompt replacement through --system-prompt-override.

Grok also recognizes several existing instruction-file names and rule directories. The grok inspect command lists discovered rule files with their paths and approximate token counts.

Using it

Requirements

Following the examples requires access to the grok command and the ability to create Markdown files in the relevant locations. Installation steps, supported operating systems, account requirements and minimum Grok versions are not specified.

Repository discovery uses the repository root and working directory. Outside a Git repository, the documented local search covers only the working directory, alongside global rules.

Mechanism

Grok loads global rules first, then rules in each directory from the repository root down to the working directory. Deeper files take precedence when instructions conflict. A nested AGENTS.md applies to its subtree.

Recognized filenames are AGENTS.md, Agents.md, AGENT.md, CLAUDE.md, Claude.md and CLAUDE.local.md. Grok also reads every Markdown file in .grok/rules/, with .claude/rules/ and .cursor/rules/ supported for compatibility. Files ignored by .gitignore are skipped.

Files are loaded in full without a documented per-file size cap. The page does not specify conflict ordering among files in the same directory or precedence between file instructions and command-line rules.

Setup

Create an AGENTS.md at the repository root with concise coding conventions, relevant build and test commands, and architecture guidance. Add nested AGENTS.md files where subdirectories need different instructions.

Check whether intended rule files are excluded by .gitignore, then use grok inspect to review discovery from the intended working directory. The page supplies no example inspection output.

Example

The monorepo example places shared instructions in a root AGENTS.md, React and CSS-module preferences in packages/frontend/AGENTS.md, and Express and REST conventions in packages/backend/AGENTS.md.

For one session, the documented command grok --rules "Always use TypeScript. Prefer functional components." supplies temporary guidance without editing a rules file. These are documentation examples; their behavior was not tested.

Assessment & evidence

Limitations

The guide states that short, specific instructions are followed more reliably than long ones, but supplies no measurements or failure examples. File discovery does not establish instruction compliance.

Ignored files are skipped, and deeper instructions can override repository-wide guidance. The page does not explain how competing instructions within one directory are resolved, how rule changes affect an existing session, or how full-file loading interacts with overall context limits.

Reasoning

The documented hierarchy supports shared repository conventions plus local exceptions. A practical implication is that maintainers need to consider the complete directory path to understand which instructions take precedence.

Working-directory choice also matters: discovery follows the path to that directory, so nested package instructions are relevant when that path includes their location. This implication follows from the documented discovery mechanism; it has not been confirmed through execution.

Alternatives

Within the guide, persistent Markdown files suit recurring instructions, while --rules supplies guidance for one run. The --system-prompt-override option replaces the entire system prompt and therefore has a broader effect.

Compatible CLAUDE filenames and .claude/rules/ or .cursor/rules/ directories offer other file locations Grok can read. This compatibility does not establish equivalent behavior in other assistants, which the page does not compare.

Evidence

The evidence is the complete xAI documentation page at [https://docs.x.ai/build/features/project-rules.md]. It contains discovery rules, a monorepo layout, a temporary-rule command and an inspection command.

The page documents intended behavior. It contains no execution logs, inspection output, comparative benchmarks or measured instruction-following results. No commands were executed for this report.

Access & freshness

Costs

Pricing, subscription requirements, usage allowances and any charge associated with project rules are unknown from this page.

The guide says files are loaded in full and inspection reports approximate token counts. It provides no billing rules or measurements from which to calculate cost.

Rights

The page provides no documentation license or explicit redistribution permission. Grok's service terms and rights governing generated code are also not specified, so those rights cannot be established from this source.

Freshness

The available source copy was captured on 23 November 2026 at 07:20:25 UTC. The page itself supplies no publication date, update date or applicable Grok version. Compatibility with a particular installed release is therefore unknown.

Actions

Start with a concise repository-root AGENTS.md containing the conventions and commands needed for the project. Add nested instructions where packages differ, and review conflicts against the documented deeper-directory precedence.

Use grok inspect from the intended working directory to check discovered paths and token counts. Separately assess whether Grok follows the instructions on a representative task; the guide provides no results for that question.

Use --rules for temporary guidance. Choose --system-prompt-override only when complete system-prompt replacement is the intended effect.

Evidence for this report

selected-page.txtselected · checked 2026-11-23