When should you use it?
- Your coding agent builds something close to, but not quite, what you asked for
- You want requirements that keep being checked in CI after the chat is over
- Non-developers on the team want to describe features in plain language
Not for: Projects with no test runner or CI where tests could actually run; Pure refactors, renames and styling changes with no visible behavior; Throwaway prototypes where speed matters more than lasting checks
What do you need, and what do you get?
You need
- A project instructions file the agent reads, such as CLAUDE.md or AGENTS.md
- A test setup that can run scenario-style or ordinary tests
- One example scenario file to show the format
You get
- Written scenarios for each user-facing change
- Tests that fail before the change and pass after it
- A minimal code change tied to those tests
How does it work, step by step?
- Paste the blockAdd the poster's block to your agent's project instructions file.
- Add one exampleCommit a single scenario file so the agent copies a real format instead of inventing one.
- Write the scenarios yourselfFor each feature or bug, describe what should happen in plain language before asking for code.
- Check the failing testAsk the agent to show the new test failing before it implements anything.
- Let CI keep scoreRun the scenarios in CI so the behavior stays checked long after the session ends.
The prompt
The original prompt by u/cannyshammy, word for word, with a link to where it was published. Below it is our adapted version with fill-in blanks, if you want it. Works in Claude Code, Custom agent and ChatGPT. Values in lime are placeholders.
Original prompt by u/cannyshammy
## Behaviour-First Default This project follows BDD. See the `.feature` files for examples. For any user-visible feature, bug fix, or workflow change, start from the behaviour. 1. Write down the expected behaviours or acceptance criteria first. 2. Turn those behaviours into executable tests before implementation. 3. Make the relevant new test fail first when practical. 4. Implement the smallest change that makes the behaviour pass. Do not start by coding the solution and only think about tests later.
Exactly as published by u/cannyshammy in I added this to my CLAUDE.md to help stop my agents drifting away from what I originally asked them to build.
Our adapted version (optional)
Fill in the blanks (optional; the copied prompt uses your values)
Project rule: for any change a user would notice ({scope}), start with behavior, not code. List the expected behaviors as short given/when/then scenarios and wait for me to confirm them. Turn the confirmed scenarios into tests in {test_framework}, run them and show me they fail. Then make the smallest code change that makes them pass, and tell me if any scenario was unclear instead of guessing.
What can go wrong?
- Letting the agent write both the scenarios and the code. The value comes from a human stating the behavior.
- Skipping the failing run. A test that never failed may not test anything.
- Applying it to every change. Renames and styling tweaks do not need scenarios, and the rule says user-visible work.
- Vague scenarios. 'It should work well' cannot become a test; name the starting state, the action and the result.
Our take
This is one of the more useful CLAUDE.md snippets we have seen because it puts the instruction somewhere the agent cannot quietly drift from: the test suite. A paragraph of guidance fades as a session gets long, while a failing scenario keeps saying no until the behavior is right. The poster's key point, that the human writes the behaviors and the agent writes the tests, is the part to keep; if the agent writes both, it can make its own misunderstanding pass. The rule is also sensibly scoped to user-visible work, so renames and styling changes are not slowed down. It does need a working test setup and some discipline about keeping scenarios specific. This is one developer's experience on his own app, not a measured study. In our dry run on a fictional dog-walking booking app, the agent wrote fee scenarios before any code, showed them failing, then passed them, and raised an unclear late-cancellation case as a question instead of guessing.
Where the time goes back: Catching a misunderstood feature at the scenario stage takes a minute of reading, while finding it after the code is written means a second round of changes and review.
FAQ
Do I need a BDD framework?
Does it work outside Claude Code?
Who should write the scenarios?
Source and credit
The original prompt on this page is by u/cannyshammy, shown word for word with a link to where it was published. The summary, notes and adapted version are ours.
- Original
- I added this to my CLAUDE.md to help stop my agents drifting away from what I originally asked them to build
- Creator
- u/cannyshammy on r/ClaudeCode
- Published on
- Original date
- Nov 19, 2026
- License
- Not openly licensed; the original prompt is shown word for word with credit and a link to the original
- Originally for
- Claude Code
- AI dry run
- Nov 21, 2026: passed. Dry-run tested by our AI test agent on sample input. Behavior-first order, failing test first, minimal change and the user-visible scope limit all held; simulated repository, no real code shipped.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Nov 21, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.