# Per-repo architecture docs for agents A short doc at each repo root that lets an agent start work correctly without reading the whole tree or guessing. One per repository, written from measured structure. ## Why per repo and not one workspace guide A repo nested under a plain parent directory starts its own context chain at its own root, so the parent workspace guide is never loaded from inside it. Coverage at the workspace level says nothing about coverage inside a project. ## Gather evidence before writing a single line Do all of this first; the doc is a report of findings, not a plan. 1. Walk the repo two levels deep with build/vendor directories pruned (`.git`, `node_modules`, `build`, `.dart_tool`, `Pods`, `__pycache__`, `.venv`), and record which directories hold real source. 2. Read the manifest — `package.json` scripts and dependencies, `pubspec.yaml`, `manifest.json` — and take run/test commands from it verbatim. Never invent a command that is not declared somewhere. 3. List the root-level markdown already present. Existing `README.md`, `PLAN.md`, design-system and storyboard files are the authority; the new doc orders and points at them, it does not restate their content. 4. Check whether a notes-vault folder for this project exists **and has content**. A folder of empty template files is not documentation. 5. Note whether the directory is actually a git repository. Several working project folders are not, and a doc that assumes branches and commits for them is wrong. ## Section order Keep the same order in every repo so an agent learns one shape: 1. One-paragraph statement of what the project is, plus the standing negative constraints that define it (no backend, no cloud sync, no build step). 2. **Code entry** — which directory holds what, in the order a newcomer needs it. 3. **Run / test** — the real commands, copied from the manifest. 4. **Required reading order**, when the repo has several docs. Name which file must be read *before* writing code and say so explicitly; end with "open only what this task needs, do not load them all." 5. **Hard constraints** — the design and safety rules that outlive any one task. 6. **Where the project knowledge lives** — vault path with the actual file names, or an explicit statement that no note exists. 7. The approval line for commit/push/PR/merge/delete and a pointer to the workspace guide. ## Pitfalls - **Never write a vault pointer you have not confirmed resolves to real content.** Write "no vault note found; this repo is the source of truth" instead — a dangling pointer sends the next agent looking for guidance that does not exist, which is worse than silence. - **An empty repo gets a doc that forbids invention.** When the repo holds only `.git` and the vault note is a blank template, the honest content is: status is idea-stage, the purpose is not written down anywhere, ask the user, and choose no framework or platform without approval. Do not let a plausible-sounding summary become the de facto spec. - **Guard against neighbour-project bleed for similarly named projects.** When two projects share a theme or a name fragment, state in the doc that they are separate and that the other one's decisions do not transfer; otherwise an agent will carry settled constraints across and quietly change the wrong product. - **Do not copy the content of the docs you point at.** Duplicated design rules drift from the source the first time the source is edited; point to the file and name what it governs. - **Restate hard safety and determinism rules in every repo they apply to**, even though duplication is otherwise discouraged — a rule stated only in a sibling repo cannot forbid anything in this one. - **Mark non-git project folders as such** and do not propose initializing version control as a side effect of documenting them. - **Record the as-of date for any "empty" or "not found" claim** so a later agent re-checks instead of trusting a stale absence.