A simple guide to prepping your project docs so your AI agent reads the right files, follows the links, and stops burning tokens.
TL;DR: give every doc a clear purpose, a unique ID, and links that say why it’s connected to other docs. Point your agent to one map. It reads less, finds more, and spends fewer tokens. That’s the whole vibe.
Also: there’s no mandatory folder structure for this. Your project, your rules. This guide shows how docs connect to each other, so you can design whatever structure fits you (section 3).
Who’s this for? Engineers, freshers, PMs: basically anyone who works with AI agents. No database or AI background needed, promise. (New to the slang? There’s a decoder at the end.)
Short on time? PMs: sections 1, 2, 5, 7, 8 and 9. Engineers setting this up: sections 3, 6, 8 and 12. Freshers: read it top to bottom; it builds up step by step.
1. The problem: your agent is lowkey lost
Here’s the thing. AI coding agents like Claude Code and GitHub Copilot start every session with zero memory of your project. It’s like a new joiner on day one, every single day. They learn your project by reading files, and every file they read costs tokens, the units AI models read and charge by. More tokens = more time + more money.
Without a map, the agent does what we all do: it searches. Ask it to “add a task assignment feature” and it searches for “assign”. It finds role assignments, variable assignments, a random meeting note from two years ago… opens a dozen files, and can still miss the one that matters: a bug report about task history that never even says “assign”. Big L.
Search finds words. It can’t find connections. The fix? Connect your docs, so the agent can follow links instead of guessing.
2. The big idea: docs as linked tables
If you’ve used a database, you already get this. If you haven’t, no stress. We’re not building a database; we’re just borrowing two of its best habits: every row has a unique ID, and rows point to each other by ID.
| In a database | In your docs | Example |
|---|---|---|
| Table | A type of doc | Requirements, designs, tests |
| Row | One doc | The “Task assignment” requirement |
| Primary key | The doc’s unique ID | REQ-004 |
| Foreign key | A link to another doc’s ID | implements: [REQ-004] |
| Index | One file that lists every doc | docs/index.md |
| Join | Following a link to a related doc | From a requirement to its design |
3. Your project, your rules: design your own structure
Real talk: there’s no universal, mandatory folder structure for AI agent docs. No required file format, no official naming scheme. Claude Code, GitHub Copilot and friends read whatever instruction file and docs you point them to. The folders, ID prefixes and link words in this guide are examples, not laws. Rename them, add more, drop some; do whatever fits your project and team. What this guide really explains is how docs connect to each other, and that works with any layout.
Any of these layouts can work:
| Layout | Looks like | Good for |
|---|---|---|
| Docs grouped by type |
docs/requirements/REQ-004-task-assignment.md,
docs/design/DESIGN-007-task-assignment.md
|
Most projects |
| Docs kept with each feature |
features/task-assignment/REQ-004.md,
features/task-assignment/DESIGN-007.md
|
Teams that work feature by feature |
| One file per “table” |
docs/employee_details.md, with one section per employee
|
Small reference data, like the example/ folder
|
You decide:
- folder names and layout;
- how big each file is: one doc per file, or one file with a section per item;
- the ID style:
REQ-004,FEAT-12,EMP-001, or anything else that’s unique and never changes; - the link words;
- how the instructions are split: one file at the root, or extra files for specific folders. Claude Code also reads a
CLAUDE.mdinside a subfolder when it works in that folder, and GitHub Copilot can apply instruction files to matching paths only (.github/instructions/*.instructions.md). That way, rules for one area load only when the agent is working in that area.
The non-negotiables, whatever you choose:
- The agent has one clear starting point: an instruction file that points to the map.
- Every doc has one purpose, a unique ID and a one-line summary.
- Links use IDs and say why two docs are connected.
- One map (an index) lists every doc.
- The instruction file explains your structure, so the agent, and every new teammate, can follow it.
- The docs live where the agent can read them. Requirements in Jira or Confluence are invisible to the agent unless you connect those tools (for example through MCP, a standard way to plug tools into AI agents) or keep the key docs in the repo.
4. Meet the docs (and how they connect)
Here’s a common set of project docs. Pick the ones your project needs, and add your own (API specs, runbooks, decision records, you name it).
| Doc type | ID | Answers the question |
|---|---|---|
| Requirement | REQ-001 |
What must we build, and how do we know it’s done? |
| Architecture | ARCH-001 |
How is the whole system organised? Which rules apply everywhere? |
| Design | DESIGN-001 |
How does this feature work: API, data, flow? |
| Implementation | IMPL-001 |
How was it built, and where is the code? |
| Source code | file path | What actually runs |
| QA (tests) | QA-001 |
How do we check that it works? |
| Bug | BUG-001 |
What went wrong, and where? |
| Release | REL-001 |
What was shipped, when, and how? |
A feature moves through these docs in order, like a relay race. A bug points back to the requirement it breaks and the code it lives in:
REQ-001 -> ARCH-001 -> DESIGN-001 -> IMPL-001 -> QA-001 -> REL-001
BUG-001 -> REQ-001 + IMPL-001 Here’s the same flow for one real feature, task assignment. Each line also shows the links that doc declares in its header (link words are explained in Step 3 of section 6):
And here’s one way to lay these docs out in a project. It’s just an example; your folders can look different (section 3).
Project/
│
├── CLAUDE.md ← short instructions for Claude Code; points to docs/index.md
├── AGENTS.md ← the same idea for other agents (optional)
├── .github/
│ └── copilot-instructions.md ← the same idea for GitHub Copilot (optional)
│
├── docs/
│ ├── index.md ← the map: every doc, one line each
│ ├── requirements/
│ │ ├── REQ-001-project-membership.md
│ │ ├── REQ-002-task-management.md
│ │ └── REQ-004-task-assignment.md
│ ├── architecture/
│ │ └── ARCH-001-application-architecture.md
│ ├── design/
│ │ ├── DESIGN-003-task-model-and-history.md
│ │ └── DESIGN-007-task-assignment.md
│ ├── implementation/
│ │ ├── IMPL-003-task-module.md
│ │ └── IMPL-009-task-assignment-module.md
│ ├── qa/
│ │ ├── QA-005-task-management-tests.md
│ │ └── QA-011-task-assignment-tests.md
│ ├── bugs/
│ │ └── BUG-015-history-lost-on-concurrent-edits.md
│ └── releases/
│ └── REL-007-release-1.5.md
│
├── src/
│ └── tasks/ ← code listed in IMPL-003
│ ├── CLAUDE.md ← rules for this folder only (optional)
│ └── assignment/ ← code listed in IMPL-009
│
├── tests/
│ └── tasks/
│ └── assignment.test.ts ← test file listed in QA-011
│
└── tools/
└── docgraph.py ← builds docs/index.md (optional)
5. Real test: what the agent actually reads
Theory is cool, but let’s see it IRL. The example/ folder next to this article is a tiny project with this structure:
This is the “one file per table” layout from section 3: each file is a table, and each
##section inside it is a row.CLAUDE.mdtells the agent which file to read for each kind of question. For example: employee questions →docs/employee_details.md, and if an employee refers to a company, also read the company document. see full here https://github.com/venuthomas/AIAgentDocumentation/blob/1f38ef44de15ebb35a300b013c843b4e5cf67626/CLAUDE.mddocs/company_details.mddescribes two companies.
see full here: https://github.com/venuthomas/AIAgentDocumentation/blob/1f38ef44de15ebb35a300b013c843b4e5cf67626/docs/company_details.mddocs/employee_details.mddescribes two employees. Each one names a company and links to it, for example[NeST Digital](company_details.md#nest-digital).
see full here https://github.com/venuthomas/AIAgentDocumentation/blob/1f38ef44de15ebb35a300b013c843b4e5cf67626/docs/employee_details.md
Here’s how the files used in this test connect:
CLAUDE.md start here: routes each question to the right doc
│
├──▶ company_details.md companies
└──▶ employee_details.md employees
employee_details.md ──works at──▶ company_details.md
(Company: NeST Digital → #nest-digital)
Think of these as two tables, employees and companies, connected by the company link. We asked Claude Code (Opus 5.5) four questions, each in a fresh session. Here’s the tea.
Question 1: “company list pls”. Straight to the company file. Nothing else. Clean.
Question 2: “Where does Venu work?” This one needs the employee and their company, so the agent grabs both files together, in one step, and cites both as sources. (The terminal says “Read 1 file” because one command read both files; the session log confirms it.)
Question 3: “I want only the names of all employees.” Names live in the employee file, so the agent reads only that file. It doesn’t follow the company links, because it needs nothing over there. Efficient.
Question 4: “i want all employees”. “All” includes each employee’s company details, so the agent reads the employee file, spots the company links, and follows them to the company file too. And instead of making stuff up, it tells you what the docs don’t have (employee ID, manager, start date). No cap, that’s a green flag.
So, what did we learn?
The agent follows a link only when the question needs what’s on the other side. Same docs, same rules: names only → one file; all details → two files. In database terms, question 3 reads one table and question 4 joins two.
Every extra step costs tokens. Like, a lot. Claude Code keeps a log of each session (under ~/.claude/projects/), showing what the agent read and how many tokens it used:
| Question | Files read | AI steps | Input tokens |
|---|---|---|---|
| “I want only the names of all employees.” | 1 | 2 | about 62,000 |
| “Where does Venu work?” | 2, together | 2 | about 62,000 |
| “i want all employees” | 2, one after the other | 3 | about 93,000 |
AI steps = how many times the model was called. The company file is tiny (under 100 tokens), yet reading it as a separate step added about 31,000 tokens. Wild, right? Here’s why: every time the model is called, it processes its whole working context again: its built-in instructions, tool descriptions, your CLAUDE.md and the conversation so far. Most of that is cached, which makes it cheaper, but not free. Meanwhile, reading two files together (question 2) cost the same as reading one.
So well-prepped docs save tokens in two ways: the agent skips files it doesn’t need, and an index lets it see in advance which files it does need, so it can grab them together. That’s the glow-up.
6. How to prepare agent docs: eight steps
Okay, here’s the playbook.
Step 1: Write a short instruction file (the starting point)
This is the first file the agent reads, on every single request: CLAUDE.md for Claude Code, .github/copilot-instructions.md for GitHub Copilot, and AGENTS.md for many other agents. Since it’s loaded every time, keep it short. Only what every task needs:
- where the map (index) is, and how your docs are organised;
- the rules for reading and updating docs;
- how to build and test the project, plus the few coding rules that always apply.
Don’t paste your whole documentation in there; point to it.
The example/ folder uses a list of routes (“for employee questions, read this file”). Totally fine for a few docs. But the list grows with every new doc, and every line gets loaded on every request. For a real project, point to an index instead:
## Project docs (read before changing code)
- Start with `docs/index.md`. Search it before searching other files.
- Doc IDs: REQ requirement, ARCH architecture, DESIGN design, IMPL implementation,
QA tests, BUG bug, REL release.
- Each doc's header lists its links (implements, verifies, found_in, ...).
Before coding:
1. Find the requirement (REQ) for the task. If there isn't one, ask.
2. Follow its links: design, architecture rules, implementation, code, tests, open bugs.
3. Read only what the task needs. If you need several files, read them together.
After coding:
4. Update the docs you affected, and their links.
5. Report missing, outdated or conflicting docs. Don't guess.
Step 2: Give every doc an ID and a short header
Put a small header at the top of each doc (the fancy name is front matter). Think of it as the doc’s bio: the agent reads just these few lines and decides whether it needs the rest of the file.
---
id: DESIGN-007
title: Task assignment design
status: approved # draft | approved | deprecated
summary: How a task is assigned to one project member (API, data, notification).
implements: [REQ-004]
conforms_to: [ARCH-001]
---
Three rules: an ID never changes and is never reused; the file name starts with the ID (DESIGN-007-task-assignment.md); the summary fits on one line. Optional fields like owner and last_reviewed (a date) tell people who to ask, and help spot outdated docs.
Step 3: Link docs by ID, and say why
A plain “see also” link tells the agent nothing. A link word tells it why two docs are connected, and so what a change will affect.
| Link word | From → to | Meaning |
|---|---|---|
depends_on |
any doc → same type | Needs this other doc |
implements |
design → requirement | This design builds that requirement |
conforms_to |
design → architecture | This design follows those rules |
realizes |
implementation → design | This code builds that design |
verifies |
tests → requirement or bug | These tests check that requirement, or that a fixed bug stays fixed |
covers |
tests → implementation | These tests run this code |
violates |
bug → requirement | This bug breaks that requirement |
found_in |
bug → implementation | The bug is in this code |
ships |
release → requirement or bug | This release delivers it |
Put the link in the newer doc, pointing back to the older one. The design says implements: [REQ-004]; the requirement doesn’t need to list its designs, because the index shows links both ways.
Step 4: Connect docs to the code
Implementation docs list the code they describe, and test docs list their test files:
---
id: IMPL-009
title: Task assignment module
status: done
summary: Assign and unassign service, API controller and notification.
realizes: [DESIGN-007]
code: [src/tasks/assignment/]
---
Now the agent can go both ways: from a requirement to the code it must change, and from a file in an error message back to the requirement and tests behind it.
Step 5: Keep one index (the map)
docs/index.md lists every doc in one place, one line each. Think of it as the table of contents for your whole project:
| ID | Title | Summary | Links |
|----|-------|---------|-------|
| REQ-004 | Task assignment | Editors assign each task to one member, who is notified | depends_on REQ-001, REQ-002 |
| DESIGN-007 | Task assignment design | API, data and notification for assignment | implements REQ-004; conforms_to ARCH-001 |
| QA-011 | Task assignment tests | Six test cases for REQ-004 | verifies REQ-004 |
| BUG-015 | History entry lost | Two quick edits save only one history entry | violates REQ-002; found_in IMPL-003 |
Search this one file for REQ-004 and you get the requirement plus every doc linked to it, in one step. Small project? Keep the index by hand. Bigger project? Generate it: tools/docgraph.py in this folder builds it from the doc headers and flags broken links and missing tests.
Step 6: Keep docs focused
- One topic per doc, with clear headings. Then the agent can read one section instead of the whole file.
- Each fact in one place. If the error codes are listed in the design, the test doc links to the design instead of copying the list. Copies drift apart, the agent can’t tell which one is right, and it pays tokens to read the same thing twice.
- Be specific. Write “rejected with error 422”, not “handled properly”, and say what’s out of scope. The agent takes what you write literally.
- Write the why, not just the what. The code already shows what it does. Docs should hold what the code can’t: the requirement, the decisions and the rules.
- Prefer text over images. Agents can’t search inside a screenshot or a diagram image, and images cost more tokens than text. Put key facts in text; keep images as extras.
Step 7: Keep docs current and safe
- Update docs in the same change as the code, and review doc changes like code changes.
- Mark old docs
deprecatedand point to the replacement. Outdated docs living rent-free in your repo will confuse the agent. - Never put passwords, API keys or personal data in docs or instruction files. Agents read them, and they usually get committed to the repo. Huge red flag.
Step 8: Test with real questions
Ask the agent the questions your team actually asks, then check which files it read, like we did in section 5. If it searches, reads too much or misses a doc, fix the summary, the link or the instruction file, not the question. Basically, vibe check your docs.
7. How the agent uses your docs
- Reads the instruction file.
- Opens the index, instead of searching every file.
- Finds the requirement for the task and reads its acceptance criteria: what “done” means.
- Follows the links to the design and the architecture rules.
- Finds the implementation doc and the code files it lists.
- Checks the related tests, open bugs and release notes.
- Lists what the change affects before writing any code.
- Updates the docs and links after the change.
Tip for PMs: the requirement is where the agent starts. A requirement with an ID and clear acceptance criteria is the most useful thing you can give an agent. It’s the main character of the whole story.
Example: “Add a task assignment feature”
The agent doesn’t jump straight into coding. It follows the links first:
docs/index.md → REQ-004 Task assignment (approved)
REQ-004 → 5 acceptance criteria, e.g. "the assignee is notified within 60 seconds"
DESIGN-007 → new API endpoints, an assignee field on Task, a notification event
ARCH-001 → rule: database changes must be backward compatible
DESIGN-003 → the Task model it extends → IMPL-003 → code in src/tasks/
QA-011, QA-005 → new test cases to write; existing task tests to rerun
BUG-015 (open) → task history can lose an entry: a risk for "every change appears in history"
REL-007 → next release: new features ship behind a feature flag
A word search for “assign” would never have found BUG-015 or the database rule. The links did. That’s a W.
After coding, the agent updates the docs: it creates IMPL-009 with realizes: [DESIGN-007] and the new code path, links the new tests in QA-011, adds REQ-004 to REL-007, and updates the index.
8. How to ask: example prompts
Docs ready? Now let’s talk to the agent. The secret sauce: name the ID. “Implement REQ-004” gives the agent a starting point. “Add assignment stuff” sends it on a scavenger hunt.
Your instruction file already holds the rules (trace first, update docs after), so prompts can stay short. Here are copy-paste examples.
Implement a feature
Short version, when your instruction file does the heavy lifting:
Implement REQ-004 (task assignment).
Detailed version, for bigger or riskier work:
Implement REQ-004 (task assignment).
Before coding:
- Start from docs/index.md and follow the links from REQ-004: design, architecture rules,
implementation docs, code, tests, open bugs and the planned release.
- Show me the trace (doc IDs) and your plan, then wait for my OK.
While coding:
- Follow DESIGN-007. If the design needs to change, stop and ask me.
- Meet every acceptance criterion in REQ-004.
When done:
- Add tests for each acceptance criterion and run all related tests.
- Create an IMPL doc (next free ID) with its code paths, link the tests in QA-011,
and add REQ-004 to REL-007.
- Update docs/index.md, and list anything missing, outdated or conflicting.
Fix a bug
Fix BUG-015 (task history loses an entry when two edits happen in the same second).
- Read BUG-015, then follow its links: the requirement it breaks (REQ-002)
and the implementation it was found in (IMPL-003, code in src/tasks/).
- First write a test that reproduces the bug and fails.
- Find the root cause and fix it with the smallest safe change. Don't refactor unrelated code.
- Run the new test and the tests linked to IMPL-003 (QA-005).
- Update BUG-015 with the root cause and the fix, and set its status to resolved.
- Link the new test in a QA doc with verifies: [BUG-015], then update docs/index.md.
Writing the failing test first is the key move: it proves the bug is real, and then proves the fix works.
Write a new requirement
PMs, this one’s yours.
Draft a new requirement: task due-date reminders.
- Check docs/index.md first. Is there already a requirement for this,
or ones it depends on (for example REQ-004)?
- Use the next free REQ ID and the same header as other requirements,
with status: draft.
- Write clear, testable acceptance criteria (AC-1, AC-2, ...) and say what's out of scope.
- Add depends_on links to related requirements.
- List open questions for me instead of guessing.
- Don't write any code. Add the new requirement to docs/index.md.
Bonus: check what a requirement change affects
Before you change a requirement, ask for the impact first:
REQ-004 is changing: a task can now have several assignees.
Don't change anything yet. Using the links in docs/index.md, list every doc,
code path and test this affects, grouped as: must change, must review, must re-test.
Mid prompt vs. better prompt
| Mid prompt | Better prompt |
|---|---|
| “add assignment stuff” | “Implement REQ-004. Show me the trace and plan first.” |
| “history is broken, fix it” | “Fix BUG-015. Write a failing test first.” |
| “we need reminders” | “Draft a requirement for due-date reminders, status: draft. No code.” |
Prompt tips:
- Name the ID. It’s the agent’s starting point.
- For big tasks, ask for the trace and plan first. You catch wrong assumptions before any code is written.
- Say what “done” means: tests pass, docs updated.
- Keep the scope tight: “smallest safe change”, “don’t refactor unrelated code”.
- Don’t repeat your rules in every prompt. They already live in the instruction file, which the agent reads on every request. Repeating them just burns tokens.
- One task per session. Start fresh when you switch tasks (
/clearin Claude Code, a new chat in Copilot). Every step re-processes the whole conversation, remember? - Review what it did. Check the trace, the code and the doc updates, like you’d review a teammate’s pull request.
9. Questions the links can answer
Once your docs are linked, the agent can answer questions like these without searching the whole repo:
| Question | How the agent finds the answer |
|---|---|
| Which requirement does this code implement? | Code path → IMPL doc → DESIGN → REQ |
| Which code does this requirement affect? | REQ → DESIGN → IMPL → code paths |
| Which APIs and data does this feature touch? | The DESIGN doc’s header and API section |
| Which tests check this feature? | Test docs that verify the REQ |
| If the requirement changes, what needs review? | Every doc that links to it, directly or through other docs |
| A bug is reported: what does it relate to? | Code path from the error → IMPL → REQ; record a BUG doc with both links |
| Which tests must run after a change? | Changed code → IMPL → test docs that cover it |
10. Five ideas people often mix up
| Idea | Simple meaning | Done with |
|---|---|---|
| Navigation | How do I get to the related doc? | A Markdown link |
| Identification | Which exact doc is this? | An ID such as REQ-004 |
| Relationship | Why are these docs connected? | A link word such as implements |
| Traceability | Is this requirement designed, built, tested and released? | Following the chain from REQ to REL |
| Impact analysis | If this changes, what else must change? | Following the links backwards |
11. Keeping your docs healthy
| Problem | Example | What to do |
|---|---|---|
| Broken link | Points to REQ-04, or to a file that was moved |
Fix it; check links automatically |
| Missing link | A requirement with no test doc | Add the test doc and link it |
| Missing doc | A requirement mentions a payment service, but no doc describes it | Write it, or let the agent report the gap |
| Outdated doc | The code changed, but the doc didn’t | Update docs in the same change as the code |
| Conflict | The design says error 422; the test expects 403 | The agent reports both; a human decides |
When docs disagree, the agent shouldn’t quietly pick a side. Simple rule: the requirement decides what the system must do, the design decides how, and the code shows what it does today. Still unclear? Ask a human.
12. Checklist
- One short instruction file: where the map is, the doc rules, how to build and test
- A map (
docs/index.md) that lists every doc - Docs live where the agent can read them (in the repo, or connected)
- Every doc has an ID, a title, a status and a one-line summary
- Docs link to each other by ID, with a link word
- Implementation and test docs list their code and test files
- One topic per doc, and each fact in one place
- No passwords, keys or personal data in docs
- Docs updated in the same change as the code; old docs marked
deprecated - Tested with real questions: the agent reads the right files, and only those
- Prompts name the doc ID and say what “done” means
Start small: add IDs and summaries to the docs you already have, write a short instruction file, and keep an index. Your folders and names can look totally different from this guide, and that’s fine. What matters is that every doc has a purpose, an ID and links that say why. Then the agent reads less, finds more, and changes things more safely. A W for everyone.