Skip to main content

The Living Specification: How I Keep AI-Written Code Correct

The code is not the source of truth anymore — and what that changes for every role in the SDLC

Updated 18 min readMarkdown
Part of seriesSoftware Assets Platform
The Living Specification: How I Keep AI-Written Code Correct

Note: Originally published on Medium

Second and final part of "AI Writes the Code. So What Is the Engineer's Job Now?", a series in 2 articles.

Previously: the story — one developer, two months, and the three bugs an adversarial AI review found before a single line of code.

Today: the method.

In Part 1, an adversarial design review found three real problems before implementation. The obvious question is: what kind of workflow makes this repeatable?

The answer is a change in the source of truth!

The code is not the source of truth anymore

This is the most important change in my workflow, and it is easy to misunderstand.

I do not start from code and then try to keep the specification close to it.

The specification is the source of truth. The invariants are the contract. The code is an implementation of that contract.

An invariant is a rule that must remain true in the system. For example:

  • a user must not access a period they cannot see;

  • an asset must belong to the correct organisational scope;

  • every API entry point must use the same authorization rule;

  • a migration must preserve the required organisational relationships.

These are not implementation details. They are properties of the system.

In a traditional project, specifications are written before development and then slowly become outdated. The code changes every day. The documentation changes when somebody remembers to update it 🫩

Diagram of specification drift. A specification, written once then frozen, is linked to the code by a dashed line crossed out and labelled "updated when somebody remembers". The code changes every week and exchanges arrows with reality: bugs, new needs and hotfixes. Eventually the code becomes the real source of truth and the documentation becomes historical.

With an AI-assisted workflow, I cannot afford this. If the specification is outdated, the AI will read outdated information and produce new code based on it.

So the rule becomes strict: The specification is the source of truth. Code reflects the specification. Not the opposite.

Diagram of the living specification cycle. Specification and invariants are the source of truth: the rules that must remain true in the system. The AI implementation takes one small task, applied against the rules. It produces code, an implementation of the contract and never where decisions are made. Verification asks whether the code satisfies the invariants, with a real command. If it fails, an arrow returns to the specification, which is fixed first, then the AI realigns the code.

When something is wrong, I do not touch or modify the code at all. First, I ask:

  • Is the specification wrong?

  • Is an invariant missing or ambiguous?

  • Did we misunderstand the business rule?

If the specification was wrong, I correct it. If an invariant was missing, I add it. Then I ask the AI to align the code with the specification.

N.B.: This discipline is not optional. If you change the code directly and forget the specification, the next AI session reads the old rule and can reintroduce the old behavior. The project splits into two realities: what the documentation says and what the code does.

The whole approach exists to prevent exactly that.

Three development models

I see three different models in the industry right now:

Diagram comparing three development models. Model 1, classic: business need, specification, architecture, development, review and QA, security review, deployment; feedback arrives late. Model 2, AI coding assistant: the human designs, the AI writes, the human reviews; it assumes the design is correct. Model 3, highlighted: human and AI explore the problem, specification and invariants, the AI attacks the design, implements a small task, verification, human review and commit.

Model 1 —the classic approach: The problem is not that every part is wrong. The problem is the feedback loop. You discover a misunderstanding during QA. You discover an architecture problem after several features are built. You discover a security problem near the end of the process, whether you're using a waterfall approach or Agile. The process is mostly sequential.

Model 2 —the AI coding assistant: It is already much faster. But it uses AI for the cheapest part of software development: typing. It also assumes the human's design is correct. And because this model is widely used, people incorrectly think that developers are no longer needed.

My project showed me that my own designs were not always correct. It contained the wrong validation boundary, an incomplete migration and the wrong sorting. If the AI had started only after the design was approved, it would simply have implemented those mistakes faster.

There is also another problem: how do you review hundreds of generated lines if there is no written specification? Without expected behavior and verification commands, code review becomes very difficult, if not impossible.

Model 3 —AI-assisted engineering: The important difference is that AI participates before implementation. It is not only a code generator. It becomes a questioning system. It challenges the product idea, challenges the architecture, writes and reviews tests, reviews security, checks accessibility. But the human remains responsible for the decisions.

The real operating system: rules, skills and plans

One of the most useful things I built was the AI configuration structure of the project. It contains rules and skills. The rules describe the project. The skills perform actions.

In Part 1, I explained that CLAUDE.md should stay concise and delegate to focused rule files. The frontend rules alone eventually became 18 smaller files: architecture, API, RBAC, security, testing, design and UX, performance, naming...

However, a skill that is specific to the project lives in the repository; a skill that is repeatable across projects lives at the account level (~/.claude/skills/). An adversarial design review works the same everywhere - install it once and every project benefits. A skill that knows your routes, your roles or your migration conventions belongs to the project.

The second important structure: every non-trivial feature gets a specification and an execution plan. The plan contains status, current task, decisions, blockers, verification commands and expected build state.

Two sentences became the rules of the project— and, eventually, of all projects:

  • The plan file is the source of truth

  • A decision that lives outside the plan did not happen

A two-month project contains many conversations. Conversations disappear. The repository remains.

This has a very practical consequence: the state of the work lives ONLY in the plans. I can stop a session, clear the context, or restart the conversation at any moment without losing anything. The next session reads the plan—current task, decisions, blockers, expected build state —and continues exactly where the previous one stopped.

Prompts are project assets

There is a third element next to rules and skills: reusable prompts.

During the project, the same requests kept coming back: explore a business need and create the specification, implement one task from a plan, review a migration before writing it, apply an API contract change, run an accessibility review. I stopped typing them from scratch. Each one became a file in the repository, versioned with the code and improved after every use.

A good reusable prompt encodes the discipline so I do not have to remember it: which rule files apply, the exact scope, the verification command, and where the AI must stop and ask. For example: "Implement ONLY task N from the plan. Run its verification command and show me the real output. Do not start the next task. Do not commit."

The prompt library grows like a toolbox. A prompt that produced a good result is worth keeping. A prompt that produced a bad one is worth fixing— exactly like code. See my GitHub project for an example.

Small tasks, real verification

AI can produce a lot of code very quickly. That creates a new danger: it can also produce a lot of WRONG code very quickly.

So I added strict scope rules. One task. One file when possible. One verification. Then review.

When I asked AI to generate tests for everything, I got many poor tests that I did not properly review. When I asked for one file at a time, quality increased because the review became manageable. The same principle applies to security: audit can be broad, fixing should be narrow.

I also changed the meaning of "done". Previously: the code looks good. Now: show me the evidence.

Every task has a verification command, and the expected result is written before the command is executed. The AI is not allowed to say "it should work".

This matters because AI has a particular failure mode: confident, well-structured answers that are wrong. The answer is not to trust the AI less. The answer is to verify more.

And the human's work must be verified too. During the redesign, I predicted the test suite would stay green through the first tasks. The measured result: 807 tests run, 138 failures, 38 errors. The plan was wrong. The measurement corrected it.

Quality became cheaper

One of the biggest changes was economic.

Before AI, doing the proper thing had a cost. Detailed tests, double migrations, documented decisions, edge-case reviews— often the answer was "we don't have time".

AI changes that equation. The project has 16,092 lines of test code versus 14,226 lines of production code. I had never reached that ratio on a project of this size. Not because I became more disciplined— because the mechanical cost of the right way became small.

When the mechanical cost becomes small, the right way becomes cheaper.

The industry may not become less disciplined. It may become possible to be more disciplined without paying the old cost. That is a much more interesting effect than writing code faster.

How Every Role Changes

AI does not simply make each role faster. It changes where the value of each role lies.

The shift across the main SDLC roles covered here is as follows:

Table of how ten roles move from an old to a new centre of gravity. Product owner or BA, from requirements to intent and decisions. UX/UI designer, from screens to design systems. Architect, to architecture as executable constraints. Developer, from code to solution definition and verification. QA, to quality strategy and evidence. Security, to continuous verification. Data, to data contracts. Platform, to paved roads. SRE, to reliability boundaries. Tech lead, to judgement and coherence.

Product Owner / BA

From writing requirements to exploring them with AI, challenging assumptions and making decisions explicit.

Ambiguous business language becomes expensive when an AI can apply it across thousands of lines of code.

The PO/BA therefore becomes less of a requirements writer and more of an interpreter of intent: identifying ambiguity, resolving contradictions, exploring edge cases and making decisions explicit enough for both humans and machines to act on.

UX/UI Designer

From producing screens to producing design systems, interaction rules and accessibility constraints.

In my project there was no Figma: the running Angular application, generated inside a set of design rules, became the maquette, and the browser became the feedback loop.

This changes the designer's role from producing individual screens to defining the system that generates consistent experiences: components, interaction patterns, responsive behaviour, accessibility rules and visual constraints.

Architect

From designing the architecture to comparing AI-generated alternatives and verifying conformance continuously.

My architecture verification skill checks the actual code against the constraints.

The architecture is no longer only a diagram. It becomes a testable contract.

The clearest example in my project is the OpenAPI contract: it is the source of truth for the API. The backend generates its interfaces from it, the frontend consumes it, and generated code is never manually edited.

An architectural change is no longer:

“Let's change the code”

It becomes:

“Let's change the contract and see what breaks”

The compiler and the generated code become part of the impact analysis.

Developer

From implementing features to defining, reviewing, validating and evolving solutions.

When implementation itself becomes increasingly cheap, the developer's value moves toward understanding the problem, selecting between alternatives, defining the right constraints and reviewing the output.

The developer is no longer simply the person who translates a specification into code.

They increasingly define what a good implementation looks like and provide the evidence that the generated implementation actually satisfies that definition.

QA Engineer

AI can generate 100 tests.

The QA engineer must ask:

“Do these 100 tests prove the right thing?”

That is a more valuable question.

The role moves from producing and executing test cases toward quality strategy, coverage reasoning and evidence.

AI can generate tests at enormous scale, but it does not automatically know whether the tests capture the important business risks, missing scenarios or incorrect assumptions.

Security Engineer

From a review phase at the end to security reasoning during design and continuous verification.

My most interesting security finding did not come from a scanner.

It came from a domain question:

“If category routes enforce period visibility, do asset routes enforce it too?”

A scanner cannot easily ask that.

AI can make security checks more continuous and can find classes of technical vulnerabilities at scale.

But security expertise increasingly lies in understanding the domain, identifying the security invariants that must hold, and asking the questions that automated tools would not know to ask.

Data Engineer

From implementing pipelines and SQL to defining data contracts and ensuring semantic correctness.

AI can generate transformations, queries and pipelines very quickly.

The difficult question becomes whether the resulting data actually means what the business thinks it means.

The data engineer therefore increasingly owns contracts, quality rules, semantic definitions and validation—not simply the mechanics of moving and transforming data.

Platform Engineer

From building and maintaining infrastructure to defining platform constraints and paved roads.

AI can generate Terraform, CI/CD pipelines, Kubernetes manifests and configuration.

The platform engineer increasingly defines the environment in which those generated solutions are allowed to operate.

The goal becomes less:

“How do I configure this service?”

and more:

“How do I make the correct path the easiest path, while making incorrect configurations impossible?”

SRE

From operating systems and responding to incidents to defining reliability boundaries and enabling automated verification and remediation.

AI can analyse telemetry, correlate signals, generate runbooks and propose or execute remediation.

But someone still needs to define what reliable means, which failures are acceptable, what actions are safe to automate and where human intervention is required.

The SRE therefore moves toward defining SLOs, failure boundaries, observability requirements and the limits of autonomous remediation.

Tech Lead

Enforcing standards can increasingly be automated: architecture checks, naming conventions, test-quality rules, repeated security audits and other forms of static verification.

The remaining part becomes the whole job:

Judgement

The Tech Lead increasingly operates at the level where individual outputs have to form a coherent system.

The question is no longer simply whether the code follows the rules, but whether the rules themselves are appropriate, whether the trade-offs make sense and whether the different AI-generated solutions still fit together.

The common shift

Across all these roles, the pattern is similar.

AI lowers the cost of producing software.

The SDLC therefore shifts toward making intent explicit, defining constraints, evaluating alternatives, and demonstrating that the produced system is correct.

The intended skill is no longer the ability to produce an artifact.

It is the ability to judge whether the artifact should exist, whether it expresses the intended solution, and whether there is enough evidence to trust it.

Am I losing my skills?

Some skills became less important for me: typing speed, API memorisation, boilerplate, manual test scaffolding.

And I have noticed something uncomfortable: my recall has become worse. I cannot write a Spring Security filter chain from memory as fluently as I could two years ago. I do not want to hide that. 😁😁😁

But I can still read one. I can identify when it is wrong. I can explain why. For me, that is a good trade— but it is a trade, and we should not pretend otherwise.

At the same time, my technical reach expanded. The learning loop changed from "read a tutorial → memorise → use it later" to "need something → ask why → compare options → implement → break it → understand it". AI makes that loop very fast.

AI increases the value of technical understanding, because it increases the amount of technical output one engineer can control.

This creates a hard problem for junior developers. A junior can now generate a migration without understanding data consistency, or authentication without understanding the threat model.

The answer cannot be "don't use AI until you are senior" — AI is too useful. The answer is: use AI as a teacher, but require understanding and verification. Not "write this", but "explain three ways to implement this, the risks, why you would choose one, and how to test it".

The goal is not to protect typing skills. The goal is to build engineering judgement.

A new skill: context engineering

One skill did not have this importance before. It is context engineering: knowing how to give AI the context required to produce your system instead of generic code.

Writing good rules and specifications. Defining architecture constraints and scope. Recording decisions. Defining verification. Structuring skills and specialised agents. Maintaining project memory.

This is not prompt engineering in the old sense. It is engineering the environment in which the AI operates. And it requires technical understanding: you cannot write good architecture rules if you do not understand architecture, and you cannot define a good verification command if you do not know what correctness means.

AI amplifies the quality of the context. It does not magically create that quality.

What I Recommend for a Team

  1. Write the rules. A project-level document with architecture, coding standards, security rules, testing rules, naming, commands and forbidden patterns. Make it part of the repository.

  2. Separate rules from actions. Rules explain how the project works; skills explain how to perform a task. Do not put everything into one huge instruction file.

  3. Make AI challenge the design. Before implementation, ask: what did we forget? What assumption is dangerous? What happens to existing data? What happens when two rules interact?

  4. Make decisions persistent. Decision, date, reason, rejected alternatives. A decision that lives only in the chat did not happen.

  5. Keep tasks small. One task, one verification, one review. Then continue.

  6. Separate audit and fix. One process finds problems, another applies the fix, then audit again.

  7. Keep the human responsible for commits. In my workflow, Claude Code never commits. The commit is the moment where I say: I accept responsibility for this change.

  8. Measure reality. Do not write "the tests should pass". Run them. Do not write "the security issue is fixed". Re-audit it.

From the keyboard to the review seat

For twenty-five years, a large part of my professional value came from producing code. AI changed that. The production part almost disappeared.

But the engineering part did not. It became more visible.

I now spend more time deciding what to build, why to build it, what "correct" means, what can go wrong, how to verify it, and whether I trust the result.

That is not less engineering. It is a different kind of engineering.

The new paradigm is not "human thinks → AI types". It is:

Human and AI explore → specify → challenge → implement → verify → learn

The human brings responsibility. The AI brings speed and breadth. The repository keeps the memory. The tests provide evidence. The adversarial review provides a machine that is willing to attack my assumptions before my users do.

AI writes the code now. It does not decide whether the code is right. That still requires an engineer. And perhaps more engineering skills than before.

Structured methods for AI-driven development are emerging —BMAD is a notable one. Comparing them with the approach described here deserves its own article.

So do not ask whether AI can write your code. Ask whether you would know if it was wrong.


Missed the story behind this method? Read Part 1 ←


Grab the template

Everything described in this article - a concise CLAUDE.md, focused rule files, skills, specifications, plans and reusable prompts - is available as a public template: github.com/elie29/ai-sample. Copy the structure, rewrite the rules for your project, and make it yours.


Let's stay in touch

I share what I learn about AI-assisted engineering, software architecture and databases. If this article made you rethink your own workflow, follow me on X and connect with me on LinkedIn .  I would like to hear how you work with AI on real projects.

About the author

  • Stratégie · Transformation · Ingénierie · Architecture

No comments yet. Be the first to comment.

Software Assets Platform

Part 2 of 2

AI can now write the code. The real question is: would you know if the code was wrong? This series is based on a real enterprise project — one developer, two repositories, two months — built almost entirely with an AI assistant. It tells the story of the bugs an adversarial AI review found before a single line of code, the times the AI was confidently wrong, and the method that made it all work: the living specification, where the spec is the source of truth, the invariants are the contract, and the code is a continuously verified implementation.

Start from the beginningAI Writes the Code. So What Is the Engineer's Job Now?How I used Claude and an adversarial design review to build an enterprise software assets platform - and why software engineering is moving from code production to technical validation.

More from this blog