The problem
Using AI to write code is easy. Using it to deliver production systems responsibly, repeatedly, across several large codebases, is a different problem with a different failure mode.
The assistant does not know what the system is. Given a large repository it infers structure from names and directory layout. In our codebases that inference is actively wrong: several components share names, and a substantial subtree does not run at all. The result is not gibberish — it is a confident, well-argued change to the wrong component.
Context is expensive and mostly wasted. Letting an assistant explore freely burns a large token budget rediscovering things that are already written down, then runs out of room for the actual task.
Every task gets the same model. Extracting a field from a struct and designing a recovery contract are not the same problem, but they were routed to the same model at the same cost. Overpaying on trivial work and underpowering hard work, simultaneously.
Review quality is inconsistent when I am the only reviewer. Reviewing my own work — including work an assistant produced under my direction — misses the same class of thing every time, because it is my blind spot doing the reviewing.
AI in the commit path is slow and non-deterministic. Calling a model on every commit makes commits slow, expensive and variable. The same commit can pass and fail on different days, which destroys trust in the gate.
The dangerous failure is a confident wrong change. Not a syntax error — those are caught immediately. A plausible change that violates an invariant nobody wrote down.
Previous workflow
Before: AI assistance without a method
Everything here works for a small codebase. None of it survives contact with a large one.
- Human action
Describe the task in a chat window
- Problem: Requirement stated conversationally, not written down
- Problem: No acceptance criteria before work started
- AI / LLM
Assistant explores the repository
- Problem: Large token spend rediscovering documented facts
- Problem: Architecture inferred from names, and names collide here
- Problem: Ran out of context before the actual task
- AI / LLM
Assistant proposes a change
- Problem: Plausible changes to the wrong component
- Problem: Invariants violated because they were never stated
- Problem: Same model for trivial and architectural work
- Human action
I review it
- Problem: Reviewing my own direction — consistent blind spots
- Problem: Contract violations skimmed past
- Problem: No second perspective available
- Automated software
Commit and push
- Problem: Inconsistent formatting and lint discipline
- Problem: No secret scan before push
- Problem: Content schema errors found at build, not at commit
- Human action
Deploy and hope
Decision point: Was that safe?
- Problem: Verification depended on remembering to do it
- Problem: No standard post-deploy check
- Human action
- Automated software
- AI / LLM
Goals and non-goals
Goals
- An assistant starts from written architectural truth rather than inference.
- Context is assembled deliberately, not discovered expensively.
- Model selection matches the task class, in capability and in cost.
- Deterministic checks run on every commit with no model involved.
- AI review adds a second perspective before push, where it is cheap.
- No production mutation happens without human approval.
- Diagnosis is read-only until an action is explicitly approved.
Non-goals
- No AI in the commit gate. Deliberate. Gates must be fast and deterministic.
- No autonomous deployment. Ever.
- Not a replacement for understanding the system. The workflow makes me faster at work I could do; it does not let me ship what I do not understand.
- Not model-vendor-specific. The routing tiers are roles, not product names.
My role
I wrote this workflow and I am its primary user. It is the reason the other case studies in this portfolio exist at the scale they do.
- Authored the repository operating manuals — the architectural truth, the invariants with their evidence, the commands, and the definition of done.
- Designed the context strategy — context packs, generated repository maps and task cards, replacing free exploration.
- Set the model routing policy — which class of task gets which tier, and which tasks get no model at all.
- Built the deterministic gate set — formatting, linting, type checking, secret scanning and content-schema validation, all without an LLM call.
- Defined the approval boundary — read-only diagnosis, human approval for mutation, audit trail throughout.
- Ran it across every project here — platform, delivery engine, data pipelines, agent governance and this portfolio site.
- Revised it from failures — most rules here exist because something went wrong without them.
Product solution
The operating manual is the foundation. Each repository carries a document that states what the system is, which architectural claims are true today, the invariants that must not break with a pointer to the evidence for each, the build and validation commands, and the definition of done. An assistant reads this first, every time. It is also what a new human contributor reads first — the two audiences want the same document.
Context packs replace exploration. Rather than letting an assistant search a large repository, the relevant material is assembled: the operating manual, a generated map of the relevant subtree, the specific files in scope, and the task card. Exploration beyond that is limited and deliberate.
Task cards make the unit small. A task card carries the goal, the acceptance criteria, the files in scope, the invariants that apply, and the sensitivity level of the data involved. Small enough to fit in context with room to think.
Model routing by task class. Deterministic facts get no model — a query, a grep or a script answers better and for free. Extraction and summarization go to an inexpensive tier. Architecture and security review go to a strong tier. Production incidents get the best available reasoning, because that is where being wrong is most expensive. Fallbacks exist for provider trouble, and spend is tracked.
Deterministic gates at commit. Formatting, linting, type checking, secret scanning and content-schema validation run on every commit. Fast, repeatable, no model, no network.
AI review before push. Once the deterministic gates pass, the diff goes to a model for review against the repository's invariants. This is where a second perspective is cheap and I am at my weakest — reviewing my own direction.
Human approval for anything that mutates production. Diagnosis is read-only. An action requires a person. Enforced structurally by the agent governance layer for automated agents, and by process for interactive work.
Workflow
Requirement to verified production change
Two AI steps, four deterministic gates, and a human at both ends.
- Human action
Write the requirement
Goal, acceptance criteria and explicit non-goals. Written down before any assistant is involved.
- Automated software
Assemble the context pack
Operating manual, generated repository map, in-scope files, task card, sensitivity level.
- Data store
Retrieve grounded background
Hybrid search over curated internal documentation for the relevant invariants and prior decisions.
- Automated software
Route the task
Decision point: Deterministic fact — no model. Extraction or summary — inexpensive tier. Architecture or security — strong tier. Production incident — best available reasoning.
- AI / LLM
Implementation under budget
Bounded token spend against a task card with acceptance criteria and the applicable invariants stated.
- Human action
I review the change
Against the acceptance criteria and the invariants, before any gate runs.
- Approval gate
Deterministic commit gates
Format, lint, type check, secret scan, content-schema validation.
Decision point: Any failure blocks the commit. No model involved, no network call, same result every time.
- AI / LLM
AI review before push
The diff reviewed against the repository's invariants — a second perspective where I have consistent blind spots.
- Approval gate
Human approval to deploy
Decision point: No automated deployment. A person decides, always.
- Automated software
Deploy with a rollback path
Behavior changes ship behind flags that default to off, so deploying and changing behavior stay separate events.
- Automated software
Post-deployment verification
Smoke checks and health verification against the documented expected state.
- Monitoring / feedback
Observe and feed back
An incident becomes an invariant, a check or a runbook — not just a fix.
- Human action
- Automated software
- AI / LLM
- Data store
- Approval gate
- Monitoring / feedback
Architecture
The workflow as a system
Written artifacts, routing policy, gates and approval points. The tooling is replaceable; the structure is the product.
Written truth
Read first by both humans and assistants.
Repository operating manual
Data store
What the system is, which architectural claims hold today, and the definition of done.
Invariants with evidence
Data store
Rules that must not break, each pointing at the code or document that proves it.
Code map
Data store
Which tree is authoritative, which names collide, and which subtrees do not run.
Runbooks and failure modes
Data store
How the system actually breaks, including the failures that are silent.
Context assembly
Generated repository map
Automated
Structural map produced from the code rather than described by hand.
Task card
Automated
Goal, acceptance criteria, files in scope, applicable invariants, sensitivity level.
Knowledge retrieval
Data store
Hybrid search over curated documentation for prior decisions and applicable rules.
Sensitivity classification
Approval gate
Determines what may appear in a prompt at all. Secrets and production data never do.
Model routing
No model
Automated
Deterministic facts — a query, a grep or a script. Faster, free and exactly correct.
Inexpensive tier
AI / LLM
Extraction, summarization, mechanical transformation.
Strong tier
AI / LLM
Architecture, security review, non-obvious design work.
Premium reasoning
AI / LLM
Production incidents, where being wrong is most expensive.
Cost and rate tracking
Monitoring
Spend tracked per task class; fallbacks defined for provider trouble.
Gates
Deterministic commit gates
Approval gate
Format, lint, type check, secret scan, content-schema validation. No LLM call.
Pre-push AI review
AI / LLM
Diff reviewed against the repository's invariants.
Human deploy approval
Approval gate
No automated deployment under any circumstances.
Post-deploy verification
Monitoring
Smoke checks against a documented expected state.
Diagram is sanitized for publication: it shows responsibilities and data flow, not hostnames, addresses or credentials.
Where AI is used — and where it is not
AI / LLM responsibilities
- Implementation against a task card with stated acceptance criteria.
- Architecture review — challenging a design before it is built.
- Pre-push diff review against the repository's invariants.
- Incident reasoning and hypothesis generation, read-only.
- Documentation synthesis from code, and drift detection.
- Summarizing prior decisions retrieved from the knowledge base.
Deterministic responsibilities
- Every commit gate: format, lint, type check, secret scan, schema validation.
- Test execution and the pass or fail result.
- The repository map, generated from code.
- Sensitivity classification of what may enter a prompt.
- Deployment, which additionally requires human approval.
- Post-deploy health verification.
- Cost and rate tracking.
- Any factual question a query or script can answer exactly.
Decisions and tradeoffs
No LLM call in the commit gate
- Options considered
- AI review on every commit · AI review on large commits only · Deterministic gates only, AI review before push
- Chosen
- Deterministic gates at commit; AI review at push
- Reason
- A gate must be fast and give the same answer every time. A model in the commit path makes commits slow, costly and non-deterministic — the same commit can pass and fail on different days, which destroys trust in the gate itself.
- Cost and risk accepted
- Problems only a model would catch survive until the push review.
- Result
- Commits stayed fast and trustworthy. AI review sits where a few minutes is acceptable.
Curated context packs instead of free repository exploration
- Options considered
- Let the assistant explore · Automatically generate full context · Curated pack with limited exploration
- Chosen
- Curated pack: operating manual, generated map, in-scope files, task card
- Reason
- Free exploration burned most of the budget rediscovering documented facts, then reached confident wrong conclusions from colliding names.
- Cost and risk accepted
- Curation is ongoing work, and a pack that misses something relevant produces a change that misses it too.
- Result
- Materially better output at lower cost. The failure mode moved from confident-wrong to visibly-incomplete, which is far easier to catch.
Route by task class rather than using one model
- Options considered
- One strong model for everything · Cheapest model with escalation · Explicit routing by task class
- Chosen
- Explicit routing, including a no-model tier
- Reason
- Extraction and architecture are different problems. Using one model for both means overpaying on one and underpowering the other at the same time.
- Cost and risk accepted
- Routing rules to maintain, and occasional mis-routing that needs a retry at a different tier.
- Result
- Cost fell and quality rose on the tasks that matter. The no-model tier turned out to be the most valuable rule.
Invariants written with evidence, not just stated
- Options considered
- Document architecture narratively · List rules · List rules, each with a pointer to its proof
- Chosen
- Rules with evidence pointers
- Reason
- A stated rule with no evidence rots into folklore, and nobody can tell whether it is still true. A rule with a pointer can be checked and, when it stops being true, noticed.
- Cost and risk accepted
- Every invariant needs evidence maintained alongside it.
- Result
- The single most useful artifact for onboarding both humans and assistants.
Human approval for every production mutation, without exception
- Options considered
- Approval for risky changes only · Approval above a change-size threshold · Approval always
- Chosen
- Approval always
- Reason
- 'Risky' is an assessment made before the incident. A threshold-based rule requires judgment precisely when judgment is under pressure, and the assessment that fails is the one nobody questioned.
- Cost and risk accepted
- I am a bottleneck on every production change, including trivial ones.
- Result
- Accepted deliberately. This is the rule I am least willing to relax.
Challenges
Confident wrong changes were the real danger. An assistant produced a well-reasoned change to a component that does not run in production, because the directory looked authoritative. It passed review because the reasoning was sound. The code map exists because of that, and it is the artifact I would write first in any new repository.
Documentation drift makes the whole method degrade. The workflow rests on written truth. When the writing goes stale, assistants confidently reproduce stale architecture, and the confidence is unchanged. A documentation check that fails on the specific drift that has bitten us before was the answer — including commands that silently print nothing when run without elevated privileges, which reads as "no logs" rather than "wrong command".
Task cards were too large at first. Multi-part cards produced changes that were partly right, and reviewing a partly-right large change is harder than reviewing two small ones. Smaller cards with tighter acceptance criteria fixed it, at the cost of more decomposition work up front.
Model routing needs actual cost visibility. The initial routing rules were my guesses about which tier suited which task. Without tracked spend they stayed guesses. Tracking cost per task class turned the policy into something evidence can adjust.
I am the bottleneck, by design. Human approval on every production change means everything queues behind me. I have not solved this and I am not trying very hard to, because the alternative is relaxing the rule I trust most.
The 50% figure is self-reported. It comes from my own observation of requirement-to-verified-change time across these projects, not from an instrumented measurement system. It is labeled that way wherever it appears.
Testing and validation
| Layer | What it covers | Evidence |
|---|---|---|
| Acceptance criteria | Every task card states what done means before implementation starts. | Definition of done in each repository's operating manual. |
| Deterministic gates | Format, lint, type check, secret scan, content-schema validation on every commit. | Git hooks configured per repository; no LLM call. |
| Test-first bug fixes | A failing test that reproduces the defect is written before the fix. | Applied to every defect; the test is the acceptance criterion. |
| AI pre-push review | Diff reviewed against the repository's invariants. | Run before push, after deterministic gates pass. |
| Integration and end-to-end | Per-project suites — package tests, browser automation, delivery simulators. | Documented in each project's case study. |
| Human approval | Every production mutation. | Enforced structurally for automated agents, by process for interactive work. |
| Post-deploy verification | Smoke checks against a documented expected state. | Per-project verification runbooks. |
| Rollback | Behavior changes ship behind flags defaulting to off. | Reverting behavior does not require reverting code. |
Results
| Measure | Before | After | How it is measured |
|---|---|---|---|
| Requirement to verified change | Baseline before this workflow. | 50% faster. | Written requirement to verified production change, across the projects in this portfolio. Self-reported. |
| Assistant grounding | Architecture inferred from names, in codebases where names collide. | Operating manual, invariants with evidence and a code map read first, every time. | The same documents onboard human contributors. |
| Context cost | Most of the budget spent rediscovering documented facts. | Curated packs: manual, generated map, in-scope files, task card. | Exploration beyond the pack is limited and deliberate. |
| Model cost fit | One model for every task, regardless of difficulty. | Four tiers including a no-model tier, routed by task class with tracked spend. | The no-model tier removed cost from tasks a query answers exactly. |
| Commit gate reliability | Inconsistent formatting and lint discipline; no secret scan. | Five deterministic checks on every commit, no LLM call, same result every time. | Fast enough not to be worked around, which is why they hold. |
| Agent-assisted diagnostic volume | Diagnosis was manual and ad hoc. | More than 53,000 recorded agent runs across three agents, spanning over 125,000 steps. | Counted from the run and step tables. Read-only diagnosis; every production mutation still required a human. |
| Production change safety | Deploy and hope, with verification depending on memory. | Human approval always, flags defaulting to off, documented post-deploy verification. | No exceptions; the rule has no threshold to argue about. |
The cycle-time figure is self-reported from my own observation across these projects, not from an instrumented measurement system. The structural changes below are verifiable from the repositories themselves.
Evidence
Repository operating manual
Architectural truth, invariants with evidence, commands and definition of done.
Placeholder — evidence pending sanitization review before publication. Invariants document
Rules that must not break, each with a pointer to its proof.
Placeholder — evidence pending sanitization review before publication. Deterministic commit gate output
Format, lint, type check, secret scan and schema validation on a real commit.
Placeholder — evidence pending sanitization review before publication. Model routing policy
Task classes mapped to tiers, including the no-model tier.
Placeholder — evidence pending sanitization review before publication.
Lessons
What worked. Writing invariants with evidence. It is the cheapest artifact in the workflow and it does the most work — it onboards humans, grounds assistants, and gives the pre-push review something concrete to check against.
What failed. My first instinct was to put AI review in the commit gate, on the theory that earlier is better. It made commits slow and non-deterministic, and a gate that gives different answers on different days stops being a gate — people start working around it. Fast and deterministic beats thorough, at that position in the pipeline.
What changed. The no-model tier. Recognizing that a large share of what I was asking a model to do was a factual question a query answers exactly — faster, free and without the possibility of being wrong — changed both cost and accuracy.
What I would do differently. I would write the code map before the first task, not after the first confident wrong change. Every repository has a version of "which tree is real", and it is two pages that prevent hours of debugging the wrong component.
What this demonstrates about AI-product leadership. This workflow is an argument that the value of AI in delivery comes from the structure around it, not from the model. Written truth, assembled context, routing by task class, deterministic gates and human approval at the boundary. The model is replaceable; the structure is what makes the output trustworthy — and being able to say precisely where a model is not allowed to operate is what makes it defensible to anyone responsible for the system.
Next milestone
- Mechanical invariant checks. Invariants are documented with evidence and enforced at review. Turning each into a check that fails a build removes the dependence on a reviewer noticing.
- Instrumented cycle-time measurement, so the improvement figure comes from data rather than from my own observation.
- Routing policy driven by tracked spend, replacing the initial guesses with evidence about which tier actually suits which task class.