Reference Skeleton
Anchor coding agents to a small working reference app that shows how the team builds things.
Problem
In a new system, agents have no existing code to imitate, so each session invents its own structure, error handling and naming. Written conventions help, but agents follow working examples far more reliably than prose. The first weeks of a greenfield project set patterns that are expensive to undo.
- Agents copy what they see.
- Conventions written as prose are ambiguous.
- A reference that isn’t maintained misleads.
- Too rich a reference turns into a framework nobody understands.
Solution
Build a small, compilable reference app that shows the team’s way of handling each recurring concern: one request path end to end, one background job, error handling, logging, configuration, tests at each level, and the CI pipeline. Agents can draft it, but people review it closely, because everything built later copies it. Keep it running and tested in CI. The memory file tells agents to follow it (“new endpoints follow /reference”), and new services are scaffolded from it. When a convention changes, change the reference first, and later work follows.
Diagram
One small, reviewed example sets the pattern; every agent session copies working code instead of guessing from prose.
When to use
Use it when
- Greenfield systems and new services
- Several teams or many agents building similar components
- Conventions drift between agent sessions
- Platform teams offering a golden path
Avoid it when
- Mature codebases with consistent examples to copy already
- One-off prototypes
- Teams that can't keep the reference compiling
Trade-offs
Gains
- Consistent structure across many agent-built components
- Reviews focus on logic, not style and structure
- Conventions change in one place
Costs
- The reference needs an owner and upkeep
- Shortcuts in the reference get copied everywhere
- Too much in it slows understanding
Worked example
The Linkwatch team starts its new click-analytics service.
- ReferenceA 400-line service with one ingest endpoint, one queue consumer, structured logging, typed config, unit and integration tests, and CI.
- Memory file“New endpoints and consumers follow
/reference: copy its structure and tests.” - BuildAgents add 6 endpoints in a week. Structure is consistent, so reviewers spend their time on the logic.
- DriftOne agent pulls in a different logging library. The reviewer points to the reference and it’s replaced.
- ChangeThe team switches config libraries. The reference is updated first, and the next agent tasks follow it.
Failure modes
| Failure | Symptom | Mitigation |
|---|---|---|
| Rotting reference | Reference no longer builds, so agents ignore it | Keep it in CI and fix it like production code |
| Bloat | Reference grows into a framework | One minimal example per concern |
| Copied shortcuts | Demo hacks appear in production code | No shortcuts in the reference; it is production quality |
| Ignored reference | Agents still invent their own structure | Point to it in the memory file; reviewers enforce it |