What @ Includes Actually Shrink When You Split Agent Rule Files
I split my rule files with Antigravity 2.11.0's @ includes and measured before and after. Maintenance surface dropped 62 percent; what a session reads dropped 1.7 percent. Against the 24,000-byte cap after expansion, here is the ordering that keeps repository-specific rules from being cut, plus an expander that catches missing, doubled, and over-cap includes.
I stopped mid-sentence while copying the same warning into a fourth file.
A handful of static site repositories, each with its own rule file for the agent. The openings differ. Everything past the introduction is nearly identical. Fixing one line meant opening the other three and hunting for the same spot. As an indie developer juggling several projects at once, this kind of hand-copying piles up before you notice.
Antigravity 2.11.0, released on August 26, added @path/to/file inside AGENTS.md and custom rule files. Referenced files get inlined directly. That duplication could finally collapse.
I assumed the read volume would drop along with it. When I measured my own files, it did not. Something else did.
Then, in November, the per-file limit was documented in bytes, and the August result stopped being merely "it does not shrink." The later sections cover how I now order files against that cap and how I triage the failures it causes.
Splitting reduces maintenance surface, not what a session reads
The conclusion first. Here is what happened when I split four repository rule files into a shared part and a per-repository part, then reassembled them with @.
What is being measured
Before
After
Change
Total bytes across files you maintain
340,824
129,229
62% smaller
Expanded bytes a session reads (one repository)
85,736
84,260
1.7% smaller
The maintenance surface fell to roughly a third. What the agent actually receives barely moved.
The reason is obvious in hindsight. An include inlines the target in place. Collapsing shared rules into one file does not change the fact that every file referencing it still carries the full text once expanded. The duplication disappears on disk and in review. For the expanded input, nothing happened.
Some finer numbers. Counting non-blank lines across the four files: 3,430 lines total, 1,214 of them unique. 695 lines appear verbatim in all four files, totaling 35,639 characters.
Metric
Lines
Total non-blank lines across four files
3,430
Unique lines after deduplication
1,214
Lines present in all four files
695
Lines present in two or more files
780
Only 35 percent of the content was distinctive. The rest was text I had transcribed by hand. In that state, forgetting one edit leaves each repository's agent working from a different set of assumptions. The reason to split was never input reduction. It was making that divergence structurally impossible.
Get this backwards and you split, see no improvement in the metric you were watching, and conclude the feature was not worth it. Decide what you are buying before you start.
The 24,000-byte cap after expansion makes this result matter more
As of November 2026, the official Rules documentation states a per-file cap of 24,000 bytes for AGENTS.md, GEMINI.md, and .agents/rules/*.md. Anything past the cap is truncated from the end, and the count is taken after includes are expanded. The limit used to be described as 12,000 characters; it is now measured in bytes.
Going back to the table above, I sat looking at one number for a while. One repository expanded to 84,260 bytes. If everything is expanded from a single entry file, that is three and a half times the cap. In August I was satisfied to have confirmed that splitting did not change the read volume. Read against today's documentation, roughly the last seventy percent would never reach the agent at all.
Includes do not split the cap. The expanded result is still judged as one file. A tiny AGENTS.md that pulls in a large shared file goes over even if the entry itself is a few hundred bytes. I built a small tree and ran it through the expander below:
{"entry": "AGENTS_en.md", "ok": false, "base": "root", "bytes": 25830, "files": 2,
"missing": [], "duplicated": {}, "over": 1830,
"cut_inside": "## Shared 8", "dropped": ["## Specific to this repository"]}
The entry is 125 bytes. With the shared file inlined it becomes 25,830 bytes, 1,830 over. The field worth reading is dropped. The repository-specific section, which I had written after the include line, is pushed past the cap in its entirety.
When I moved that section above the include line and ran the same check, the overflow was the same 1,830 bytes, but dropped came back empty. Only the tail of the last shared section was cut. You cannot always change how much gets truncated, but the ordering decides what gets truncated.
Specific rules first, shared rules last. If something has to fall off, let it be the text every repository already has. Of everything I changed during this split, that ordering rule did the most. A missing tail of shared rules can be covered elsewhere, through subdirectory rules or rules loaded only when relevant. A repository's own assumptions live in exactly one place.
One caveat. I have not re-measured, inside Antigravity itself, exactly where it truncates. The expander's verdict is an estimate that follows the documented behavior. There is an open request on the CLI repository to make the cap configurable, the way Codex exposes project_doc_max_bytes (issue #1863). As of November 2026 I would design on the assumption that it cannot be changed.
✦
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
✦Estimate what splitting your rule files will and will not reduce, using measurements from your own repository
✦Catch the silent rule-drop that happens when include paths resolve against the wrong base, before you ship the change
✦Spot a layout where a shared rule file gets pulled in twice and doubles your expanded input, before you run it
✦See which sections the 24,000-byte cap pushes out after expansion, and order your files so repository-specific rules survive
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.
Root-relative caught the cycle and stopped. Expected.
File-relative did not stop. Inside rules/b.md, the string @rules/c.md resolves to rules/rules/c.md, which does not exist, so the include never happens. The cycle never closes, so no error fires. The expansion reports success and one file's worth of rules quietly vanishes.
This is the worst failure mode in the whole exercise. The breakage shows up as absence rather than as an exception. Nothing in the output looks wrong. It surfaces only as a vague sense that the agent is behaving a little oddly.
Rule files are not the kind of file you re-verify on every run. That is exactly why an omission survives for weeks.
Returning an empty string for a missing include is the dangerous choice
There is a fix, and it lives in your expander rather than in your file layout: never return an empty string when a target is missing.
My expander leaves a marker instead.
if not os.path.isfile(real): stat["missing"].append(path) return f"<!-- MISSING INCLUDE: {path} -->\n", stat
Three lines, but they change how the failure is discovered. The marker catches a human skimming the expanded text, and the missing array catches an automated check. Either path works.
The same reasoning applies to a depth ceiling, as insurance for when you have picked a base that cannot detect cycles.
if depth > max_depth: raise Cycle(f"exceeded {max_depth} levels: {os.path.relpath(real, root)}")
Cycle detection and depth limiting look redundant. They cover each other's blind spots, and both are cheap.
The full expander
This is what I run before handing rule files to the agent, and again whenever I edit them.
#!/usr/bin/env python3"""Expand @ includes and audit the result before the agent sees it.base="file" ... relative to the including file (the base moves as you nest)base="root" ... fixed to the project root (same string, same meaning, anywhere)"""import sys, re, os, jsonLIMIT = 24_000 # per-file cap, counted in UTF-8 bytes after expansion (official docs, November 2026)# Only a full line that is an include gets expanded, so @mentions and email# addresses in prose are left alone. Accepts both the bare @path form I used# in August and the link form @[label](path).INCLUDE = re.compile( r'^([ \t]*)@(?:\[[^\]]*\]\(([^)\s]+)\)|([A-Za-z0-9_./\-]+\.(?:md|txt|json)))[ \t]*$')HEADING = re.compile(r'^#{1,6} ')class Cycle(Exception): passdef expand(path, root, base="root", stack=None, stat=None, depth=0, max_depth=16): if stack is None: stack = [] stat = {"count": {}, "missing": []} real = os.path.realpath(os.path.join(root, path)) # Normalize with realpath before comparing, so a symlink or a ../ detour # to the same file is not treated as a different file. if real in stack: chain = [os.path.relpath(p, root) for p in stack[stack.index(real):]] raise Cycle(" -> ".join(chain + [os.path.relpath(real, root)])) if depth > max_depth: raise Cycle(f"exceeded {max_depth} levels: {os.path.relpath(real, root)}") # Never return empty for a missing target. Rules disappearing in silence # is the failure you will not notice. Count only files that exist. if not os.path.isfile(real): stat["missing"].append(path) return f"<!-- MISSING INCLUDE: {path} -->\n", stat stat["count"][real] = stat["count"].get(real, 0) + 1 out = [] for line in open(real, encoding="utf-8"): m = INCLUDE.match(line) if not m: out.append(line) continue indent, target = m.group(1), m.group(2) or m.group(3) anchor = "" if base == "root" else os.path.dirname(os.path.relpath(real, root)) child, stat = expand(os.path.normpath(os.path.join(anchor, target)), root, base, stack + [real], stat, depth + 1, max_depth) # Propagate the including line's indentation into the child, so an # include placed inside a bulleted list does not flatten the nesting. out.extend(indent + l if l.strip() else l for l in child.splitlines(keepends=True)) return "".join(out), statdef cut_point(text, limit=LIMIT): """If the cap truncates this text, which heading does it cut inside, and which headings fall off entirely?""" used, current, cut_inside, dropped, in_code = 0, None, None, [], False for line in text.splitlines(keepends=True): if line.lstrip().startswith("```"): in_code = not in_code is_head = bool(not in_code and HEADING.match(line)) if used >= limit: if is_head: dropped.append(line.strip()) elif cut_inside is None and not dropped: cut_inside = current continue if is_head: current = line.strip() used += len(line.encode("utf-8")) if used > limit and cut_inside is None: cut_inside = current return {"cut_inside": cut_inside, "dropped": dropped}def audit(entry, root, base="root"): try: text, stat = expand(entry, root, base) except Cycle as e: return {"entry": entry, "ok": False, "error": f"circular include: {e}"} size = len(text.encode("utf-8")) result = { "entry": entry, "ok": True, "base": base, "bytes": size, "files": len(stat["count"]), "missing": stat["missing"], "duplicated": {os.path.relpath(p, root): n for p, n in stat["count"].items() if n > 1}, } if size > LIMIT: result["ok"] = False result["over"] = size - LIMIT result.update(cut_point(text)) return resultif __name__ == "__main__": root, base = sys.argv[1], sys.argv[2] bad = False for entry in sys.argv[3:]: r = audit(entry, root, base) bad |= not r["ok"] or bool(r.get("missing")) print(json.dumps(r, ensure_ascii=False)) sys.exit(1 if bad else 0)
Run it like this. It needs only the Python 3.8+ standard library.
It exits with status 1 if any file is over the cap or has a missing include, so it drops straight into a pre-commit check for rule-file changes. The August version reported chars; since the cap is counted in bytes, I switched it to bytes in November.
It accepts both the bare full-line @path form I used in August and the link form @[label](path). Which form your version treats as official is worth confirming in that version's documentation.
Anchoring the pattern to a full line is deliberate. @ shows up constantly in prose, and a partial match will treat mid-sentence text as an include. My first version matched at line start only, and it swallowed explanatory text inside a bulleted list. Full line, trailing whitespace allowed, nothing else.
Pulling a shared file in through two paths doubles it, exactly as you would expect
There is a second trap, and this one makes things bigger.
As you split further, you end up with intermediate files that include the shared file. entry.md includes x.md and y.md, and both include common.md. Your includes are now a graph, not a tree.
duplicated reports 2, and bytes is 6,400: exactly two copies of the 3,200-byte common.md. The agent reads the same rules twice because you handed it the same rules twice.
The deeper your split, the easier this shape is to create. You can end up with more expanded input after a reorganization intended to reduce it. That is why the expander reports duplicated at all.
My fix was to pull shared files in at exactly one place, the entry point, and never from an intermediate file. Intermediate files are written assuming the shared rules are already present. Since a file cannot verify that assumption on its own, I leave a one-line comment at the top of each dependent file naming where it expects to be included from.
Under a 24,000-byte cap, a double include stops being mere waste and becomes a cause of omission. Every extra copy of those 3,200 bytes pushes the same amount of later content past the cut.
When the agent seems not to know part of your rules
After a split, the symptom "the agent is ignoring some of my rules" came down to one of the causes below. Checking them in this order kept the backtracking short.
Symptom
Likely cause
How to confirm
Fix
Only rules near the end of the file are ignored
The expanded file exceeds 24,000 bytes and the tail is truncated
bytes, over, and dropped from the expander
Move specific sections above the include. Move rules you do not need every session into a separate file
Some rules disappear only in one directory
File-relative resolution doubled the path (rules/rules/), so the include silently failed
Is the path listed in missing?
Standardize on root-relative paths and one include style
The same warning appears twice, or the expanded size grew after the split
The shared file is included through more than one route
Is any duplicated count 2 or higher?
Include shared files from the entry point only
Explanatory text in a bullet list vanished or was replaced with another file
The include pattern matched part of a line and grabbed an @ in prose
diff the text before and after expansion
Expand only lines that consist entirely of an include
A larger rule file shows up as just a path and a description
The combined rule budget was exceeded and the largest files were demoted
Add up the rules that always load
Move rules you rarely need to load only when relevant
Expansion stops with a depth or cycle error
Includes form a loop
The chain printed in error
Remove the include from the lowest file in the chain
Rows one and five look identical from the outside: the back of your rules does not arrive. The first is the per-file cap, the second is the combined budget, and the fixes differ. If every file's bytes is under the cap and the symptom persists, look at the combined budget next.
Three things I had backwards
"Splitting with includes keeps me under the cap." It does not. The cap is applied after expansion, so a small entry file is judged together with everything it pulls in. To stay under, the pieces have to be separate rule files sitting side by side, not includes of one another.
"If I go over, loading will fail and tell me." The documentation says the file is truncated, not that loading fails. It is the same kind of quiet as the missing-include case earlier in this article. Whatever tells you about it has to live on your side.
"24,000 bytes is about 24,000 characters." For English prose, close enough. Japanese text runs around three bytes per character in UTF-8, so a rule file written in Japanese approaches the cap at roughly a third of the character count you would expect. My own shared rules looked comfortably small when I counted characters.
Where to split and where to leave things alone
Doing this for real surfaced a few usable boundaries.
Worth splitting
Rules that are word-for-word identical across repositories. In my measurement that was the 695-line block.
Supplementary material whose relevance depends on the task. Sessions that do not need it stop paying for it.
Content with a different update owner. If only one side changes often, the diffs get much easier to read.
Better left in one file
Rules where ordering carries meaning. Shift the include position and you shift how precedence reads.
Conditional rules that get misread without their surrounding context. An "except when..." clause stranded in another file is a hazard.
Blocks under a hundred lines. The file-management overhead exceeds the benefit.
I overshot on that last one and rolled it back. Fine-grained splitting feels tidy, but an entry file that is nothing but a column of @ lines tells you nothing when you open it. Keeping files readable on their own turned out to be faster overall. When you are the only person reviewing your own repositories, that difference lands directly on your working hours.
For the decision order: first check whether the same text exists in more than one place. If not, do not split. If it does, check whether that block stands on its own when read in isolation. If it does not, widen the boundary until it does, then extract.
Since November I add one last check to that order: expand the entry after extraction and see whether it fits inside 24,000 bytes. If it does not, the problem is no longer how to split. It is how much you make the agent read every session, and the answer is separate rule files or rules that load only when relevant.
Combining this with subdirectory config files
2.11.0 also added discovery of skills.json, agents.json, and rules.json from subdirectories, so a project with multiple packages can give each package its own rules.
That solves a different problem than @ does. Includes govern how a single rule file is composed. Subdirectory config governs which rule file gets selected in the first place.
Here is how I divide them:
Goal
Mechanism
Keep identical rules in one place across repositories
@path/to/file includes
Apply different rules depending on the working directory
Subdirectory rules.json
Bind specific rules to one particular agent
The rules: frontmatter key
That third one lets a custom Markdown agent point directly at a rule file, which is useful when different agents follow different conventions and you want that mapping written down.
The thing to watch when combining them is the same rule arriving through two routes. If a rule file loaded via a subdirectory rules.json is also pulled in by an @, you are back in the double-expansion case above. The expander only counts the include path, so this one has to be prevented at design time.
What you hit next is the combined budget, not the single file
Once each file fits under the cap, the next thing to watch is the total of rules that always load. In my case, re-laying the split as separate files pushed the total over the combined budget, and the largest files were demoted first.
The output is "duplicated lines / total lines". It is tempting to reach for sort | uniq -c, but that counts the distinct lines that appear more than once, not how many copies were hand-written (the 780 in the table above is that count). To estimate what a split can remove, total minus unique is the number that matches reality.
A small number means splitting buys you nothing. A large number means you can proceed knowing what you are actually reducing. In my case 2,216 of 3,430 lines were duplicates, and knowing that number first produced a very different design than the one I had in mind.
After that, run one of your entry files through the expander above and look at bytes and dropped. If a repository-specific section shows up in dropped, moving it above the include line is the fastest first fix.
What a split does not change, and what the cap quietly pushes out, turned out to matter more to me than the split itself. Thank you for staying with this to the end.
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.