Make your repository understandable to AI

Clear boundaries tell an agent where it may go, but not how your codebase works.

Document what agents cannot infer

Stable context that is hard to infer belongs in guidance; other context can be inspected in code.
Figure 5. Write down what is stable and hard to infer; leave cheap facts in code.

An agent begins with the files and systems it can access. Everything else is invisible until a tool or permission exposes it. It can search thousands of source files and still miss the convention that every engineer on the team learned months ago.

Now picture that search happening at the start of every task. The agent reads package manifests, traces imports, scans component directories, and slowly reconstructs the architecture. It may reach the right answer, but the team pays for the same discovery in time and tokens again and again.

Write down the knowledge that changes slowly and costs a lot to recover:

  • Architectural layers and allowed dependency directions
  • Coding rules and ownership boundaries
  • Generated or protected files
  • Design-system usage and package-creation workflows
  • Known traps that look reasonable in source code

Leave cheap facts in the code. Package scripts, a small directory, an obvious export list, or a local implementation detail may take less effort to inspect than to document and maintain. In a monorepo, the root and relevant package manifests usually reveal ordinary build and test commands. Document a command when the workflow is unusual, multi-step, environment-specific, or hazardous.

Inspect the code when needed

Easy to find and likely to change Package scripts Obvious exports Local implementation details

Write it in agent guidance

Hard to infer and important to get right Architecture boundaries Protected or generated files Hidden configuration and known traps

There is a useful database analogy here. Repository guidance works like a database index: it is useful when it saves the same time-consuming search again and again. If a detail is quick to find in the code, documenting it may take more effort to maintain than it saves.

The guidance should also name what source code cannot reveal. A build pipeline may import configuration stored elsewhere. Generated files may look editable. A local fallback may hide a failed remote path. These are exactly the places where a plausible reading of the repository produces the wrong answer.

Keep module guidance local

For modules with costly context, keep a short manual beside the code: responsibilities, public entry points, state and timers, invariants, and known gaps. Route agents to the manuals for the modules they touch. Update affected manuals in the same change; leave obvious exports and implementation details in source.

Preserve earlier decisions with ADRs

Teams can keep that history in a registry of architecture decision records, or ADRs, just as they did when developers wrote every change by hand. Store the registry in the repository or another place agents can access. It gives future agents a chance to reflect on earlier choices before planning related work.

Without the rationale, an intentional compatibility layer can look like duplication. An agent may remove it during a cleanup, or bring back an approach the team rejected months ago because the current code no longer explains the decision. Record the status of each ADR and link superseded decisions to their replacements so old guidance does not keep directing new work.

A skill does not need to hold every piece of guidance. Repository knowledge that an agent only needs to consult can stay behind the instruction router. Put each rule in one canonical place, then link to it. Duplicating the same guidance across skills and repository documents almost guarantees that one copy will age first.

Give agents access to external knowledge

Some of the facts an agent needs will live outside the repository. Architecture decisions may sit in Notion, product rules in Confluence, and operational procedures somewhere else again.

That access can come through a service's command-line interface, an MCP server, a plugin or app built for the agent harness, or a controlled export. Authentication follows the integration: command-line tools and MCP servers may use tokens, OAuth, or credentials supplied by the environment. Plugins can package setup and discovery for one harness, while exports exchange live access for a smaller snapshot that is easier to inspect.

Compare the options by the data they expose, the actions they permit, how credentials are stored, whether access can be read-only, what gets logged, and who must maintain the integration. Section 9 covers those boundaries in detail.

Connect design intent to shared components

Figma components resolve through a catalog to code, with explicit routes for missing tokens or matches.
Figure 6. Design components resolve through a catalog; gaps are recorded, not invented.

A design file may show the right component while the repository holds its implementation. Without a bridge between them, an agent can easily recreate a button, input, modal, or spacing token that already exists.

Maintain a machine-readable catalog with component names, import paths, supported variants, tokens, usage constraints, and links to the corresponding design-tool components. In Figma, for example, the mapping should connect design components and variants to their code equivalents.

Choose an authoritative source for design tokens and keep the mapping synchronized with it. When a design asks for a color, spacing value, type style, or radius that has no approved token, the agent should record the mismatch and ask for a design-system decision before adding code. A raw value may look harmless in one component and still become the start of design drift. Section 5 turns that rule into a deterministic check.

A UI task can then take the short route. The agent sees a design component, resolves it to the shared code component, checks the supported props, and imports it. Repository exploration begins only when the catalog has no match. The same catalog can flag deprecated components and platform-specific gaps.

The task and instruction router select relevant sources of context.

Route context on demand: select the relevant module manual, ADR, external source, or design-to-code catalog.

Follow relevant routes on demand. The router gives source locations and retrieval instructions; inspect cheap facts in code and keep initial context small.