AI with Zero Bugs in Ugly Code
Better brakes let drivers brake later.
"Better brakes don't just let you stop.
They let you stop caring about stopping."
Watching closely enough that nothing goes wrong is still toil. More stressful. Less interesting.
Brownfield teams have been here for years.
No AI required.
vigilance toil
Vigilance Toil ∝
throughput
× amt to protect
Greenfield: protect ≈ 0.
Brownfield: protect is large.
In brownfield, vigilance > work already.
Work toil down 75%
=> 4x more events
=> 4x more Vigilance Toil.
AI cuts work, raises total cost.
Find key moments in a transcript
A daily coaching workflow. Six transitions follow, each silencing one specific vigilance question.
Step 0 · Prompt Claude and watch
Command
▐▛███▜▌ Claude Code v2.1.117 ▝▜█████▛▘ Sonnet 4.6 with medium effort · Claude Max ▘▘ ▝▝ D:\coaching-clients\ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ I am working with my current client, redacto. We just completed a day's training session. Today with day 03 of series 01. I need to start working on the lesson plan for tomorrow and write a status email for today. To get started, I need you to do the following. 1. Use your fireflies MCP tool to get today's transcript. It will be too large to read into context in one step, so it'll get written to a file by the tool. Move that file to `clients// / /inputs/session-transcript.md`. 2. I downloaded the retro notes. They are in my Downloads folder. Move them into inputs as well. /clear ▐▛███▜▌ Claude Code v2.1.117 ▝▜█████▛▘ Sonnet 4.6 with medium effort · Claude Max ▘▘ ▝▝ D:\coaching-clients\ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ I am working with my current client, redacto. We just completed a day's training session. Today with day 03 of series 01. I need to start working on the lesson plan for tomorrow and write a status email for today. Our first step is to understand what happened. 1. Read `clients/ / / /inputs/session-transcript.md` and ` /retro.md`. 2. Interview me in the style of Arlo Belshee + Tricia Broderick. Ask one question at a time, and use the info you learn to fill in your understanding. Ask until you understand enough to record what happened. 3. Write down your insights at `clients/ / / /intermediate/key-moments.md`. Gather the information that we need in order to do lesson planning and create the status email.
I do
(click to load)
Step 1 · Written workflow
Command
Read `workflow/find-insights.md` and follow it.
I do
(click to load)
Step 2 · Narrow goal
Command
Read `workflow/find-insights.md` and follow it.
I do
(click to load)
Step 3 · Document iteration pattern
Command
Read `workflow/find-insights.md` and follow it.
I do
(click to load)
Step 4 · pnpm do-today
Command
pnpm do-today
I do
(same as before)
Step 5 · Scripted fetch
Command
pnpm do-today
I do
(same as before)
Step 6 · Iterative analysis
Command
pnpm do-today
I do
(click to load)
Example 1
Example 2
vigilance toil
Vigilance Toil ∝
throughput
× amt to protect
× cost to protect
We control the protection cost factor by building systems.
Where vigilance toil comes from
Two kinds of engineer
If your AI is one of the developers, you are the tool builder.
Make even crappier AI succeed.
How?
The agent's universe
Safety Categories
The recipe
Pick one to explore
Case studies
Goals
Tooling
Workflow
Feedback
Memory
State control
Reachable Context
Recipe
Worked example — three iterations
PaymentService from OrderProcessoryour customers
Synthesis
Discovery during demos
"Does this contradict a decision from earlier in the session? Are we building on conflicting assumptions?"
Main Levers: Memory + Reachable Context
The AI cannot blend old ideas with new ones.
It has no access to old ideas.
This direction was always the plan. It doesn't know otherwise.
Name the experience
Scope
Cross-session decision inconsistency.
Cost to protect
Zero: conflicting decisions are structurally impossible.
Lever
Memory + Reachable Context.
Recurring structured output
"Does this email follow the same structure as last time? Did it include the right sections for day N/10?"
Main Lever: Goals
Claude writes sentences. Deterministic code assembles everything else.
Structure, recipients, rendering: zero-risk zones. Forever.
Name the experience
Scope
Format and structure drift in recurring output.
Cost to protect
Zero. Structure, recipients, and rendering each become zero-risk zones.
Lever
Goals (structured spec).
Structural refactoring in legacy code
"Did my restructuring change what the code actually does?"
AST tools solve this for human developers. What about AI?
Main Lever: Tooling
Design correctness
AI can be wrong.
Undo is as easy as do.
Behavioral safety
Guaranteed by the tool.
Not possible to violate.
Only the first failure mode remains possible.
Name the experience
Scope
Behavior preservation during refactoring.
Cost to protect
Zero within scope. Behavioral safety is guaranteed by the tool.
Lever
Tooling (operation semantics).
Database migrations
"Did the migration change what the data means? Can I recover it if something went wrong?"
Main Lever: State control
1. Archive table: all rows preserved before migration runs.
2. Bidirectional remapping: deterministic verification before execution.
3. Extracted library: AI writes the definition; the library executes.
Deterministic pre → AI creative decision → deterministic execution.
Name the experience
Scope
Schema migrations against live data.
Cost to protect
Zero. Data loss is structurally impossible.
Lever
State control (Determinism sandwich).
Code review under agentic load
"Did the AI land code that's technically correct but full of things a reviewer would flag?"
Main Lever: Feedback
Lint, type, tests, dead code, complexity, missing-test heuristics. Each problem tagged must-fix or could-fix.
The AI sees its own code through the reviewer's filter and re-invokes commit until the report is clean.
The human only sees commits that already passed.
Name the experience
Scope
Known code-quality categories at commit time.
Cost to protect
Zero on those categories. Deterministic checks fire synchronously at the moment of action.
Lever
Feedback (the tool result is the quality verdict).
User-visible work
"Did the AI ship something that looks done and passes tests but doesn't actually work?"
Main Lever: Feedback
Two timescales. Three actors.
All deterministic.
Name the experience
Scope
"Is this demo-able?" for every user-visible chunk.
Cost to protect
Zero. The plan tool gates advancement on demo verification.
Lever
Feedback (multi-actor, multi-timescale loops).
TDD with an agent
"Did Claude skip the refactor and shove logic into the test? Write the test after the code? Mix test edits and production edits in the same change?"
Main Lever: Workflow
One workflow, five universes.
A Minions mission orchestrates the sequence. Deterministic code handles commits and chooses the next phase.
No single Claude call can do TDD wrong
because the wrong move isn't in its toolbox.
Name the experience
Scope
TDD discipline across one feature's inner loop.
Cost to protect
Zero. Phase bleed is structurally impossible at each boundary.
Lever
Workflow (phased mission; tools and writable surface change per phase).
Brownfield monorepo
"Did my change to package A silently alter package B?"
Main Lever: Reachable Context
Shrink what the agent can see to exactly what its task should touch.
The agent can use other packages correctly. It cannot silently change them.
Name the experience
Scope
Cross-package change inside a monorepo.
Cost to protect
Zero. Other packages' implementations are not in the agent's reachable surface.
Lever
Reachable Context (API-only exposure across the boundary).
Multi-phase migration
"Did the AI optimize for the eventual shape and skip the partial-progress state I asked for?"
Main Lever: Reachable Context
Truncate the horizon to the next durable resting point.
Premature optimization for the wrong target becomes structurally impossible.
Name the experience
Scope
Multi-phase re-design with intermediate landing states.
Cost to protect
Zero within the current phase. Future phases simply do not exist for this execution.
Lever
Reachable Context (horizon truncated per phase).
Findability in legacy code
"Did the AI miss the relevant code because grep wasn't the right way in?"
Main Lever: Reachable Context
Expand the reachable surface in a direction that matches how the agent asks questions.
The agent can find code by intent, not just by literal token. "Did it miss anything?" shifts from often-yes to occasionally-yes.
Name the experience
Scope
Code findability across a large codebase.
Cost to protect
Reduced, not zero. Semantic search complements lexical search; misses get rarer.
Lever
Reachable Context (a semantic index added to the agent's reach).
Planning under uncertainty
"Did the AI lock in on the first plausible option without exploring the space?"
Main Lever: Reachable Context
Hide the comparison from the agents being compared.
probably-wrong branch per option, replacing the node with a commitment to that option.Each branch executes one option as well as it can, because alternatives are not in its reachable context.
Name the experience
Scope
Plan-time option exploration across uncertain design space.
Cost to protect
Zero. Option exploration is structural; per-branch focus is total.
Lever
Reachable Context (alternatives hidden per branch).
What we did each time
Memory · Reachable Context · Goals · Tooling · Workflow · State control · Feedback
Each choice created a zero-risk zone. Each zone permanently freed vigilance budget for the next thing.
vigilance toil
Vigilance Toil ∝
throughput
× amt to protect
× cost to protect
Vigilance toil is the cost of having to worry about whether you can stop.
engine
Throughput and skill.
brakes
Careless AI still succeeds.
"Better brakes let you stop caring about stopping."
Recipe — Step 1
Worked example — extract PaymentService
PaymentService from a 4 000-line OrderProcessor.behavior-equiv-check stage in the extract pipeline.The loop is standing. Time to pick what to attack first.
Recipe — Step 2
Worked example — extract PaymentService
@Transactional spans.Selected: Behavior change.
Recipe — Step 3
Worked example — extract PaymentService
try/catch in OrderProcessor.refund() swallowed a StripeException; the extracted version re-throws it.Recipe — Step 4
Worked example — extract PaymentService
edit-file out of the toolbox. Hand the agent an AST extract-method-to-class transform instead.Recipe — Step 5
Worked example — extract PaymentService
Next loop: select transaction-boundary preservation.
Recipe — Step 6
Worked example — extract PaymentService
PaymentService seams — still at Vigilance level.Vigilance about behavior, transactions, and observability is gone, permanently.
Worked example — extract PaymentService
Same scope. Same expectation list, shrinking.
One category gets locked per loop.
Iteration 1
Spot-check
Diff OrderProcessor.refund() against extracted version; trace every exception path.
Categories surfaced
Exception shape changed. Side-effect order changed. Return type widened.
Lever applied
Tooling. Remove edit-file; require an AST extract-method-to-class transform.
Outcome
Behavior change locked — structurally impossible within the transform's scope.
Iteration 2
Spot-check
Diff the call graph reachable under each @Transactional annotation, before vs after.
Categories surfaced
Transactional method moved out of its enclosing span. Nested transaction created where there was none.
Lever applied
Tooling. Extend the refactor to refuse moves that break transactional scope; surface the violation as a structured error.
Outcome
Transactional-scope drift locked at the structural level.
Iteration 3
Spot-check
Set difference on log statements and metric names; trace-span boundary comparison.
Categories surfaced
Log lines silently dropped. Metric counter renamed without alias. Trace span collapsed across the seam.
Lever applied
Tooling + Feedback. Add a "no orphan log / no orphan metric" lint as a commit gate; pipe its result back to the agent before it tries again.
Outcome
Observability loss locked. The agent self-corrects before commit.
Three loops in
Every extraction now ships with three permanently-free categories.
Between agent turns: two different agents
Between agent turns: two different agents