Back to all articles
TutorialDecember 2, 2026·12 min read

Grok Build vs Claude Code - Which Files Each One Reads Before It Starts (2026)

Your repository was set up for Claude Code: a CLAUDE.md at the root, a few rules in .claude/rules/, and a CLAUDE.local.md with your own notes that never gets committed. A teammate now runs Grok Build's grok command in the same repository and says it seems to follow different instructions. Some rules that only apply to tests are showing up everywhere, and your personal notes aren't there at all. You start to wonder which files each tool actually reads before it writes a line of code.

The short answer: both tools read instruction files from your repository at the start of a session, and Grok Build reads most of Claude Code's files too. xAI's documentation says "Grok is fully compatible with Claude Code with zero configuration needed." But the two tools pick files by different rules: which file names count, what happens to gitignored files and rule frontmatter, and whether automatic memory starts on.

This guide covers a side-by-side table, how each tool loads instructions, where they differ, where they work the same way, which setup fits which kind of work, and how to keep one set of project context when you use both.

Grok Build vs Claude Code at a glance

DimensionGrok BuildClaude Code
Instruction file names read in each directoryAGENTS.md, Agents.md, AGENT.md, CLAUDE.md, Claude.md, and CLAUDE.local.md, plus *.md in .grok/rules/CLAUDE.md, .claude/CLAUDE.md, and CLAUDE.local.md; AGENTS.md only when none of those exist, by default
Which directories load at launchGlobal rules in ~/.grok/, then every directory from the repository root down to the working directoryThe working directory and every directory above it; subdirectory files load on demand
When two files disagreeDeeper files take precedence on conflictsFiles are concatenated rather than overriding each other
Rule folders.grok/rules/, plus plain *.md files directly in .claude/rules/ and .cursor/rules/; frontmatter is stripped.claude/rules/, searched recursively; paths frontmatter scopes a rule to matching files
Files ignored by .gitignoreSkipped during rule discoveryCLAUDE.local.md loads after CLAUDE.md in its directory
Size handlingFiles load in full, with no size capWhole CLAUDE.md up to 4 MiB; a larger file is skipped
Automatic memory between sessionsCross-session memory is off by defaultAuto memory is on by default in local sessions
How to check what loadedgrok inspect lists each rules file with its path and approximate token count/context all lists loaded files under Memory files; /memory opens them

Checked against each vendor's documentation on December 2, 2026.

Grok Build has two surfaces. This comparison covers the Terminal UI, the grok command, because that's the one that reads Claude Code's files. The desktop Agents Window uses the Cursor rules system instead; our guide to what changed when Cursor became Grok Build covers that side.

How Grok Build loads instructions

xAI describes project rules this way: "Project rules are Markdown files that Grok loads into context for every session in a directory tree."

Instruction files

Grok starts with global rules in ~/.grok/, then reads every directory from the repository root down to the working directory. Outside a git repository, it reads only the working directory. In each directory it accepts several names. xAI's page says Grok reads "any of AGENTS.md, Agents.md, AGENT.md, CLAUDE.md, Claude.md, and CLAUDE.local.md", plus every *.md file in .grok/rules/.

When two files disagree, depth decides. xAI says the tool loads rules "with deeper files taking precedence on conflicts". A nested AGENTS.md in packages/frontend/ applies to that subtree.

Rule folders and compatibility

It reads .claude/rules/ and .cursor/rules/ for compatibility, with limits. xAI writes that "Grok loads only plain *.md files sitting directly in those directories, and it does not load .mdc files at all." Frontmatter isn't applied: "frontmatter such as globs or alwaysApply is stripped rather than applied, and nested subdirectories are not searched."

Beyond instructions, it picks up Claude Code's other files. Its compatibility section says: "Grok automatically reads Claude Code marketplaces, plugins, skills, MCPs, agents, hooks, and instruction files". Each scanner can be turned off in ~/.grok/config.toml.

Memory and sessions

It saves conversations on its own. xAI's sessions page says it stores "prompts, responses, tool calls, and file snapshots" under ~/.grok/sessions/, keyed by working directory, and you can resume them with /resume or grok -c.

Cross-session memory is a separate setting. The Terminal UI settings reference lists a [memory] switch, described as the "Cross-session memory master switch", with a default of off. The xAI pages checked for this guide don't describe what it saves when you turn it on.

How Claude Code loads instructions

Anthropic's memory page opens with the basic fact: "Each Claude Code session begins with a fresh context window." Two things carry knowledge across sessions: CLAUDE.md files you write, and auto memory Claude writes.

Instruction files

Claude Code reads CLAUDE.md and CLAUDE.local.md from the working directory and every directory above it at launch. Files in subdirectories load later, once Claude Code reads or edits a file there. Anthropic is clear about how they combine: "All discovered files are concatenated into context rather than overriding each other." Instructions closer to where you launched Claude are read last.

AGENTS.md is a fallback by default. Anthropic's page says: "By default, Claude reads AGENTS.md only when you have no CLAUDE.md in your working directory or above it." You can change that with the Project instructions setting in /config, for example to read both files together.

Rule folders

Claude Code reads .claude/rules/ and searches it in depth. Anthropic's page says: "All .md files are discovered recursively, so you can organize rules into subdirectories like frontend/ or backend/". In Claude Code, rules with a paths field in their frontmatter load only when Claude works with matching files. Rules without one load at launch.

Memory and sessions

In Claude Code, auto memory is the part Claude writes. Anthropic's page says: "Auto memory is on by default in local sessions." Notes go to ~/.claude/projects/<project>/memory/, with an index file, MEMORY.md, whose first 200 lines or 25KB load at session start. Anthropic also notes: "Auto memory is machine-local."

Session transcripts are deleted after the cleanupPeriodDays retention period, but the memory files are excluded from that sweep.

Where they differ

Which file wins when both CLAUDE.md and AGENTS.md exist

Grok Build reads both. Its list of accepted names in each directory includes AGENTS.md and CLAUDE.md side by side.

Claude Code reads CLAUDE.md only, by default. Anthropic's table says that with an AGENTS.md and a CLAUDE.md in your working directory or above it, Claude reads "Your CLAUDE.md files only". If the two files hold different instructions, the two tools start from different context.

What happens to CLAUDE.local.md

Grok Build skips files that .gitignore covers. xAI's page says: "Files ignored by .gitignore are skipped, which keeps personal overrides like CLAUDE.local.md out of shared context." If your CLAUDE.local.md is gitignored, as Anthropic recommends, Grok doesn't load it.

Claude Code loads it, appended after CLAUDE.md in the same directory, so your personal notes are the last thing Claude Code reads at that level. Anthropic adds a side effect: "Because CLAUDE.local.md counts, adding one to keep your own uncommitted instructions in a project that relies on AGENTS.md stops Claude from reading AGENTS.md for you."

How rule frontmatter is treated

Grok Build strips it. A rule in .claude/rules/ with a paths field loads in every Grok session, because the frontmatter is "stripped rather than applied". Grok also doesn't search nested folders inside .claude/rules/.

Claude Code applies it. A rule with paths loads only when Claude Code works with matching files, and Claude Code finds rules in subfolders too.

How conflicts resolve

Grok Build gives precedence to deeper files, so a package-level file takes precedence over the root on conflicting guidance.

Claude Code concatenates everything and doesn't rank the files. Anthropic's troubleshooting section warns that if two files give different guidance for the same behavior, "Claude may pick one arbitrarily."

Whether automatic memory starts on

Grok Build's cross-session memory is off by default, according to its settings reference. Its saved sessions are transcripts you resume, not notes it carries into new sessions.

Claude Code's auto memory is on by default in local sessions, and Claude Code loads its index at the start of each one.

Where they work the same way

  • Both read instruction files at the start of a session. Neither needs you to repeat project conventions each time.
  • Both walk the directory tree. Instructions near your working directory apply on top of repository-wide ones.
  • Both read AGENTS.md in some setups. Grok Build reads it always; Claude Code reads it when there's no CLAUDE.md, or always if you change the Claude Code setting.
  • Both save conversations you can resume. Grok uses ~/.grok/sessions/; Claude Code keeps transcripts until its retention period ends.
  • Both offer a way to check. grok inspect and /context all show what actually loaded.

Which one fits which job

If your repository already has a CLAUDE.md and .claude/rules/ with paths scoping, Claude Code applies that structure as written, and Grok loads the same rules in every session.

If your repository is built around AGENTS.md, Grok reads it with no setup. Claude Code reads it too, as long as there's no CLAUDE.md or CLAUDE.local.md on the path, or once you set Project instructions to read both.

If you rely on personal notes that aren't committed, Claude Code loads a gitignored CLAUDE.local.md. For one-off personal instructions in Grok, xAI's page describes session rules: --rules appends text to the system prompt for one run.

If you want automatic notes between sessions, Claude Code's auto memory starts on. In Grok, it's a setting you'd turn on and test yourself.

Using both

If you keep Claude Code alongside Grok Build, the instruction files can be shared, but three things drift apart:

  1. Scoped rules. A test-only rule in .claude/rules/ stays scoped in Claude Code and loads everywhere in Grok.
  2. Personal notes. A gitignored CLAUDE.local.md reaches Claude Code and not Grok.
  3. What each tool learned. Claude Code's auto memory lives in ~/.claude/projects/, and Grok's saved sessions live in ~/.grok/sessions/. Neither tool's documentation describes reading the other's.

The safest shared base is one AGENTS.md with the conventions both should follow, loaded in Claude Code through an @AGENTS.md import in CLAUDE.md, which Anthropic describes as the way to share one file with other coding tools.

What people try first

Assuming Grok reads Claude Code's files the same way. It reads the files, but strips rule frontmatter and skips gitignored ones.

Adding a CLAUDE.local.md to an AGENTS.md project. In Claude Code, that switches AGENTS.md off by default.

Putting rules in nested folders under .claude/rules/. Claude Code finds them; Grok doesn't search nested subdirectories there.

Expecting Grok to remember the way Claude Code does. Grok's cross-session memory starts off, and its saved sessions are separate from Claude Code's notes.

Checking by asking the agent. grok inspect and /context all give an exact list instead.

The Fix: Give both tools the same project context

Step 1: Put shared conventions in one AGENTS.md

Move the instructions both tools should follow into AGENTS.md at the repository root, and add @AGENTS.md at the top of CLAUDE.md.

Step 2: Make scoped rules safe to load everywhere

Review each rule in .claude/rules/ that uses paths. Rewrite it so it still makes sense if Grok loads it in every session, or keep it in a Claude-only place.

Step 3: Check what each tool loaded

Run grok inspect and /context all in the same directory and compare the lists.

Step 4: Write down what both should know

Note the decisions behind the rules, such as why the tests need a local database, in your own words, in a place outside either tool's files.

Setting this up in MemoryLake

Instruction files tell each tool how to work in the repository. The reasons behind them, such as which approach the team rejected or which service is being retired, are context worth keeping where every assistant can find it.

MemoryLake is a memory layer for that kind of context, kept in one place you maintain and available to the assistants you connect, such as ChatGPT, Claude Code, and Codex. Grok Build isn't one of them, so for Grok you paste the context you've written into AGENTS.md or a .grok/rules/ file yourself.

You write the entries yourself, in your own words. Nothing is read out of, written to, or deleted from your CLAUDE.md or AGENTS.md files, your .claude/ or .grok/ folders, Claude Code's auto memory, Grok's saved sessions, or any vendor's store. Grok Build and Claude Code work the way their vendors describe them.

Step 1: Create an API key

Sign in and generate a key from the dashboard. Keep it somewhere private.

The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent
The MemoryLake console showing the API keys screen, where a new key is created and copied for use in an agent

Step 2: Upload your first memories

Start with what you wrote in Step 4 of the fix: the decisions behind your rules. One topic per entry.

The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory
The MemoryLake workspace with the first documents uploaded, listing each file as it becomes searchable memory

Step 3: Connect your AI & agents

Connect ChatGPT, Claude Code, Codex, and the other assistants you use, so the same context is there in each.

The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer
The MemoryLake integrations screen listing the AI clients and agent frameworks that can be connected to the memory layer

What this changes in practice

The first difference is fewer surprises. Rules that only make sense in one tool stop leaking into the other.

The second is a shared record of reasons. A rule file says what to do; your notes say why, and that survives a change of tool.

The third is easier checking. When both tools start from the same AGENTS.md, a difference in behavior points to a scoped rule or a personal file, not a missing convention.

Best practices for using Grok Build and Claude Code together

Keep one AGENTS.md as the shared base. Both tools can read it.

Import it into CLAUDE.md. That keeps Claude Code reading it even when CLAUDE.md exists.

Treat paths rules as Claude-only. Grok strips the frontmatter.

Keep rule folders flat if Grok should read them. Nested subdirectories aren't searched.

Don't count on CLAUDE.local.md in Grok. Use --rules for one-off personal instructions there.

Run the inspect commands after changes. grok inspect and /context all show the real list.

Decide on memory per tool. Claude Code's auto memory is on; Grok's cross-session memory is a setting you control.

Conclusion

Grok Build's Terminal UI reads a wide set of instruction files, including AGENTS.md and CLAUDE.md in the same directory, plus plain rule files from .grok/rules/, .claude/rules/, and .cursor/rules/. It strips rule frontmatter, skips gitignored files, gives deeper files precedence, and starts with cross-session memory off.

Claude Code reads CLAUDE.md files and falls back to AGENTS.md only when there's no CLAUDE.md, applies paths rules from a recursively searched .claude/rules/, concatenates files without ranking them, loads a gitignored CLAUDE.local.md, and starts with auto memory on. Keep shared conventions in one AGENTS.md, check what each tool loaded, and keep the reasons behind your rules in your own words.

Frequently asked questions

Does Grok Build share memory with Claude Code?

Not according to either vendor's documentation. Grok saves sessions under ~/.grok/sessions/, and Claude Code keeps auto memory under ~/.claude/projects/. Grok Build reads Claude Code's instruction files, skills, and MCP config, but neither tool's documentation describes reading the other's memory or sessions.

Is Grok Build or Claude Code the right choice for a repository set up for Claude Code?

It depends on how the repository uses scoping. Claude Code applies paths rules and loads CLAUDE.local.md; Grok reads the same files but loads every rule in every session and skips gitignored ones.

Does Grok Build read CLAUDE.md?

Yes. xAI lists CLAUDE.md, Claude.md, and CLAUDE.local.md among the instruction files Grok reads in each directory, alongside AGENTS.md.

Does Claude Code read AGENTS.md?

By default, only when there's no CLAUDE.md or CLAUDE.local.md in your working directory or above it. Change the Project instructions setting in /config to read both.

Why doesn't Grok load my CLAUDE.local.md?

Grok skips files that .gitignore covers during rule discovery, and CLAUDE.local.md is usually gitignored.

Does Grok Build apply paths or globs in rule files?

No. xAI says frontmatter such as globs or alwaysApply is stripped, so every rule Grok loads from those folders applies in every session.

Is Grok Build memory on by default?

No. The Terminal UI settings reference lists cross-session memory as off by default.