BaCheWork and records of a photonics research workhorse
Language

Routing layer: what AI reads at the start, and what it reads only when it hits something

Always-loaded content stays under 73 KB; the rest is read only as needed: the opening summary, rules that load when a file is touched, the lookup tables, and an automatic search when “last time” comes up.

Type
Essay
Published
2026-11-02
Updated
2026-11-02

However neatly the files are written, it does not help if the AI doesn’t know which one to read. But loading everything is not the answer either: every word read at the start takes up its attention and context space. The routing layer exists to handle this trade-off: keep only the smallest and most-used material at the start, and tell it “which file to read in which situation” for everything else.

The conclusion first

  • Always-loaded content has a budget: what is read at the start every time comes to about 68 KB, with a ceiling of about 73 KB, and it is checked each time a new conversation opens.
  • Instruction files are written as “when X, do Y”: most rules apply only in specific situations. Writing them as conditionals keeps the AI from treating every rule as something to do at all times.
  • One opening summary, with an overall cap: active projects, frequently used pages and system status are combined into one summary of under 10 KB. Anything that does not fit is marked “a few more not listed” rather than disappearing silently.
  • Rules follow the files: each of the 37 rules declares which files it applies to, and the AI loads a rule only when it touches one of those files.
  • Mentioning “last time” triggers an automatic search: when a question contains words like “before” or “last time”, the system first looks up candidate locations for the AI, rather than relying on the AI to remember to check.

1. The budget for always-loaded content

What is always read at the start Size (2026-11-02)
One-line descriptions of each skill (45 skills) About 28 KB
Global instruction file (CLAUDE.md) About 21.5 KB
Opening summary About 9.7 KB
Memory card index (one line per card) About 7.3 KB
Other hints About 1.5 KB
Total About 68 KB, ceiling about 73 KB

Each item also has its own limit. Each registry row is capped at 400 characters and the memory card index at 12 KB; both are there to protect the total. When something goes over, a warning appears on the first line of a new conversation.

The instruction file itself contains only conditional statements and pointers, for example: “For work with multiple steps and several agents dividing the tasks, first read a certain operations manual.” That manual runs to several hundred lines, but it is read only in that situation.

2. The opening summary

Each time a new conversation starts, the system automatically assembles a summary and places it at the very top. It includes:

  • Active projects, newest first; the rest listed by name only;
  • What each of the main view pages is for;
  • The results of the system health check (whether anything has expired and whether there are warnings that need action).

Previously this was six separate injected blocks, adding up to about 10.9 KB with no overall cap. Now it is combined into one summary, capped at 10 KB in total. Whenever a section gets cut off, a tail such as “64 more, names only” is added, so the AI knows something was not shown and will check the registry.

After a long conversation is compressed, the system adds a short card telling the AI where the earlier summary and the full conversation record are kept, when to go back to them, and which method to use to search first.

3. Rules loaded only when a file is touched

There are 37 rules. Each one declares at the top “which files it applies to”, for example “all slide decks”, “all proposal forms” or “all Android config files”. A rule is loaded only when the AI reads or changes a file that matches it.

This mechanism is built into Claude Code, but I measured its blind spots:

  • Inside the folder where the conversation started, matching rules were missed about 1.2% of the time;
  • For files outside that folder, the built-in mechanism loaded the rule 0 times out of 802 times it should have been loaded.

I often start a conversation in one folder and then edit files in another, so I added a small mechanism: when a file outside is found to match a rule that has not yet been loaded, the full text of the rule is sent in. It only fills the gaps the built-in mechanism leaves, and it does not block any action.

4. Lookup tables

The opening summary and the rules handle “what to look at first”; the lookup tables handle “which file to read next”:

Lookup table Question it answers
Playbook routing table (12 rows) What situation is this right now (dispatching work, wrapping up, handing over…), and which manual should be read?
Skill trigger dictionary Which skill should this sentence invoke? Which phrasings are easy to misroute?
“Which layer does this go in” reference Should a new preference, fact or practice be written into the instruction file, a manual, a skill, memory, or the notes vault?

The last one matters most: it tells the AI where to write something, so that it can find it when reading later.

I had originally written a rule in the instruction file: “When the user mentions something done before, check the records first.” Later, looking back over 640 conversation records, in about 130 cases where a search was due, the AI followed the rule only about 22% of the time. A rule written as text depends on the AI remembering it every time, and this kind of thing is the easiest to miss.

So I switched to a mechanism: when a question contains words such as “before”, “last time”, or the English “last time”, the system first runs a search (in under a second), attaches the candidate locations after the question, and labels them “these are literal-match candidates, not answers”. The AI then opens the files itself to verify.

6. Memory split across different folders

Claude Code’s long-term memory is “one set per working folder”: a conversation opened in folder A cannot see what was recorded in folder B. I have memory cards stored in 19 folders, so I generated a separate read-only master index that lists the card names and descriptions from every folder together, so that search can find them. The master index reads only the top of each card and never changes the memory in any folder.

Limits of this layer

  • Only about 5 KB of room is left for always-loaded content, so every additional always-loaded rule has to be paid for by giving up something else.
  • The “mention of ‘last time’ triggers a search” condition is literal matching. A sampled estimate found that when it fires, only a little over 40% of the time is the user actually asking about the past; the rest are false triggers. The cost of a false trigger is only a few extra lines of candidates to read, so for now I accept it.

Next post: Index and follow-the-trail search: the index only nominates, and the answers are read from the files