Course outline
The CTO's playbook for AI coding agents · Module 3: Spec-driven development at scale
Shared context across the org
Specs say what to build; shared context says how your org builds. Layer repo instruction files, ADRs, conventions and golden paths, give each layer an owner, and keep it fresh.
Lesson 12 / 20 · ⏱ 8 min
A spec tells an agent what this change should do. It shouldn’t have to tell it that you use structured logging, never call the billing database directly, and deploy behind feature flags. That knowledge applies to every change, so it belongs in shared context: written once, owned by someone, and loaded automatically wherever agents work.
Without it, each team’s agents rediscover your standards by trial and error, and each rediscovery is slightly different. That’s how you get ten flavors of the same pattern.
Four layers of context
| Layer | Typical artifacts | Owner |
|---|---|---|
| Org | Engineering principles, security and data rules, approved stacks, API style guide | Platform or architecture group |
| Domain | Glossary, domain ADRs, service contracts, shared libraries to prefer | Domain tech lead |
| Repo | Instruction file for agents, build and test commands, folder map, local do and don’t | Repo code owners |
| Task | The approved spec, relevant files, a reference example | Spec author |
The repo layer is where most teams start, with an instruction file at the root. Our AGENTS.md starter template covers the format; the CTO’s job is making sure the layers above it exist and that repo files link to them instead of copying them.
The building blocks
- Architecture decision records. Short, dated, one decision each: context, decision, consequences. Agents are good at following a rule; ADRs give them the reason, which stops them “improving” a deliberate trade-off.
- Golden paths. A blessed, working template for the common things: a new service, a new endpoint, a new job. An agent that copies a golden path produces code that already passes your checks. It’s the highest-leverage context you can give.
- Machine-checkable conventions. Anything that can be a linter rule, a type, a schema or a CI check should be. Prose is a suggestion; a failing check is an instruction the agent can’t miss.
- A distribution mechanism. Shared files pulled into each repo, a template repository, or a central location your agents are configured to read. The method matters less than the rule: one source, no forks.
Keeping it fresh
- Every file has an owner and a review date in its header. Past the date, it gets flagged.
- Update context in the same PR as the change. Migrating to a new client? The PR also edits the instruction file and the golden path. Make it a review checklist item.
- Treat agent mistakes as context bugs. When an agent repeats a mistake across teams, the fix is a line in shared context or a new check, not a sterner prompt.
- Keep it short. Context competes for the agent’s attention. Prune quarterly; if a rule hasn’t mattered in a year, delete it or turn it into a check.
Where is your org today?
📊 Shared context maturity
1. Most active repos have an agent instruction file with working build and test commands.
Not at allFully true2. Org-wide standards live in one place, and repo files link to them instead of copying them.
Not at allFully true3. Key architecture decisions are recorded as short ADRs that agents can read.
Not at allFully true4. Golden-path templates exist for our most common kinds of change.
Not at allFully true5. Our important conventions are enforced by linters, types or CI, not just prose.
Not at allFully true6. Each context file has a named owner and a review date.
Not at allFully true7. Context files are updated in the same PR as the changes that make them stale.
Not at allFully true8. Repeated agent mistakes are fixed by updating shared context or adding a check.
Not at allFully true
For the developer-level view of instruction files, see repo instruction files in the Agentic Engineering course.
Before you move on
✅ Key takeaways
0 / 5 completed