
Beyond green tests: risk, a deliberate-break check and the cheapest effective gate.
MODULE 3 // QUALITY
Quality in 10x Workflow: five lessons on protecting the most dangerous scenarios with a test whose assertion actually fails - a test plan, the oracle and mutation, hook layers, an E2E flight and debugging from evidence. A green test that does not fail when you break the code guards nothing.
RISK MAP UNDER A SHIELD // CLICK AN AREA TO FLY TO A SECTION
Module summary · five lessons in 30 seconds
What kills the project first? The most dangerous scenarios protected first.
LESSON 02How does a test know what is correct? An assertion that actually fails on broken code.
LESSON 03What catches the error before you see it? Drift detected seconds after it appears.
LESSON 04Does the whole thing really fly? A flight where a unit test would lie.
LESSON 05What do all the instruments say at once? A diagnosis from evidence, not from hunches.
Start from risks, not from files - and write tests whose assertion actually fails on broken code.
"The desert kills in a known order: thirst first, then the storm, the worm last. Whoever leaves the sietch without this map does not come back."
- Fremen teaching, before leaving the sietchThe Fremen do not leave the sietch with a to-do list - they leave with a map of what kills. The desert is predictable in its hostility: every threat has a known weight and a known frequency. A test plan brings that rigor to the project: instead of covering files one by one, it maps risks on the impact × likelihood axes and describes each risk as a user-facing failure - "the cart loses items on refresh", not "cart.ts has no tests".
A test plan starts from a map of what kills the project, not from a list of files: it maps risks on the impact × likelihood axes and describes each risk as a user-facing failure - "the cart loses items on refresh", not "cart.ts has no tests".
Input: a working product and the PRD. Output: context/foundation/test-plan.md - a risk map cut into rollout phases, from the most dangerous scenarios down. Mechanism: /10x-test-plan orchestrates the delivery of tests instead of writing them itself - it drives each phase through the chain (research → plan → implement), and a re-run resumes from the next phase instead of starting over.
before the first test is written - the order of writing tests is set by the risk map, not by the directory structure.
An orchestrator, not an author of tests: it writes context/foundation/test-plan.md as a phased rollout strategy and drives each phase through the chain: new change → research → plan → implement. A re-run reads the state from disk and resumes from the first unfinished phase.
Input: the PRD, the roadmap, the change archive, a hot-spot scan of git history (the last 30 days) and a user interview - five questions about real worries, past incidents and places changed without confidence. Output: an impact × likelihood risk map cut into rollout phases with statuses.
Every risk cites evidence: a PRD line, an interview answer, a high-churn directory. Never file:line - anchors in code are found only by the research of a specific phase, on current code. A risk is a user-facing failure scenario, not a location in the repo.
For each risk the plan carries response hints:
If the product has login, payments or accepts user input, the map must contain at least one abuse scenario: resource ownership checks, server-side validation, secret or data leaks, resource abuse. The happy path contains no attacker, so these risks will not surface from the interview on their own.
It does not write test code and does not configure hooks or CI - that is the rollout phases' job. It does not invent risks: each one must derive from the PRD, the roadmap, the archive, the hot-spots or the interview. A single test for a single file is /10x-tdd territory, not a rollout.
"Do not ask the theory whether it is right. Break the system and watch whether the instrument screams - measurement decides, not faith."
- experiment protocol, research team journalIn "The Three-Body Problem" disputes are settled by experiment: a theory that cannot be measured is just an opinion. A test has the same nature - it must know what is correct from an oracle built from requirements and research, not from the code it checks. A test that reads its expected value from the implementation merely duplicates it - it will rubber-stamp every bug already living there. Hence the anti-patterns to eradicate: assertions copied from code, snapshots without understanding, mocks testing mocks.
A test must know what is correct from an oracle built from requirements and research, not from the code it checks. An assertion copied from the implementation merely duplicates it - it will rubber-stamp every bug already living there; hence the anti-patterns to eradicate: assertions copied from code, snapshots without understanding, mocks testing mocks.
Input: one risk from test-plan.md. Output: a test whose assertion actually fails on broken code. Mechanism: the mutation check - break the protected behavior on purpose and confirm the red; if the instrument does not scream after sabotage, it measures nothing. /10x-tdd enforces this order from the start: a red test before the code, green as proof, refactoring on protected ground.
for every test written by an agent - the oracle comes from requirements, and the proof of a test's quality is its red on broken code.
The test-first sibling of /10x-implement: it drives the phases of an approved plan through the red → green → refactor loop. The failing test is written before the production code - the oracle physically cannot be copied from the implementation, because it does not exist yet.
Two questions before each phase: does the implementation not exist yet, and can the phase be driven by a failing test. Existing code - stop and redirect to /10x-implement, because tests added after the fact are not TDD. Scaffolding, config, infra, visual polish - also a redirect: there a failing test drives nothing.
One test per behavior, named after the outcome ("returns 429 once the limit is exceeded"), assertions about results, not internals. The test must fail for the right reason: the missing behavior, not a syntax error in the test itself. Skipping a test with it.skip so it "passes" is forbidden - the red is the whole point.
The smallest production code that puts out the red - no building ahead, future behaviors will get their own RED step. Then cleanup with the test green: names, duplication, types - without changing behavior. Budget: 2-5 tests per phase, the ones that catch real regressions; not a test for a getter.
Testing implementation details (private state, call order), over-mocking (when everything is a mock, you are testing mocks), snapshots for business logic, near-duplicates under different names. And the iron rule: commit only on green - never with a red or skipped test.
"The cheap outer screen works first, then the deflectors, the armor last. Fire that reaches the hull is a failure of every layer."
- shield section officer, pre-battle briefingA cruiser does not take fire on its hull armor - that is what deflector shields are for, layer after layer, from the cheapest on the outside to the most expensive at the plating. Quality defense works the same way and is ordered by cost: per-edit (lint and typecheck seconds after a save) → pre-commit → pre-push. The farther an error flies, the more it costs to shoot down.
Quality defense is ordered by cost: per-edit (lint and typecheck seconds after a save) → pre-commit → pre-push. The later an error is detected, the more its fix costs.
Input: the project's quality rules - lint, typecheck, fast tests. Output: hooks wired to events - per-edit, pre-commit and pre-push, each with its own time budget. Mechanism: a self-checking pipeline - drift is detected seconds after it appears, in the background, with no human involved; the only things that reach the end of a phase are those no layer could have caught earlier.
when working with an agent that generates code faster than you can read - the error should go out at the cheapest layer, before it touches git history.
"A mock-up in the dock will not tell you whether the ship flies. Take her out, light the drive and read the instruments in flight."
- ship mechanic, before the test flightThe Rocinante did not prove she could fly on dock schematics - she proved it with a test flight: drive, navigation, hull and crew at once, in vacuum. An E2E test is the same maneuver: a flight through all modules at once - UI, API, data - exactly where a mock would lie. The rule of the cheapest test that gives signal applies: if a unit test is enough, E2E is a luxury; if the unit test lies, E2E is the only honest measurement. Signal is the goal, not coverage.
An E2E test is a pass through all modules at once - UI, API, data - exactly where a mock would lie. The rule of the cheapest test that gives signal applies: if a unit test is enough, E2E is a luxury; signal is the goal, not coverage.
Input: a running application and a risk from the plan that nothing cheaper can cover. Output: Playwright tests + a seed test preparing the data for the flight. Mechanism: /10x-e2e drives the risk through plan → generate → review → verify on the running application, multimodally - the agent reads the DOM and looks at screenshots at the same time, so it also sees what a selector cannot catch.
for critical paths - login, payment, data writes - E2E only where a mock would lie, not for chasing coverage.
It drives the plan's browser-level phases one risk at a time through the plan → generate → review → verify loop. An agent will generate a passing E2E test in seconds; the hard part is a test that protects a real risk and survives tomorrow's refactor - and that is exactly the work this loop does.
Three conditions at once: the risk genuinely requires a browser (it cuts across auth, routing, API and data, or exists only in the rendered UI), the feature is already built and runnable, and a test for this risk does not exist yet. Everything else - a redirect to /10x-tdd or /10x-implement: E2E is the most expensive and most brittle layer.
E2E tests are not generated from scratch. Quality is guarded by two levers: seed.spec.ts - the exemplar test every next one is modeled on (what you show is what you get), and the E2E rules file read before generation. The prompt carries only what the levers cannot encode: the specific risk, the flow and the real vs mock boundaries.
The agent sees the accessibility tree (roles, names, states), not pixels - hence getByRole locators come naturally, not CSS selectors. Internal boundaries (auth, routing, the database) stay real, because that is where the integration risk lives; only expensive or non-deterministic external APIs get mocked, at the network layer.
A generated test is not taken at its word. The review catches five anti-patterns: a hallucinated assertion, a brittle selector, shared state, waiting for time instead of state, missing cleanup. The fix is a re-prompt by the anti-pattern's name: what is wrong, why it does not protect the risk, which pattern should replace it - never a generic "fix this test".
A green result is not enough. The control question: will the test fail when the risk from the plan actually materializes? The proof is a deliberate break: intentionally breaking the protected behavior and confirming the red, then immediately restoring the pre-break state. Budget: one test per risk, rarely more than 1-3 per phase.
"Each of us carries a different tale, and none of them explains anything on its own. The truth lies where the tales intersect."
- the pilgrims' rule, on the way to the Time TombsThe pilgrims on their way to the Time Tombs reach the truth only because each one tells his own story - none of them explains anything on its own, all of them at once point to the same place. Debugging with an agent works exactly the same way: a synthesis of evidence from many sources - Sentry from production, wrangler logs from the backend, console and network from Playwright - instead of mastery of a single tool.
Debugging with an agent is a synthesis of evidence from many sources at once - Sentry from production, wrangler logs from the backend, console and network from Playwright - instead of mastery of a single tool. No source explains anything on its own; all of them at once point to the same place.
Input: a symptom - a user-facing error, a red test, an alert. Output: a diagnosis backed by evidence and a fix pinned with a test so the regression does not come back. Mechanism: collect readings from all the instruments at once and look for where the tales intersect; along the way, eradicate error swallowing - a try/catch returning 200 is sweeping evidence away (OWASP A10:2025), and it makes the next diagnosis start from zero.
when the symptom and the cause live in different layers - the diagnosis is made by the intersection of sources, not by the first suspicion.
Quality closes the 10xBuilder block. Foundation builds the launch ramp, the chain flies units of work, scaling raises rigor and autonomy, and quality makes sure that what flies does not fall.
Quality closes the 10xBuilder block. Foundation prepares the project, the chain delivers units of work, scaling raises throughput and autonomy, and quality makes sure the bar does not drop as the pace goes up.
From here the game moves into someone else's code: 10xArchitect opens the legacy module - inherited systems, no tests, the archaeology of decisions. Everything this module taught you on your own code comes back there with the stakes doubled.
The 10xBuilder block is behind you: the foundation, the chain and tests that actually catch bugs. Module 4 moves all of it into someone else's code - start with the lesson on the project map.
NO RESULTS // TRY ANOTHER QUERY