Turning your AI instruction file into a table of contents: how I keep CLAUDE.md and AGENTS.md short as they grow A developer described restructuring AI instruction files like CLAUDE.md and AGENTS.md into a table of contents that points to separate knowledge, skills, and task folders rather than holding all rules inline. The entry instruction file stays at 394 lines while the content behind it totals roughly 95,000 lines across about 230 knowledge files, task folders, specialist instructions, and skills, so the AI reads the bulk only when needed. The approach follows Claude Code documentation guidance to keep CLAUDE.md files under 200 lines and split file-specific rules into separately loaded instructions. Instruction files like CLAUDE.md and AGENTS.md keep getting longer the more you use them. Every time the AI repeats a mistake you add a rule, and every time you hand it a new kind of work you add a procedure. Before you know it, the file is several hundred lines long. I don't write the actual content into my instruction file. I give it only the job of a table of contents. The instruction file says only "what is where, and when to read it," and the rules and procedures themselves live in other files. In this article, based on the private repository I actually use, I go through how I split the table of contents from the content, how I write each line of the table of contents, and how I keep the files it points to in good shape. When you keep adding content to an instruction file, the first problem is that the important instructions get buried. The instruction file is read in every conversation, so the longer it gets, the more the AI has to read each time. You end up making it read rules that have nothing to do with the current task, every time, and the instructions you really want followed get lost among everything else. Next, the same thing tends to get written in two places. If you write the same rule in both the instruction file and a procedure document, fixing only one of them creates a conflict. The AI can't tell which one to trust, and sometimes it follows the older instruction. On top of that, people also lose track of what is written where. When the instruction file is long, fixing a rule starts with hunting for the place to fix. All of these come from packing both "directions" and "content" into a single file. If you separate the directions from the content and leave only the directions in the instruction file, these problems shrink considerably. The official Claude Code documentation also recommends keeping each CLAUDE.md file under 200 lines. Long files use more context and make instructions less likely to be followed, and the documentation says instructions that only apply to part of the code should be split into rules that are loaded only when working with those files. https://code.claude.com/docs/en/memory https://code.claude.com/docs/en/memory The official guidance shows that you should keep the file short and gives you mechanisms for splitting it. This article covers what comes after that: how to point to what you split out, and how to keep it in shape. I based it on a real repository that also covers work beyond coding. I keep my instruction files and knowledge for AI in a private repository. In this repository, there is only one entry instruction file that the AI reads at the start of a conversation, and the content is split into folders. I described what I write in the entry instruction file in this article: The folder structure looks like this: ai-agents/ ├── agents/ The entry instruction file, plus specialist instructions per organization and role ├── knowledge/ Accumulated knowledge facts, decisions, writing style rules, and so on ├── skills/ Skills that describe the steps for routine work ├── tasks/ One folder per frequent task procedure, request prompt, improvement log ├── docs/work-logs/ Work logs └── CHANGELOG.md Why the instructions and knowledge were changed The entry instruction file is currently 394 lines. Counting the content behind it, the knowledge folder has around 230 files and about 80,000 lines, the per-task folders about 11,000 lines, the specialist instructions about 2,300 lines, and the skills about 1,600 lines. If I had written all of that into the entry file, the AI would be reading close to 100,000 lines in every conversation. The entry file is less than 0.5% of the whole, and the AI reads the rest only when it needs it. I split the folders by how the AI uses what is in them. Instructions on how to behave for each organization or role go in the specialist instructions folder, facts and decisions that come up in conversation go in the knowledge folder, and how to carry out routine work goes in the skills folder. For frequent tasks, the procedure, the request prompt, and the improvement log are kept together in one folder per task. Because there is a rule for where things go, I don't have to think hard when adding something new. I am careful not to add too many kinds of places. I used to have a separate folder that collected frequently used request prompts. But once I started putting request prompts in the per-task folders as well, the prompts for the same task ended up split across two folders. When I reviewed the whole repository in May 2026, I retired the prompt folder and let the per-task folders and skills absorb its role. With fewer kinds of places, the table of contents stays short too. This split applies, to my own repository, the division of roles among instructions for AI that I laid out in an earlier article overall instructions, the steps for routine work, and detailed rules such as design and writing style . In the entry instruction file, I list each file or folder that holds rules or procedures, one line each, with where it lives. For the per-task folders, it looks like this: - tasks/