# Repository memory

# Repository memory

A good human reviewer knows the codebase. inline builds that knowledge automatically: after each substantive review it distills what it learned into a small, durable **repo profile**, and it re-reads that profile at the start of every future review.

> Memory captures *implicit* knowledge inline discovered on its own — how this codebase is shaped and where it's dangerous. [Learnings](./learnings.html), by contrast, capture *explicit* rules a human taught it. The two are separate on purpose.

## What it holds

The profile is Markdown with exactly four sections:

```markdown
## Architecture
How the system is laid out; the major modules and how they relate.

## Conventions
Patterns this codebase follows that a reviewer should respect.

## Fragile areas
Code that breaks in non-obvious ways; where to tread carefully.

## Gotchas
Surprises — footguns, implicit contracts, historical scar tissue.
```

It stays small on purpose — capped at a few thousand characters. It holds only durable knowledge: no PR-specific facts, no generic best practices that apply to any codebase. If it wouldn't help review the *next* PR, it doesn't belong.

## How it's built

- **Absorb (incremental).** After each substantive review, a cheap model call folds that review's summary, posted findings, and changed paths into the existing profile. The inputs are tokens already paid for during the review, so absorbing is nearly free. This runs best-effort at the end of the pipeline — if it fails, the review is unaffected.
- **Rebuild (full).** The portal's **Regenerate** button rebuilds the profile from scratch off the repo's most recent substantive reviews.

Each profile tracks how many reviews it has absorbed, its cumulative cost, and when it was last updated. A profile can be hand-edited in the portal; once a human edits it, that's recorded so you know it's no longer purely agent-maintained.

## Where it's used

The profile is injected into the review under a **Codebase profile** heading, alongside the diff rather than in the cached system prefix — so it can change per review without busting the [prompt cache](./review-cost.html#prompt-caching). The deep-review agent reads it before it starts reasoning about the diff, so it arrives already knowing the terrain.

## Controls

- **Enable/disable** per repo (default on).
- **Regenerate** to rebuild from recent reviews.
- **Edit** the profile text directly in the portal.
