A four-layer scheme for development with AI agents

A reference for teams bringing AI agents into large, long-lived projects with several people involved.

Why a layered scheme

The problem is not that agents write bad code. They write reasonably well. The problem shows up three months in, when nobody can reconstruct why the system does what it does, and the architectural decisions are buried in chat sessions that no longer exist.

The cause is always the same: one tool ended up covering responsibilities that should have been separate. The tracker holds the specification, the specification holds the task plan, the agent writes its own acceptance criteria, and the result is a system with no auditable source of truth.

This scheme separates four responsibilities and defines coupling rules between them. It is independent of which agent, which model, or which framework you use — those are details of a single layer, the most replaceable one.

Part 1 — The four layers

The four layers: intent with maximum authority, coordination, execution, and verification with veto power 1 Intent The contract: what the system must do and why. Lives in the repo. Human owner. MAXIMUM AUTHORITY outlives the project 2 Coordination Who does what, in what order. Lives outside the repo. References the contract, never copies it. outlives the sprint 3 Execution Translating contract into diff. Deliberately disposable. When in doubt, it does not guess. outlives the session 4 Verification Proof that the diff satisfies the contract. Lives in the repo, next to the code. VETO POWER outlives the project verification corrects the contract
Authority flows down; correction flows up. Layer 3 is the only disposable one, and it is also the only one whose tooling changes every six months.

Layer 1 · Intent

What it is: the contract. What the system must do and why.

Two distinct artifacts:

  • Current state — what the system does today. Descriptive and always true.
  • Change proposal — the delta you want to introduce. Prescriptive and temporary.

Confusing them is the most common mistake. Mix both into one document and in six months you will not be able to tell what the system does from what somebody once proposed it should do.

Current state versus change proposal: descriptive and permanent versus prescriptive and temporary Current state What the system does TODAY · descriptive · always true · permanent to know what it does, read here Change proposal The delta you want to introduce · prescriptive · temporary ADDED MODIFIED REMOVED lives only until the cycle closes absorbed On closing the cycle: the delta is absorbed into the current state and the proposal is archived. This is the step nearly everyone skips, and without it layer 1 becomes a graveyard of contradictory proposals.
Two documents, two natures. Mixing them is what makes it impossible, six months later, to tell whether a line describes the system or just an old intention.

Where it lives: in the repository, versioned, reviewed by PR like any code change.

Who owns it: one person. Always. An agent can draft it, but acceptance is human.

Authority: maximum. No other layer can contradict it without an explicit review.

Layer 2 · Coordination

What it is: who does what, in what order, blocked by what.

Minimum content of a work unit: an identifier, a reference to the corresponding contract (not a copy), a human owner, and a status.

Where it lives: outside the repository. Who is working on what changes far faster than the code, and versioning it across branches produces permanent conflicts while adding nothing.

Critical rule: the work unit references the contract, never contains it. If the technical substance migrates into the tracker, you lose the ability to reconstruct the project from the repository.

Layer 3 · Execution

What it is: translating contract into diff.

Artifacts it produces: task plan, diff, session log.

Where it lives: nowhere permanent. It is deliberately disposable.

Design test: if all of this layer’s output were lost tomorrow, no information should be lost with it. If something produced here becomes indispensable to understanding the system, that is a sign it belonged in layer 1 and needs promoting.

Its limit: the agent cannot modify the contract on its own. Faced with an ambiguity, it stops and asks. It does not guess. This is the hardest rule to hold and the one that most defines long-term quality — an agent that guesses right 90% of the time leaves you 10% of architectural decisions made by nobody and documented nowhere.

Layer 4 · Verification

What it is: proof that the diff satisfies the contract.

Artifacts: acceptance tests derived from layer 1’s criteria, unit tests, the automation that runs them, and the gates that block the merge.

Where it lives: in the repository, next to the code.

Authority: veto power. It is the only layer that cannot be talked around.

Critical rule: the acceptance criterion is written before layer 3 starts, and by someone other than the implementer. If whoever implements also defines what counts as success, verification stops verifying.

The four coupling rules

RuleStatementWhat it prevents
DirectionalityEach layer references upward, never duplicatesFour versions of the truth, none authoritative
Judge/executor separationThe criterion is written by a person, beforehand, in layer 1A loop closed on itself
Asymmetric persistenceLayers 1 and 4 outlive the project; 2 outlives the sprint; 3 the sessionCritical knowledge trapped in ephemeral artifacts
Aligned granularityOne contract = one unit = one reviewable diff = one evidence setReview made impossible, traceability lost
The four coupling rules between layers 1 · Directionality Each layer references upward, never duplicates. 4 3 2 1 Prevents: four versions of the truth, none of them authoritative. 2 · Judge/executor separation The criterion is written by a person, beforehand. who judges who executes Prevents: a loop closed on itself that verifies nothing. 3 · Asymmetric persistence 3: session 2: sprint 1 and 4: project What lasts longest holds what matters most. Prevents: critical knowledge trapped in ephemeral artifacts. 4 · Aligned granularity contract = unit = diff = evidence If one grows, review stops being possible. Prevents: PRs approved without reading and traceability lost.
The four rules are not style: each one prevents a concrete, observable failure — and the diagnosis section at the end of this article reads them backwards, as symptoms.

The cycle

Outbound: a delta is proposed → humans agree on it → it becomes a work unit → an agent executes it → the evidence validates it.

Closing: the delta is absorbed into the current state and the proposal is archived. This is the step nearly everyone skips, and it is what stops layer 1 from becoming a graveyard of contradictory proposals.

Return: there are two return paths.

  • From verification — if the evidence contradicts the contract, the evidence wins and the contract is corrected. Never the other way around.
  • From execution — if the agent finds an ambiguity, it escalates. It does not resolve.
The full cycle: outbound, closing, and the two return paths OUTBOUND delta proposal agreement between humans work unit the agent executes the evidence validates CLOSING The delta is absorbed into the current state and the proposal is archived. The step nearly everyone skips. Without it, layer 1 accumulates proposals that contradict each other. RETURN — two paths, and neither is optional From verification If the evidence contradicts the contract, the evidence wins. Never the reverse. From execution If the agent finds an ambiguity, it escalates. It does not resolve.
Closing is the invisible step: nobody misses it until layer 1 has already become useless. Treat it as part of the merge, not as a separate chore.

Part 2 — Tools by layer

Tools change fast; layers do not. This section will go stale before the rest of the article, and that is exactly the point: if your process depends on a specific tool, migrating costs you the whole process.

Tool categories per layer and how fast each one churns 1 Versioned specification frameworks OpenSpec · Spec Kit · BMAD · Kiro · your own markdown + AGENTS.md / CLAUDE.md at the root low churn 2 Trackers with agent support GitHub Issues · Linear · Jira — the criterion is not features, it is who else has to take part low churn 3 Agent harness — CLI, IDE, or cloud Pick it for team ergonomics, not benchmarks. It is the most replaceable of the four layers. HIGH CHURN 4 Test frameworks, static analysis, and CI Cucumber · Playwright · pytest · Vitest · linters · Actions — with blocking gates, not informational ones low churn
The three layers that matter churn slowly. The one everybody argues about — which agent to use — is precisely the one you need to be able to swap at no cost.

Layer 1 · Intent

Category: versioned specification frameworks.

ToolProfileNotes
OpenSpecBrownfield, lightweightSeparates current state from proposals using delta markers (ADDED/MODIFIED/REMOVED). Produces compact, easily reviewable artifacts. Its stores allow specs shared across repos.
GitHub Spec KitGreenfield, structuredMore exhaustive and more verbose — roughly three times the content OpenSpec produces for the same change. Requires Python.
BMAD-METHODMulti-team, ceremoniousSimulates a full agile team with 12+ specialized agents. Only justified at large scale.
KiroFull IDEIntegrates all four layers in one environment. Less initial friction, more lock-in.
Your own documentsAnyA markdown directory with clear conventions covers 80% of the value. Do not underestimate this option.

Minimum requirement, tool-independent: a conventions file at the repository root (AGENTS.md or CLAUDE.md) that any agent reads on startup. That is what makes the rest portable.

Layer 2 · Coordination

Category: trackers with agent support.

ToolStrengthLimit
GitHub IssuesShort loops between idea, code, review, and merge; highly programmable via Actions and GraphQLIt is a developer-native coordination layer, not a work system that spans the whole organization
LinearTreats agents as first-class participants: direct assignment, issue context when launching the coding tool, MCP supportLives outside the repository, with no native access to the code
JiraAdministrative model and governance for large organizationsConsiderable configuration weight

The choice criterion is not features but who else has to take part. If it is only developers, Issues is enough. If design, product, or management are involved, a developer-native tracker shuts them out.

Layer 3 · Execution

Category: agent harness.

  • CLI: Claude Code, Codex CLI, Gemini CLI, Aider
  • IDE: Cursor, Cline, Roo Code, Copilot
  • Cloud/async: agents that take an issue and hand back a PR

This is the fastest-churning layer and the one where deep integration is least worth investing in. Pick it for team ergonomics, not benchmarks. The best agents today solve between 60% and 70% of SWE-bench Verified, but that benchmark uses curated issues with explicit acceptance criteria — conditions real tasks almost never have. The number says more about the quality of your layer 1 than about the agent.

Layer 4 · Verification

Category: test frameworks and automation.

LevelTypical toolsDerives from
AcceptanceCucumber, Behave, Playwright, contract testingLayer 1 criteria
Unitpytest, Vitest, JUnit, Go testingLayer 3 design
Staticlinters, type checkers, security analysisRepo conventions
OrchestrationGitHub Actions, GitLab CI, and merge gates

Configuration rule: gates must be blocking, not informational. A check you can merge past in red is not verification, it is decoration.

Part 3 — How the methodologies fit together

No methodology covers all four layers. Each one concentrates on one or two and assumes the rest. Understanding where each one puts its weight is what lets you combine them with neither overlap nor gaps.

Coverage matrix

MethodologyLayer 1Layer 2Layer 3Layer 4
Vibe coding●●●
Issue-driven●●●●●
SDD (spec-driven)●●●●●
TDD (test-driven)●●●●●
BDD / ATDD●●●●●
SDD + TDD●●●●●●●●
EDD (evaluation-driven)●●●

●●● main focus · ●● strong involvement · ● partial involvement · ○ marginal · — does not cover

Coverage heat map: seven methodologies against the four layers Layer 1 Layer 2 Layer 3 Layer 4 Vibe coding focus Issue-driven focus SDD focus TDD focus BDD / ATDD focus SDD + TDD focus focus EDD focus the only one on 1 and 4 More saturation, more weight. Pale cells are partial involvement; grey ones, no coverage.
No methodology covers all four layers on its own. SDD + TDD is the only row with a main focus on layer 1 and layer 4 at once — which are, precisely, the two that outlive the project.

Vibe coding

What it is: describing in natural language what you want, letting the agent generate the code, and accepting the result if it “works”, iterating through conversation without reading the code in detail. There is no prior contract and no success criterion fixed in advance: the criterion is the impression of whoever tries it. Andrej Karpathy popularized the term in early 2025 to describe that mode of working where you forget the code even exists.

Where it lives: layer 3, exclusively.

It works well for prototypes, exploration, and throwaway scripts — contexts where the cost of being wrong is zero and the artifact has no future.

Why it fails at scale: all the knowledge stays in the most ephemeral layer. When the session ends, the information is gone. With several people, each one builds a different mental model of the system and nobody can reconcile them.

When to use it anyway: inside a work unit already bounded by a contract. Vibe coding is a valid layer 3 technique; the problem is using it as a methodology.

Issue-driven development

What it is: organizing work around a tracker’s issues. Every change is born as an issue, is discussed, prioritized, and assigned there, and is closed when the associated PR merges. It is the default practice of almost any team using GitHub, GitLab, or Jira, which is why many apply it without naming it.

Where it lives: layer 2, spilling into layer 3.

The issue is the work unit and the agent’s entry point. In its pure form, the agent reads the issue, navigates the code, and hands back a PR.

Strength: zero adoption friction. It does not change how the team works, it just adds an actor.

Structural weakness: with no layer 1, the issue ends up absorbing the specification. It starts as three lines and ends up a design document buried in comments. Six months later you have a tracker with thousands of closed issues and no coherent description of the system.

How to integrate it well: keep the issue thin and pointing at the contract. Issue-driven is an excellent layer 2 and a terrible layer 1.

SDD — Spec-driven development

What it is: writing and approving a specification — what the system must do, at what scope, under what constraints — before generating code, and using that spec as the agent’s direct input instead of a loose prompt. It is the methodology behind the layer 1 tools from Part 2 (OpenSpec, Spec Kit, Kiro): each is a different way of structuring the spec and chaining it to the plan and the tasks.

Where it lives: layer 1, with strong influence over layer 3.

It inverts the traditional relationship: the specification stops being documentation written afterwards and becomes the source that drives generation, checklists, and task decomposition.

Key difference from a traditional PRD: a design document is written for human readers, who interpret ambiguities and fill gaps with organizational context. Agents fill gaps too — but not the way you would want. Without explicit scope, they move fast in the wrong direction.

Its blind spot: SDD alone is weak on layer 4. It produces documents describing expected behavior, but the translation into executable evidence stays implicit. On top of that, proposals are static: in long implementations, contract and code drift apart with nothing catching it.

Three levels of spec authority over code:

  1. Spec-first — the spec precedes and constrains, the code is still the main deliverable
  2. Spec-anchored — governance layers and supervision checkpoints are added
  3. Spec-as-source — the spec is the primary artifact and the code is derived

Most teams should start at level 1.

TDD — Test-driven development

What it is: writing an automated test that fails first, because the functionality does not exist yet, then the minimum code to make it pass, and finally refactoring with the test as a safety net. That cycle — red, green, refactor — repeats in small increments at the unit level. Kent Beck formalized it within Extreme Programming, and it is as much a design technique as a verification one: it forces you to define a component’s interface before implementing it.

Where it lives: layer 4, with strong influence over layer 3.

With agents, there are three variants depending on where the human sits:

VariantWho writes the testRisk
Human writes the testsA personLow — but it is the bottleneck
Review checkpointAgent writes, human approves before implementingMedium
Everything inside the loopAgent writes both test and implementationHigh

The third variant’s risk is concrete, not theoretical. Kent Beck documented agents deleting failing tests instead of fixing the underlying implementation. The agent optimizes the criterion you gave it — if the criterion is “keep the suite green” and the agent controls the suite, you have a misaligned incentive.

Its blind spot: TDD says nothing about what to build. It verifies you did well what you decided to do, not that you decided the right thing. A system with 100% coverage can be solving the wrong problem.

BDD / ATDD

What it is: two names for the same idea, with different emphases.

  • BDD (Behavior-Driven Development) — an evolution of TDD proposed by Dan North. Instead of unit tests, the system’s expected behavior is described in structured natural-language scenarios (Given-When-Then: given an initial state, when an action occurs, then a result is expected), written jointly by business, development, and testing, and automated with tools like Cucumber or Behave.
  • ATDD (Acceptance Test-Driven Development) — the same practice seen from the test side: acceptance criteria are agreed with whoever requests the change and turned into executable tests before implementing.

In practice they are used almost interchangeably. BDD puts the weight on shared language; ATDD, on the acceptance test as a contract.

Where it lives: a bridge between layer 1 and layer 4.

The scenarios work simultaneously as readable specification and as executable test. It is the methodology that naturally connects intent with evidence.

Its specific advantage in this scheme: it resolves the translation SDD leaves implicit. The acceptance criterion stops being interpretable prose and becomes an artifact that runs.

Its risk with agents: when the agent generates the scenarios from a domain description, those scenarios tend to reflect the model’s training distribution rather than your domain’s specific edge cases. AI-generated scenarios need human review focused on completeness, not correctness — the problem is rarely that a scenario is wrong, but that the three that matter are missing.

What it is: not a new methodology but the explicit combination of the two above: SDD to fix the contract and scope before starting, and TDD — with BDD scenarios as the bridge — to turn that contract into failing tests before the agent writes any code. Each one covers the other’s blind spot.

Where it lives: layers 1 and 4 simultaneously, which is exactly what neither covers alone.

The two methodologies operate at different architectural levels, which is why they integrate rather than compete: TDD drives interface design through red-green-refactor cycles at the unit level, while SDD stacks on top to impose architectural constraints.

The SDD plus TDD flow in six steps across the four layer lanes LAYER 1 Intent 1 Change contract + Given-When-Then scenarios Expected behavior, scope, and criteria. Reviewed and approved by a person. 2 Work units with an assigned owner Layer 2 — the tracker points at the contract, it does not copy it. 3 Acceptance tests that FAIL — written by the judge Layer 4, before execution. This is the step that makes judge/executor separation real. 4 The agent implements the minimum to pass them Layer 3 — with unit-level TDD for internal design. It does not touch the acceptance tests. 5 CI green, with blocking gates Layer 4 — acceptance and unit tests. Red does not merge. 6 The delta is absorbed into the current state and the proposal is archived.
Order matters more than tooling: step 3 comes before step 4, and someone else writes it. If the same agent does both, you are back to the closed loop.

The concrete flow, layer by layer:

  1. Layer 1 — the change contract is written: expected behavior, scope, and the acceptance scenarios in Given-When-Then format. A person reviews and approves it.
  2. Layer 2 — the contract becomes one or more work units with an assigned owner.
  3. Layer 4 (first step) — the scenarios are translated into executable acceptance tests that fail. This happens before execution, and it is what makes judge/executor separation real rather than declarative.
  4. Layer 3 — the agent implements the minimum needed to pass the tests, using unit-level TDD for the internal design.
  5. Layer 4 (closing) — CI runs acceptance and unit tests. The gates block the merge if anything fails.
  6. Layer 1 (archiving) — the delta is absorbed into the current state.

Why this combination specifically: the spec is the rein; TDD is the mechanism that holds it. Without a spec, TDD verifies the wrong thing well. Without TDD, the spec drifts silently during implementation. Code shipped with neither spec nor test suite looks fine until the third sprint, when behavioral drift accumulates and refactoring turns into archaeology.

The rule that keeps it from collapsing: the step 3 acceptance tests are written by a person, or by an agent different from the one implementing and reviewed by a person. If the same agent does 3 and 4, you are back to the closed loop.

EDD — Evaluation-driven development

What it is: adapting the test-driven cycle to components whose behavior is non-deterministic, such as an LLM or an agent. Instead of binary asserts, you define evals: sets of representative cases with metrics — accuracy, instruction adherence, quality judged by another model or by people — run continuously, before and after each deployment, to catch regressions when the model, the prompt, or the data changes.

Where it lives: layer 4, extended beyond the merge.

Only relevant if what you are building includes AI components. TDD and BDD assume that once software passes its tests it stays reliable — a valid assumption for deterministic systems. LLM-based components evolve with model changes, knowledge updates, and context variations, and exhibit emergent behaviors no static test case anticipates.

What it adds: continuous post-deployment evaluation, with metrics on dimensions asserts do not capture — reasoning coherence, constraint adherence, output quality.

When to bring it in: if your product has an agent inside it, layer 4 needs this component in addition to traditional tests. If you only use agents to build deterministic software, you do not need it.

Adoption guide

Coming from vibe coding: add layer 4 first. Acceptance tests before specs. It is the change with the best effort-to-benefit ratio and the one that makes the problem visible.

Coming from issue-driven: add layer 1 and slim the issues down. Migrate the technical substance from the tracker to the repo.

Already doing SDD: check whether your acceptance criteria are executable or prose. If they are prose, you have a nominal layer 4.

Already doing TDD: add layer 1 for the decisions tests do not capture — scope, architectural constraints, design rationale.

Suggested adoption order: layer 4, then layer 1, then layer 2, and layer 3 last 4 Verification First, because it is what makes the problem visible. 1 Intent Next, to fix the source of truth the evidence measures. 2 Coordination Then, to split the work without absorbing the technical substance. 3 Execution Last, because it is the one that matters least and will change most. The order is counterintuitive on purpose: almost everyone starts by picking an agent, the last decision that matters. Health indicator: if a newcomer understands what the system does by reading only layers 1 and 4, the scheme works.
Suggested implementation order. Layer 3 goes last because it is the one that matters least and the one that will change most.

Suggested implementation order: layer 4 → layer 1 → layer 2 → optimize layer 3. Layer 3 is last because it matters least and will change most.

Diagnosis

Four failures, each identifiable by which layer slipped out of place:

SymptomDisplaced layerCorrection
Project knowledge lives in the trackerSubstance migrated from 1 to 2Move content to the repo, leave references
Tests always pass, bugs always shipLayer 3 writes layer 4Separate who writes the criterion
The spec says one thing, the system does anotherLayer 1 is never archivedInstitute the cycle’s closing step
PRs get approved without readingBroken granularityReduce the size of the work unit

Health indicator, in one sentence: if a newcomer can understand what the system does by reading only layers 1 and 4, the scheme is working.

References