Guides

A decision in one repo, an agent in another

What Claude Code, Codex and Grok Build read outside your repo, tested with --add-dir, imports, symlinks and a parent folder, and where shared rules go.

Published · updated

The API team freezes /v1/orders. The pull request that does it also adds a line to api/AGENTS.md: "/v1/orders is frozen since 2026-11-20; new callers use /v2/orders." Reviewed, merged, done.

The next morning someone opens Claude Code in the web repository and asks for an order history page. The agent finds /v1/orders in the existing client code, adds one more call to it, and the tests pass. Nobody did anything wrong. The agent in web never read a file in api.

Every tool in this guide reads instructions from the repository you launch it in. A team with a frontend, an API and an infra repository has decisions that belong to two or three of them at once: an API contract, a deprecated endpoint, a shared environment, a library everyone must stop using. This guide shows what each tool documents about instruction files outside the launch repository, what we measured on our own machine, and where a decision like the frozen endpoint has to live so the agent in the other repository sees it.

Card: The decision lives in api. The agent opened in web. Left, the file api/AGENTS.md, marked “reviewed, merged”, with its highlighted line: /v1/orders is frozen since 2026-11-20; new callers use /v2/orders. Four dotted lines leave it and stop at a red X before the window on the right: Claude Code 2.1.329 opened in web with claude -p, on 2026-12-01, under the question “did the api line arrive?”. The four tries: --add-dir ../api, no; plus CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1, no; @../api/AGENTS.md in web/CLAUDE.md, no; a symlink in .claude/rules/ to api/AGENTS.md, no. Below: next morning, in web, one more call to /v1/orders, the tests pass, nobody did anything wrong. In a dark band, the folder above both: ~/work/AGENTS.md, Claude Code reads it, Codex 0.156.1 doesn’t, and it is in no repository.

What each tool documents

Claude CodeCodexGrok Build
Where project instructions come fromCLAUDE.md and CLAUDE.local.md "from your current working directory and every directory above it", and AGENTS.md when there is no CLAUDE.md there"Starting at the project root (typically the Git root), Codex walks down to your current working directory"Agents Window: .cursor/rules/*.mdc, and AGENTS.md in the project root and in subdirectories. Terminal UI: "Every directory from the repo root down to the working directory (or only the working directory outside a git repo)", reading AGENTS.md, CLAUDE.md, CLAUDE.local.md and the *.md files in .grok/rules/, plus plain *.md files in .cursor/rules/ and .claude/rules/
A second repository opened for the session--add-dir: "By default, CLAUDE.md files from these directories are not loaded." With CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 their CLAUDE.md loads, and "Their AGENTS.md doesn't load"--add-dir: "Additional directories that should be writable alongside the primary workspace". The AGENTS.md page lists no other sourceNot stated on the page we read
Pulling a file in from elsewhere@path imports. An import that "resolves outside your working directory" is external: "The first time Claude Code encounters external imports in a project, it shows an approval dialog". A symlinked rule pointing outside is treated the same wayNot stated: one file per directory on the root-to-cwd path"Rules aren't imported on their own": rules from a GitHub repository come in a published plugin
Instructions for every repository at onceA managed CLAUDE.md (/etc/claude-code/CLAUDE.md on Linux) and ~/.claude/CLAUDE.mdAGENTS.md or AGENTS.override.md in the Codex home (~/.codex)Team Rules, "managed from the dashboard. Available on Team and Enterprise plans", applied "Team Rules → Project Rules → User Rules". The Terminal UI also loads "Global rules in ~/.grok/"

Two things stand out. In all three tools, the cross-repository options are either machine-level files (one per laptop, per CI runner, per tool) or a vendor dashboard. And Claude Code's two in-repo routes to another repository, an import and a symlink, both stop at an approval the first time.

What we measured

On one Linux machine, on December 1, 2026, with Claude Code 2.1.329 and codex-cli 0.156.1. Each case builds two fresh git repositories side by side, api and web, with the frozen-endpoint line in api/AGENTS.md, and starts a headless run from web.

Neither tool was signed in on this machine that day, so no model call ran. We did not need one: both tools assemble the instruction files before the first request to the model. For Claude Code we recorded every file it loaded with an InstructionsLoaded hook, plus the line the built-in AGENTS.md reader writes to the debug log (that reader fires no hook). In three cases we also checked the session transcript for the marker text. For Codex we searched the session record it writes before its first request.

The Claude Code command, with the case's flags added:

cd web
claude -p hi --settings ./instructions-log.json --debug-file ./debug.log
Case, launched from webWhat Claude Code loaded
Nothing elsenothing
--add-dir ../api, api has only AGENTS.mdnothing
The same plus CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1nothing
The same, and api/CLAUDE.md holds its own line plus @AGENTS.mdapi/CLAUDE.md. Not the AGENTS.md it imports
web/.claude/rules/api-decisions.md symlinked to ../../../api/AGENTS.mdnothing
web/CLAUDE.md containing @../api/AGENTS.mdweb/CLAUDE.md. Not the AGENTS.md it imports
A CLAUDE.md in the folder above both repositoriesthat file
An AGENTS.md in the folder above both repositoriesthat file
The same, and web has its own AGENTS.mdboth, the parent folder's first
Case, launched from web with CodexWhat Codex loaded
AGENTS.md in web, in the folder above, and in api, with --add-dir ../apiweb/AGENTS.md only
The same without web/AGENTS.mdnothing

Five things the lab shows

1. --add-dir gives access to files, not to the other team's instructions. In both tools. In Claude Code even the environment variable that loads the added directory's CLAUDE.md skips its AGENTS.md, exactly as the documentation says. A repository that moved to AGENTS.md so that every tool reads one file is the one that disappears.

2. A link out of the repository is dropped in a headless run. The import from web/CLAUDE.md, the import inside the added api/CLAUDE.md and the symlinked rule all point outside the working directory, so Claude Code treats them as external. At a keyboard, the first session shows an approval dialog. In claude -p there is nobody to approve it, and the transcript confirms the text never arrived. The agent that misses the frozen endpoint is the scheduled one, the one nobody watches.

3. A parent folder works in Claude Code and not in Codex. Claude Code walks up past the git root, so a CLAUDE.md or AGENTS.md in a ~/work/ folder that holds every checkout loads for all of them. Codex starts at the git root and walks down, and the same file never reached it. Grok Build's Terminal UI documents the same walk as Codex, from the repo root down, so by its page a parent folder does not reach it either; we did not run it. The parent folder has another problem: it is in no repository. Nobody reviews it, it has no history, and it exists only on the machines where someone created it, which rarely includes CI.

4. Codex reads one directory chain. With api added, a parent AGENTS.md present and web holding its own file, Codex read web/AGENTS.md and nothing else. Without that file it read nothing at all.

5. Even the cases that load read whatever is on disk. The api checkout next to web on a laptop is as old as its last git pull. If it was cloned three weeks ago, the agent gets the rule as it was three weeks ago, with no date on the line to tell it so.

Where a cross-repository decision goes

Split decisions by who has to see them.

Lives in the repository's own fileLives somewhere every repository reads
How this repository builds, tests and deploysA contract between repositories: an endpoint, a schema, an event format
Conventions for this codeA deprecation that other repositories must stop calling
"Never edit generated files"A shared environment's state: frozen, migrating, read-only
Where to look up the current decisionsThe decision itself, with its date and who made it

For the right column there are three honest options.

Machine-level files. A managed CLAUDE.md, a ~/.codex/AGENTS.md, the global rules of Grok Build's Terminal UI in ~/.grok/ and Grok Build Team Rules all reach every repository. They are four places to edit for one decision, none of them carries a date, and the first three exist per machine: every laptop and every CI runner needs the same copy.

One decisions repository, read fresh. A small decisions repository with one line per key and a date, and a line in every repository's AGENTS.md that tells the agent to read it with git show origin/main:decisions.md from a clone the job updates first. This needs no product. It depends on the agent following the line, and nothing in it stops a second line for the same key.

A shared memory over MCP. The decision is written once, by key, and every agent in every repository reads the same current value through the same server. This is what we build, and the next section shows it.

Whichever you pick, add a gate for what must not happen. A check in the web repository's CI that fails on a new reference to /v1/orders stops the call. A sentence, in a file or in a memory, does not.

Check what your agents load: ten minutes

Save this as instructions-log.json anywhere:

{
  "hooks": {
    "InstructionsLoaded": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "jq -c '{file_path, load_reason, parent_file_path}' >> /tmp/instructions-loaded.log"
          }
        ]
      }
    ]
  }
}

Then, from each repository, start a session the way your team and your CI really start them, with the same flags and environment:

rm -f /tmp/instructions-loaded.log
claude -p "List the decisions you were given about other repositories." \
  --settings /path/to/instructions-log.json --debug-file /tmp/cc-debug.log
cat /tmp/instructions-loaded.log
grep -o 'AGENTS.md loaded: .*' /tmp/cc-debug.log

The log lists every CLAUDE.md, rule and import that loaded, with load_reason (session_start or include) and the file that imported it. The grep shows the AGENTS.md files the built-in reader loaded, which the hook does not report. For Codex, ask the same question in codex exec and compare the answer with the files you expected.

Then write down, for each decision that crosses repositories, which of your repositories can see it. Any blank cell is a frozen endpoint waiting to be called.

The same setup with ValorBrain

ValorBrain is a memory server for teams of agents, reached over MCP at one URL from every repository and every tool. The frozen endpoint becomes one keyed fact, written once by whoever records the decision:

{
  "tool": "upsert_keyed_fact",
  "arguments": {
    "fact_key": "api.orders.v1",
    "fact_value": "frozen since 2026-11-20; new callers use /v2/orders; existing callers move by 2027-01-31",
    "as_of": "2026-11-20",
    "evidence": "API team decision, PR that froze /v1/orders",
    "authority": "agent"
  }
}

A newer value for the same key replaces the older one, and keyed_facts_as_of returns what was in force on any past date. The authority: "agent" above is what an agent writes when it records a decision a person made; a person writing with their own token can record it as "human", with their own words in human_order, and then a lower-authority write for the same key waits as a proposal instead of replacing it. Correctability has the rules.

Every repository's AGENTS.md, api and web alike, keeps the same pointer:

## Decisions that cross repositories

Contracts, deprecations and shared environment state are not in this file.
At the start of a task, call `memory_prepare` and read the keyed facts it returns.
Before calling another repository's API or changing a shared schema, search the memory for it.
If a keyed fact and this file disagree, follow the fact and say so: it has a date and a source.

The third line is the one that catches the frozen endpoint. memory_prepare does not return every key in the memory: it returns the keyed facts whose key or value shares words with the request, about a dozen by default. "Add an order history page" may not bring api.orders.v1; a search for /v1/orders, made before the agent adds the call, does.

On a developer's machine, one command adds the server, writes the memory rules into the harness's instruction file and installs hooks, so the read does not depend on the model remembering the pointer:

npx -y @valorbrain/connect@latest --token <vbm_…> --harness <claude-code|codex|cursor>

On Claude Code and Codex a hook fetches memory at session start and on each prompt; the cursor harness gets a session-start hook and no prompt hook. A CI runner gets none of that: it needs the MCP entry and a few lines in the job's prompt, as Headless and scheduled agent runs shows. One MCP config in the repo, no token in git shows how to commit the server entry once per repository with nobody's token in it.

What ValorBrain does not do

  • It does not reach a harness that is not connected to it. An agent in a repository without the server, or in a CI job without the token, reads nothing from it. The ten-minute check above is still how you find out.
  • It does not block the call. A fact tells the agent; the CI check in web stops the merge. Keep both.
  • It does not know a decision nobody wrote. The API team's pull request has to record the fact, the same way it updated AGENTS.md. A line in the pull request template ("Does this change a contract other repositories use? Record it.") is the cheapest reminder.
  • It does not replace the repository's own file. Build commands, conventions and rules about one codebase belong next to the code, versioned with it.

What we ran and what we did not

Nine Claude Code cases and two Codex cases, one run each, on one Linux machine, with throwaway repositories and dummy text. No model call ran in either tool: both were signed out that day, and both assemble instructions before the first request, which is what the lab measures. The Claude Code results come from the InstructionsLoaded hook and the debug log, and three of them (the two imports and the parent CLAUDE.md) were confirmed against the session transcript. We did not test the interactive approval dialog for external imports, so we do not know whether an approval given once at a keyboard carries over to later headless runs on that machine. We did not run Grok Build; its column is documentation only. Whether a model follows an instruction once it is loaded is a separate question that this lab does not answer.

The lab script is a single bash file that builds the repositories under /tmp, runs each case and deletes everything after.

Checklist

  • Every decision that more than one repository depends on is listed, with the repositories that must see it.
  • You ran the ten-minute check from each repository, the way your CI starts the agent, not only from your laptop.
  • No cross-repository rule depends on an @../other-repo import, a symlink out of the repository or a parent folder that CI does not have.
  • The decision lives in one place, with a date and a source, and each repository's AGENTS.md points to it.
  • What must not happen is a CI check, not a sentence.
  • The pull request template asks whether a change affects another repository, and where to record it.

Sources, read on December 1, 2026: Claude Code, How Claude remembers your project (how CLAUDE.md loads, additional directories, imports, symlinked rules, AGENTS.md); Codex, Custom instructions with AGENTS.md and codex --help for --add-dir; Grok Build, Rules (project rules, Team Rules, AGENTS.md) and AGENTS.md (Terminal UI) (discovery, global rules); the documentation that used to be at cursor.com/docs now redirects to docs.grok.com and calls the product Grok Build.

Next: CLAUDE.md, AGENTS.md and .cursor/rules in one repo for the same problem inside one repository, Handing work from one coding agent to the next for what to pass along between tools and people, and Headless and scheduled agent runs for what a job with nobody watching starts with.

On this page