ANTIGRAVITY LABJP
Articles/Editor View
Editor View/2026-06-22Intermediate

Precedence for Nested AGENTS.md: A Merge Design for Many Projects in One Workspace

Put several projects in one workspace, each with its own AGENTS.md, and which instruction the agent follows turns ambiguous. Root and per-project rules quietly collide; one wins, or both blend. Taking 'closer is stronger' as the base rule, this designs a merge that distinguishes overriding from appending, with working Python and field notes.

Antigravity258AGENTS.md8Workspace DesignAgent OperationsProduction10

Premium Article

Keep several projects in one workspace and a day comes when the agent's behavior turns suddenly unreadable. The root AGENTS.md says "commit messages in English," yet one project keeps writing them in Japanese. Look closer and that project has its own AGENTS.md, carrying a different instruction.

Nested instruction files are a natural idea in themselves: shared promises at the root of the workspace, project-specific promises inside each. The trouble is that when the two collide, "which one wins" is defined nowhere. The agent interprets the unwritten precedence loosely, anew each time.

What this designs is the merge rule that removes that "loosely." Several AGENTS.md files, bound into one in a fixed order, by a fixed method.

What happens with several AGENTS.md in one workspace

First, look concretely at where the ambiguity comes from.

I keep Dolice Labs' several sites bound into one workspace myself. The root holds promises shared by all sites — "Japanese in polite form," "no bare URLs" — while each site's folder holds that site's specifics: category names, build steps.

Three patterns emerge here. Only the shared rule takes effect and the specific one is ignored. Only the specific rule takes effect and the shared one falls away. Or the two blend halfway into a result matching neither. Which one happens shifts with how the agent reads it at that moment. Nothing is worse than a bug that won't reproduce.

Make "closer is stronger" the base rule

To cut this ambiguity, place one clear principle. The AGENTS.md closer to the file being edited has the stronger instruction. That's all.

workspace/
├── AGENTS.md            ← weak (shared rules for everything)
├── claudelab/
│   ├── AGENTS.md        ← medium (shared within this site)
│   └── articles/
│       └── AGENTS.md    ← strong (specific to this area)
└── rorklab/
    └── AGENTS.md
LevelRolePriority
Workspace rootPromises shared by all projectsLow (foundation)
Project rootSpecifics shared within the projectMedium
SubfolderRules specific to that areaHigh (final say)

Just sharing the single sentence "closer is stronger" makes "which instruction finally takes effect when editing this file" uniquely determined. Ambiguity is born from the absence of a rule. Even one line, once written down, dissolves it.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
A breakdown of how root and per-project AGENTS.md files collide into unreadable behavior, and how to set precedence with 'closer is stronger' as the base rule, paired with a scope table
Instead of deciding vaguely in prose, a merge that combines multiple AGENTS.md section by section, distinguishing override from append, given as drop-in Python
Guidance on splitting shared rules into the root and specific rules into each project, plus keeping AGENTS.md thin, drawn from binding several sites into one workspace as an indie developer
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Editor View2026-06-16
Feeding Spec PDFs to Antigravity 2.1.4: A Practical Attachment Workflow
Field notes on using the PDF attachment added in Antigravity 2.1.4 as a spec-driven implementation workflow: supported formats, the scanned-PDF trap, token cost, and how to verify the output.
Editor View2026-05-24
VS Code 1.121 and the Agent Host Protocol — Reading the Moment When Editor Boundaries Started Moving Outward
VS Code 1.121 introduced Remote agents and the Agent Host Protocol (AHP), expanded the Claude Agent's Auto mode and BYOK options, and made Markdown Mermaid support standard. Read from an Antigravity user's perspective, this release looks like the moment the editor began stepping outside itself.
Editor View2026-04-28
Building a Multi-Model Development Environment with GitHub Copilot BYOK
GitHub Copilot's BYOK feature now lets you register API keys from Anthropic, Google, OpenAI, OpenRouter, Ollama, and more. Learn how to set up VS Code for seamless model switching based on your coding task.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →