Andreas Heige

· 7 min · harness engineering, review, AI-native architecture

devsecops-workflow: a dual-loop way of working for coding agents

Contents · 8 sections

An agent left to itself writes the code, writes tests that agree with the code, reviews its own work and says “done”. Every step is graded by the same mind that made it.

devsecops-workflow is a Claude Code plugin that splits the work into roles and steps that check each other:

  • Two loops. An outer loop turns an idea into tickets. An inner loop takes one ticket from primed context to a landed PR.
  • The author never grades itself. A separate tester tries to break the code, a fresh-context reviewer judges the diff against the ticket, and a model from another family does the end-of-ticket review.
  • Every step proves itself. Each command states its end state and how to check it, and running the real thing (Level 4) can never be skipped.

Part of my Claude Code setup. Code: andreasheige/claude-plugins, plugin devsecops-workflow (MIT). Install: /plugin marketplace add andreasheige/claude-plugins, then /plugin install devsecops-workflow@personal-plugins. The end-of-ticket review uses review-loop.

The two loops

  1. plan-create-prd
  2. plan-architecture
  3. slice-epic one file per ticket
  4. prime-codebase
  5. plan-implementation
  6. implement red → green per step
  7. validate 5 levels + tester
  8. review-changes fresh-context reviewer
  9. commit
  10. eot review-loop, other family
  11. open-pr rebase, re-validate, risk, land
  1. slice-epic one file per ticket leads to prime-codebase: each ticket
  2. validate 5 levels + tester leads to implement red → green per step: any level fails
  3. eot review-loop, other family leads to implement red → green per step: blocking finding
  • plan-create-prd leads to plan-architecture
  • plan-architecture leads to slice-epic one file per ticket
  • prime-codebase leads to plan-implementation
  • plan-implementation leads to implement red → green per step
  • implement red → green per step leads to validate 5 levels + tester
  • validate 5 levels + tester leads to review-changes fresh-context reviewer
  • review-changes fresh-context reviewer leads to commit
  • commit leads to eot review-loop, other family
  • eot review-loop, other family leads to open-pr rebase, re-validate, risk, land
  • Outer loop: once per feature or epic
    • plan-create-prd
    • plan-architecture
    • slice-epic one file per ticket
  • Inner loop: once per ticket
    • prime-codebase
    • plan-implementation
    • implement red → green per step
    • validate 5 levels + tester
    • review-changes fresh-context reviewer
    • commit
    • eot review-loop, other family
    • open-pr rebase, re-validate, risk, land
Fig. 1 — The two loops

Outer loop

CommandProducesChecked by
/devsecops-workflow:plan-create-prddocs/prd/<name>.md: scope, non-goals, objectives, success metrics. Asks open questions before writingA script that requires Scope, Non-Goals and Success Metrics to be present and non-empty
/devsecops-workflow:plan-architectureAn architecture doc next to the PRD: components, interfaces, data flows, non-goalsThe same script for its sections, then a manual check that every interface maps to a listed component
/devsecops-workflow:slice-epicOne file per ticket in docs/tickets/, each with Scope, Files and a Definition of DoneThe script per ticket, plus a conflict check that flags files listed by more than one ticket

Tickets are sliced by concern, not by file: each should read as one change a reviewer could approve on its own.

Inner loop

StepCommandWhat happens
1prime-codebaseRead the ticket, then only the files it touches or must respect. List them back, so missing or bloated context is visible
2plan-implementationThe smallest ordered set of steps, each [step] → verify: [check]. A script rejects a step without a verify:; a human-style check rejects a vague one (“make sure it works”)
3implementPer step: red (write the test for that verify: and see it fail for the right reason), green (minimal code), run it again for real. Pure markup or styling steps skip red/green and say so
4validateFive levels, in order (below). Any failure goes back to the failing level
5review-changesAn architecture-reviewer subagent in a fresh context judges the diff against the architecture doc and the ticket’s Definition of Done
6commit, then eotreview-loop eot: scan, then a finder and a verifier from the other model family. Fix test-first, recheck at most twice, then a human decides
7open-prRebase onto the latest main (never merge), re-validate (a rebase can change behaviour), recheck, push, open the PR with its risk section. A risk:low PR lands through review-loop land; everything else waits for a human

Five validation levels

LevelWhatRule
1. Compile & lintType-checker, linterReal output, not “should pass”
2. Unit integrityThe tester subagent writes an adversarial suite against the diffThe implementer’s session never writes these tests
3. IntegrationTests over the ticket’s touched interfaces
4. Agent executionRun the changed code end to end and look at the real outputNever skippable. A green suite is not a substitute
5. Stack-specific + securityE2E or performance checks for the stack; the security pass runs after commit in eot

Level 4 is the one that matters most. “The tests pass” and “it works” are different claims, and agents are very good at the first while skipping the second. Running the app, the endpoint or the script and reading what it printed catches the bugs that live between tested units.

The tester: success is the code surviving

The tester is the part people ask about most. It’s a subagent with one job, to break code someone else wrote:

  1. It reads only the diff and the ticket’s requirements, not the implementer’s plan or reasoning. It tests what the code does, not what it was meant to do.
  2. It lists edge cases and failure modes: empty and null input, off-by-one, concurrency, hostile input, resource exhaustion, wrong types, permission edges.
  3. It writes a runnable suite aimed at those cases, not a restatement of the happy path.
  4. It runs the suite and reports failures honestly. A suite that only ever passes is suspicious.
  5. It mutation-checks every test. For each test, it breaks the code under test in exactly the way that test claims to catch (drop the scope, flip the comparison, make the predicate constant), confirms that test fails, then reverts. Inverting an assertion isn’t enough: that proves the assertion runs, not that it detects the bug.

Success is the Implementer’s code surviving your adversarial suite — not your suite passing easily.

It refuses to test code it wrote itself in the same session, and asks for a fresh dispatch instead.

One shape for every command

Every command uses the same four-part template, which is what makes a long chain of steps reliable:

TASK: <what, for $ARGUMENTS>

1. PRIMING: what must be in context, and nothing more
2. END STATE: the observable result that means "done"
3. VALIDATION PLAN: which levels apply, always including Level 4
4. GO: the steps, in order, with what is forbidden

The END STATE is written before the steps, so the agent knows what it is aiming at. The VALIDATION PLAN says how that will be proven. Deterministic checks (scripts/check-doc-structure.sh for PRDs, architecture docs, tickets and plans) do the mechanical part, so the model’s judgment goes to what a script can’t see.

Skills that come with it

  • verify-before-done: before saying “done”, “working” or “try it yourself”, run the five-level sweep. Level 4 has no exceptions, not even for “obviously correct” one-liners.
  • git-workflow: Conventional Commits, branch naming, rebase only. After a PR is merged, it removes the worktree and branch, but lists ignored files first so nothing local is lost.
  • cost-aware-orchestration: when the agent dispatches subagents, it picks each one’s model by how hard the task is, using real prices, instead of letting every subagent inherit the most expensive model.
  • dogma / dogma-deep: iterative reasoning for hard problems: solve, critique, refine, until the critic finds nothing substantive. The deep variant starts with three agents using different framings.

How it fits with the rest

  • plan-gate keeps the agent moving through a plan until it is done or a line says BLOCKED: <reason>. The inner loop’s step list is exactly such a plan.
  • review-loop does the end-of-ticket and end-of-epic review and decides what an agent may merge. If the CLI isn’t installed, eot falls back to the plugin’s own read-only security-reviewer subagent.
  • The guardrails deny git merge, plain force pushes and pushes to main, so rebasing on a branch is the path that works. My own harness also denies plain gh pr merge, which leaves review-loop land as an agent’s only way to merge; add that rule yourself if you want the same.

Adopt it

You don’t need all of it. In the order I’d add it:

  1. [step] → verify: [check] plans and Level 4 on every task. This alone changes the most.
  2. The tester subagent, dispatched against a diff, with the mutation check.
  3. A fresh-context reviewer that gets the ticket’s Definition of Done.
  4. The outer loop when work gets bigger than one ticket.
  5. review-loop at the end of each ticket, once you have a second model family available.

Write tickets with a real Definition of Done. Every later step judges against it, and a vague one makes every check vague too.

What didn’t work

  • The agent merged its own PRs. The first open-pr ended with gh pr merge, so the same agent wrote, reviewed and landed the change. It then stopped at the open PR for a while, and now lands only risk:low PRs through review-loop land, where code decides the tier.
  • The reviewer could only judge the architecture. It saw the diff and the architecture doc, so it couldn’t tell whether the change did what the ticket promised. It now gets the full ticket text, checks every Definition of Done line and quotes the line in its findings.
  • A green test wasn’t evidence. A test only counts as coverage once it has failed under the bug it guards against. Hence the mutation check, done by hand per test rather than with a mutation tool on every ticket.
  • A single-model security reviewer was noisy. On my golden set it raised 2.8 findings per clean commit. It’s been replaced by review-loop’s other-family review, and is kept only as a read-only fallback with no shell or web access.