../notes

executable project memory

why I think BDD is an underrated practice in agentic development, and what it could mean for the long-term maintainability of our codebases.

  • engineering
  • bdd
  • testing
  • agentic-development

The easier it becomes to write code, the more expensive it feels to write the wrong code.

Much of the conversation around agentic development focuses on immediate productivity. How quickly can we implement a feature? How much of a task can we delegate? How many pull requests can we get through?

I've been thinking more about what happens six months or two years down the line.

As agents generate increasingly large amounts of code, how do we ensure that our codebases remain coherent? How do we recognise recurring patterns, preserve business intent and avoid accumulating subtly different implementations of essentially the same behaviour?

Over the past six months, I've been experimenting with an established but, in my opinion, rather underrated software engineering practice in agentic development: Behaviour-Driven Development (BDD).

agreeing on what we're building

One of the things I find interesting about agentic development is how quickly agents move from an abstract description of a problem to a concrete implementation plan.

These plans are often quite good at describing how something should be implemented. But I'm not always convinced that we've spent enough time agreeing on what we're implementing.

Consider a relatively simple checkout scenario. A customer completes a purchase, but the product catalogue doesn't return the product information required to populate their confirmation message.

Without an explicitly defined fallback behaviour, a customer might end up seeing an unresolved placeholder such as {product_name}.

We could describe the task as fixing the checkout confirmation message when product information is unavailable. Alternatively, we could express the expected behaviour more explicitly:

Scenario Outline: Display a purchase confirmation
  Given a customer has completed a purchase
  And the catalogue returns "<product_name>"
  When the purchase confirmation is displayed
  Then the confirmation should contain "<expected_text>"
  And it should not contain unresolved placeholders

  Examples:
    | product_name | expected_text        |
    | Headphones   | Headphones           |
    | unavailable  | Thank you for buying |

The distinction is subtle but important.

We're no longer simply asking the agent to fix a bug. We're agreeing on what the customer should experience under different circumstances, including the behaviour we want to preserve.

I've used this approach when working with external consumers of a service. In one instance, I took the Gherkin scenarios generated by an agent and used them as the basis of a discussion with the consuming team.

It became apparent that our initial, relatively abstract description of the task didn't quite align with their expectations.

We iterated on the scenarios before touching the implementation.

Changing a few lines of Gherkin was considerably cheaper than repeatedly changing an implementation based on evolving interpretations of the requirements.

executable project memory

Much of how I approach software engineering today was shaped by Robert Chatley's teaching during my time at Imperial. What I particularly valued was how closely his teaching connected software engineering principles with the realities of working in industry.

It gave me an appreciation for established engineering practices that I've continued to develop through my own experiences, revisiting them as the tools and environments around us change.

At Prime Video, I worked on a checkout orchestrator where BDD helped us reason about increasingly complex business logic.

When I joined Spotify, I experienced the other side of this problem. Understanding a specific behaviour often meant navigating thousands of lines of implementation and test code, piecing together what happens and why, and hoping that I'd found all the relevant logic.

There is a difference between having access to the implementation of a system and having access to an understandable representation of its behaviour.

In June 2026, I started revisiting BDD in the context of agentic development.

Rather than attempting to retrofit an entire codebase with Gherkin scenarios, I started introducing them for existing behaviours as I modified them, and defining them upfront for new use cases.

What interested me was that the resulting scenarios served several purposes.

They were regression tests, but they were also documentation. They provided a starting point for someone onboarding into the codebase, a reference for engineers modifying existing behaviours, and a source of context for agents working on subsequent tasks.

I also noticed that agents seemed to have an easier time reasoning about business logic when it was expressed in business terms, rather than having to reconstruct it from implementation details.

The scenarios became a form of executable project memory.

Unlike a standalone document describing how a system works, they could be validated against the implementation. Unlike the context accumulated within an agent session, they remained available to the next engineer or agent working on the codebase.

why now?

One of my historical frustrations with BDD was the amount of work involved in wiring everything up.

Writing a Gherkin scenario is relatively straightforward. Turning that scenario into an executable Cucumber test often involves step definitions, fixtures, mocks and a fair amount of repetitive implementation.

A step definition might historically have looked something like this:

@Given("^the catalogue returns \"([^\"]*)\"$")
public void catalogueReturns(String productName) {
    when(catalogue.getProduct())
        .thenReturn(
            productName.equals("unavailable")
                ? Optional.empty()
                : Optional.of(productName)
        );
}

Modern Cucumber expressions make some of this less cumbersome, but the underlying work remains.

Interestingly, much of what makes BDD tedious to implement is precisely the sort of work that coding agents are quite good at.

Pattern matching, identifying existing step definitions, wiring up mocks, generating fixtures and following established implementation conventions are all relatively well-suited to agentic development.

This changes the trade-off.

Historically, the additional effort involved in maintaining a BDD framework could make it difficult to justify, particularly for smaller changes or teams operating under tight delivery constraints.

With agents handling much of the repetitive wiring, we can spend proportionally more time thinking about the behaviours themselves.

The value of BDD hasn't fundamentally changed. The cost of adopting it has.

the workflow

The workflow I've been experimenting with is relatively simple:

  • Give the agent an abstract description of the problem.
  • Ask it to discover existing behaviours and draft Gherkin scenarios.
  • Review related scenarios together, one behaviour at a time, and agree on the full scope before the agent plans the implementation.
  • Wire up the agreed scenarios and run them against the current implementation.
  • Implement the changes and run the same scenarios again.

The approval pause is particularly important to me. Gherkin becomes the medium through which we discuss requirements, rather than simply another artefact the agent generates along the way.

Once we've agreed on the scenarios, I ask the agent to wire them up and run them against the current behaviour.

Taking the earlier checkout example, I want to see the missing-product scenario fail because the confirmation is wrong, whilst the existing, correct behaviours continue to pass.

Only then do I want the agent to change the implementation and run the same examples again.

This brings some of the discipline of TDD into agentic development at the behavioural level. We're establishing what should be true, demonstrating where the current implementation falls short, and validating our changes against the same agreed expectations.

The scenarios then remain in the codebase as executable project memory, rather than disappearing into the history of an agent session.

I've reconstructed this workflow into a BDD agent skill, based on what I've been practising since June 2026. It guides the agent through requirements discovery, collaborative scenario refinement and test-first implementation, with explicit approval points along the way.

The intention isn't to automate away requirements engineering, but to reduce the friction of doing it well.

who defines the tests now?

I've also been thinking about this in the context of Test-Driven Development (TDD) and Domain-Driven Design (DDD).

What I particularly appreciate about DDD is the emphasis on a ubiquitous language: a shared vocabulary that allows us to reason about the problem domain without constantly translating between business requirements and implementation details.

Gherkin gives us a practical way to express behaviours using that vocabulary, in a format that both humans and agents can work with.

Historically, writing tests forced engineers to engage with the problem domain.

When agents generate both the implementation and the tests, it's increasingly easy to bypass that thinking. We can end up with passing builds, good coverage and a comprehensive-looking test suite without really knowing whether we're testing what we want.

Passing tests and having the right tests are two very different things.

I don't think we need to remain the authors of every test case. But we do need to remain actively involved in defining the behaviours those tests represent, and the language we use to describe them.

beyond the next pull request

Much of what I've observed so far has been qualitative. I haven't conducted a controlled experiment comparing development time, token consumption or long-term maintainability between codebases with and without BDD.

But I do think there's something worth exploring here.

As the cost of generating code decreases, I'm increasingly interested in the cost of understanding it.

An agent might implement a feature perfectly well within the context of a particular session. But that session is transient. The implementation, its tests and the decisions encoded within them are what the next engineer or agent inherits.

Without a coherent representation of the behaviours we intend to preserve, I wonder how sustainable some of our current approaches to agentic development will be.

BDD isn't a silver bullet. It doesn't replace good architecture, thoughtful abstractions or the need to understand the systems we're working on.

But it does offer a way to make business intent more explicit, more accessible and more durable.

I wouldn't be surprised if BDD sees a resurgence as agentic development matures. Not because it's a new practice, but because the conditions that once made it relatively expensive to adopt are changing.

Perhaps some of the most useful practices for agentic development are ones we've already had for decades.

We can delegate the mechanics of writing tests without delegating the responsibility of deciding what should be true.

interactive terminal

ready — try help