adversarial-implementation
Automated adversarial implementation framework using Claude Code Agent Teams. Takes a final-plan.md from the adversarial-proposal skill and produces a vetted implementation document with exact code diffs, test specifications, and a coverage matrix proving every plan item is addressed. Two agents work independently — a Surgical Implementer (minimal diffs) and a Coverage Guardian (complete tests) — then a Synthesizer merges them, both critique, and the Synthesizer reconciles into a final implementation.md. Use this skill after adversarial-proposal completes, or whenever the user wants to create an implementation document from a plan. Trigger on phrases like "create implementation", "implement the plan", "adversarial implementation", or "implementation doc".
- License 许可
- MIT
- 最近更新
- 2026-10-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- adversarial-implementation
- description
- Automated adversarial implementation framework using Claude Code Agent Teams. Takes a final-plan.md from the adversarial-proposal skill and produces a vetted implementation document with exact code diffs, test specifications, and a coverage matrix proving every plan item is addressed. Two agents work independently — a Surgical Implementer (minimal diffs) and a Coverage Guardian (complete tests) — then a Synthesizer merges them, both critique, and the Synthesizer reconciles into a final implementation.md. Use this skill after adversarial-proposal completes, or whenever the user wants to create an implementation document from a plan. Trigger on phrases like "create implementation", "implement the plan", "adversarial implementation", or "implementation doc".
02 资源文件 7
- 参考文档agents/critic.md2.2 KB
- 参考文档agents/guardian.md3.6 KB
- 参考文档agents/implementer.md3.6 KB
- 参考文档agents/reconciler.md4.0 KB
- 参考文档agents/synthesizer.md4.7 KB
- 参考文档references/implementation-format.md3.8 KB
- 参考文档references/subagent-fallback.md9.7 KB
03 SKILL.md 正文
Adversarial Implementation Framework
Overview
This skill takes a final-plan.md (typically from the adversarial-proposal skill) and produces a complete, vetted implementation.md with exact code diffs, test specifications, and a coverage matrix that proves every plan item is addressed.
The same adversarial process that works for planning applies here: two agents independently produce implementation documents from the same plan, a synthesizer merges the best of both, the original agents critique the synthesis, and the synthesizer reconciles into a final implementation document.
The critical output is the coverage matrix — a table mapping every plan item to a specific code diff and a specific test. Zero gaps allowed.
When to Use
- After
adversarial-proposalproduces afinal-plan.md - When you have any implementation plan and want vetted, exact diffs before coding
- When previous implementations have missed items from the plan
- When testing coverage is critical
Prerequisites
This skill requires Agent Teams (TeammateTool, SendMessage). Enable with:
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
If Agent Teams is not available, see references/subagent-fallback.md for an alternative using the Task tool with file-based coordination.
Architecture
INPUT: final-plan.md (from adversarial-proposal or any plan)
─────────────────────────────────────────────────
ROUND 0: Setup
─────────────────────────────────────────────────
Lead reads final-plan.md → extracts source files + plan items
Strategy pair: A=Surgical, B=Coverage
ROUND 1: Independent Implementation Planning (parallel)
─────────────────────────────────────────────────
Agent A (Surgical) Agent B (Coverage Guardian)
┌──────────────────┐ ┌──────────────────┐
│ Own context │ │ Own context │
│ │ │ │
│ Sees ONLY: │ │ Sees ONLY: │
│ - final-plan.md │ │ - final-plan.md │
│ - Source files │ │ - Source files │
│ - Test files │ │ - Test files │
│ │ │ │
│ Focus: minimal │ │ Focus: complete │
│ diffs, correct │ │ coverage, tests │
│ ordering │ │ for everything │
│ │ │ │
│ CANNOT see B ─────┼── ✗ ──────┼── CANNOT see A │
│ │ │ │
│ → impl-A.md │ │ → impl-B.md │
└───────────────────┘ └───────────────────┘
◄── Quality check + Convergence check ──►
ROUND 2: Synthesis
─────────────────────────────────────────────────
Synthesizer C
┌──────────────────────────────────────┐
│ Phase 0: Reads plan + source files │
│ Phase 1-2: Reads impl-A + impl-B │
│ Phase 3: Verifies diffs against src │
│ Phase 4: Merges into impl-C.md │
│ Phase 5: Writes isolated reviews │
│ │
│ → impl-C.md (lead-only) │
│ → review-for-A.md (A's eyes only) │
│ → review-for-B.md (B's eyes only) │
└──────────────────────────────────────┘
ROUND 3: Feedback (parallel, ISOLATED)
─────────────────────────────────────────────────
Agent A Agent B
┌──────────────────┐ ┌──────────────────┐
│ Reads ONLY: │ │ Reads ONLY: │
│ - review-for-A.md │ │ - review-for-B.md │
│ + own impl-A.md │ │ + own impl-B.md │
│ │ │ │
│ → feedback │ │ → feedback │
└──────────────────┘ └──────────────────┘
ROUND 4: Reconciliation
─────────────────────────────────────────────────
Synthesizer C
┌──────────────────────────────────────┐
│ Receives feedback from A and B │
│ Verifies disputed diffs against src │
│ Reconciles into implementation.md │
│ → implementation.md │
└──────────────────────────────────────┘
OUTPUT: implementation.md (in same directory as final-plan.md)
Why Two Strategies
| Agent | Strategy | Focus | Catches |
|---|---|---|---|
| A (Surgical) | Minimal diffs, correct ordering | Unnecessary changes, over-engineering | — |
| B (Coverage) | Complete tests, nothing dropped | Missed plan items, untested changes, broken existing tests | — |
The natural tension: A wants to do less, B wants to cover more. The synthesis finds the right balance — every plan item addressed, but no unnecessary bloat.
How to Execute
When the user triggers this skill, you (the lead) orchestrate the entire workflow.
Step 0: Gather Context
- Get the path to
final-plan.mdfrom the user's command - Read the final plan — extract:
- All source file paths referenced
- All test file paths referenced (or derive them from source paths)
- Every discrete plan item (these become the coverage matrix rows)
- Determine output directory — same directory as
final-plan.md - Rename existing review files if they exist from the proposal phase:
review-for-A.md→proposal-review-for-A.mdreview-for-B.md→proposal-review-for-B.md
- Read the agent role files to embed in prompts:
agents/implementer.mdagents/guardian.mdagents/synthesizer.mdagents/critic.mdagents/reconciler.mdreferences/implementation-format.md
Step 1: Round 1 — Spawn A and B (Parallel)
Spawn both agents in the same turn for parallel execution.
Agent A prompt must include:
- Full content of
final-plan.md - List of source file paths to read and verify
- Implementer role (from
agents/implementer.md) - Implementation format (from
references/implementation-format.md) - Strategy assignment: Surgical — minimal diffs, correct ordering
- Output path:
{output_dir}/impl-A.md - Investigation notes path:
{output_dir}/impl-notes-A.md - Isolation rule: do NOT read impl-B.md or any other impl files
Agent B prompt must include:
- Same plan and source files
- Guardian role (from
agents/guardian.md) - Same implementation format
- Strategy assignment: Coverage — complete tests, nothing dropped
- Output path:
{output_dir}/impl-B.md - Investigation notes path:
{output_dir}/impl-notes-B.md - Isolation rule: do NOT read impl-A.md or any other impl files
Both prompts must instruct the agent to WAIT after completing, not exit.
Wait for both — with the output watchdog. An agent that produces no output while "running" is indistinguishable from one that is working, and a silent inbox is not evidence of work. All four rules apply here and at every later wait in this workflow:
- Poll for output. Verify bytes on disk before assuming progress. Round 1 polls
{output_dir}/impl-A.mdand{output_dir}/impl-B.md; Round 2 polls{output_dir}/impl-C.md+review-for-A.md+review-for-B.md; Round 3 polls{output_dir}/impl-feedback-A.mdandimpl-feedback-B.md; Round 4 polls{output_dir}/implementation.md. - Timeout budget. 5 minutes per implementer or critic (Rounds 1 and 3); 8 minutes for the synthesizer and the reconciler (Rounds 2 and 4). The budget expires only against an absent file, never against an inbox status.
- Ping once, then keep waiting. Ping once via SendMessage — a ping can wake a wedged agent. No reply does not mean dead: a pinged agent can surface minutes later, so never conclude a silent agent is gone.
- Distinct output paths for any replacement. A re-spawned agent MUST write to a distinct path from the original (
impl-A.md→impl-A-r2.md) so a late-waking original cannot clobber it.
After both arrive: quality check (coverage matrix present, diffs included, tests specified) then convergence check.
Step 1.5: Quality Check
Verify each implementation doc has:
- Plan items inventory — all items from the plan listed
- Implementation steps with exact
old_string → new_stringdiffs - Coverage matrix with Status column
- Test specifications (new and modified)
- Commit groups
- Definition of done
If a doc fails, message the agent with specific feedback and request revision.
Step 1.6: Convergence Check
If both implementations produce the same diffs and same tests for all plan items, skip Rounds 2-3. Spawn C for a lightweight review (verify diffs against source, check for missed items), then produce implementation.md directly.
Step 2: Round 2 — Spawn C
Spawn synthesizer with:
- Instruction to read source files FIRST (Phase 0)
- Then read impl-A.md and impl-B.md
- Synthesizer role (from agents/synthesizer.md)
- Produce THREE files: impl-C.md, review-for-A.md, review-for-B.md
- Isolation rules for review files
- Wait for instructions
C's round is complete only when all three files exist on disk. Apply the output watchdog above (8-minute budget, ping once, -r2 paths for a replacement).
Step 3: Round 3 — Message A and B
When C completes, message both agents with their review files. Same isolation rules as the proposal skill. Each message must also require the critic to save its feedback to {output_dir}/impl-feedback-A.md (resp. impl-feedback-B.md) — the file is what the output watchdog polls (5-minute budget, ping once, -r2 paths for a replacement); a reply alone leaves nothing on disk to verify.
Step 4: Round 4 — Forward Feedback to C
When both feedback messages arrive, forward to C with the reconciler role. C produces implementation.md. Apply the output watchdog to this wait too (8-minute budget, ping once, implementation-r2.md for a replacement).
Step 5: Cleanup and Present
Shutdown all agents. Present implementation.md to the user. Offer to:
- Show the full deliberation trail
- Explain specific decisions
- Proceed to execute the implementation
- Re-run any round
Building the Agent Prompts
Each prompt must be self-contained — embed everything inline.
What to Embed in Every Prompt
- The full content of
final-plan.md— verbatim - Source file paths — explicit list of every file to read and verify
- Test file paths — existing tests that may need updating
- The agent role — full content from the relevant
agents/*.mdfile - The implementation format — full content from
references/implementation-format.md - The output path and filename — exact save location
- The isolation rule — for A and B in Rounds 1 and 3
- The strategy assignment — Surgical for A, Coverage for B
- The "wait" instruction — tell agents to wait after completing
Critical Instruction for All Agents
"You MUST read every source file referenced in the plan BEFORE writing any diffs. Verify that line numbers, function signatures, and variable names in the plan match the actual code. If they don't, use the actual code — do not copy stale references from the plan."
Error Handling
Agent Timeout / Exit Recovery
How a failure is DETECTED. "Fails" below is not a guess. An agent has failed only when all three hold, in order:
- Its timeout budget has expired — 5 minutes for an implementer or critic (Rounds 1 and 3), 8 minutes for the synthesizer or reconciler (Rounds 2 and 4).
- Its deliverable is still absent from disk — the paths named in the output watchdog (Step 1), not an inbox status.
- One ping via SendMessage has gone unanswered for a further budget.
No reply does not mean dead. A ping can wake a wedged agent minutes later, so a silent agent must never be assumed gone — which is exactly why every replacement below writes to a distinct path.
| Round | Failure | Recovery |
|---|---|---|
| Round 1 | One agent fails | Wait for the other. C reviews single doc for gaps. |
| Round 1 | Both fail | Abort workflow. Report to user. |
| Round 2 | Synthesizer fails | Re-spawn C writing to distinct paths (impl-C-r2.md, review-for-A-r2.md, review-for-B-r2.md). If second attempt fails, present both raw docs. |
| Round 3 | One agent fails | Proceed to Round 4 with available feedback. |
| Round 3 | Both fail | Proceed to Round 4 with no feedback. C reconciles from synthesis alone. |
| Round 4 | Synthesizer fails | Re-spawn reconciler writing to a distinct path (implementation-r2.md). If second attempt fails, present impl-C.md. |
Quality Gate Failures
If an implementation doc fails the quality check after Round 1, message the agent with specific feedback and request revision before proceeding.
Known Tradeoffs
Reconciler bias toward own synthesis: Same as the proposal skill — C naturally favors its own impl-C.md when reconciling. The reconciler role includes bias awareness guidance, but for critical implementations, review the synthesis yourself before feedback rounds.
Diff staleness: Between the time agents read source files and the time implementation.md is produced, the source code could change (if someone is actively coding). The implementation doc captures a point-in-time snapshot. If the code changes, diffs may need re-verification.
Invoking the Skill
Direct Prompt
/adversarial-implementation .dev/proposals/caption-audio-sync-drift/final-plan.md
As a Claude Code Command
Save as .claude/commands/adversarial-implementation.md:
Read the adversarial implementation skill at .claude/skills/adversarial-implementation/SKILL.md.
Use the workflow described to produce an implementation document from the given plan.
Create a 3-agent team: implementer-a (Surgical) and implementer-b (Coverage Guardian) work
independently (FULLY ISOLATED), synthesizer-c reviews both and produces a synthesis. Then A
and B critique C. C reconciles into a final implementation.md.
Plan path: $ARGUMENTS
Output Directory
Files are saved in the same directory as the input final-plan.md:
{project}/.dev/proposals/{issue-slug}/
├── final-plan.md ← Input
├── impl-A.md ← Round 1: Surgical Implementer
├── impl-B.md ← Round 1: Coverage Guardian
├── impl-notes-A.md ← Round 1: A's investigation notes (subagent fallback)
├── impl-notes-B.md ← Round 1: B's investigation notes (subagent fallback)
├── impl-C.md ← Round 2: Synthesis (lead-only)
├── review-for-A.md ← Round 2: C's review for A
├── review-for-B.md ← Round 2: C's review for B
├── impl-feedback-A.md ← Round 3: A's feedback (subagent fallback)
├── impl-feedback-B.md ← Round 3: B's feedback (subagent fallback)
└── implementation.md ← Round 4: FINAL DELIVERABLE
Reference Files
| File | When to Read | Purpose |
|---|---|---|
references/implementation-format.md |
When building agent prompts | Implementation doc template to embed |
references/subagent-fallback.md |
If Agent Teams not available | Alternative workflow using Task tool |
agents/implementer.md |
When building A's prompt | Surgical implementer role |
agents/guardian.md |
When building B's prompt | Coverage guardian role |
agents/synthesizer.md |
When building C's Round 2 prompt | Synthesis role |
agents/critic.md |
When messaging A and B in Round 3 | Feedback guidance |
agents/reconciler.md |
When messaging C in Round 4 | Reconciliation + bias awareness |
Agent Roles Summary
| Agent | File | Used In | Purpose |
|---|---|---|---|
| Implementer | agents/implementer.md |
Round 1 (A) | Surgical: minimal exact diffs |
| Guardian | agents/guardian.md |
Round 1 (B) | Coverage: tests for everything, nothing dropped |
| Synthesizer | agents/synthesizer.md |
Round 2 (C) | Merge best of both, verify against source |
| Critic | agents/critic.md |
Round 3 (A and B) | Review synthesis, flag issues |
| Reconciler | agents/reconciler.md |
Round 4 (C) | Reconcile feedback, produce final implementation.md |
04 同仓库更多 Skills
forge-orchestrator
tmux-based orchestrator for multi-agent building. Coordinates work across Claude Code and two Codex workers via forge-bridge. Translates user requests into dispatched tasks with structured audit logging. Replaces forge-dispatch, forge-state.yml, and stage-routing-map.yml.
forge-fix-runner
Drain the GitHub `forge-fix` issue queue through the forge fix pipeline, one service at a time. Tallies actionable issues worst-first, scouts a service into a routing plan (clusters + quick/full tiers), gets human approval, then dispatches fixes (quick = dispatched fix-code; full = forge-pipeline), gating every `Closes #N` on per-issue verification. Trigger when the user wants to fix triaged QA issues, "work the forge-fix queue", or "run the fix runner".
forge-coder
Procedural coding skill. Reads implementation.md, validates diffs against the codebase, applies changes in execution order, runs tests after each commit group, and produces a coder-report.md artifact.
fix-reproducer
Optional first stage of the fix-pipeline. Verifies a reported bug is reproducible and captures deterministic repro steps, environment state, and evidence. Single procedural executor — does not spawn sub-agents and does not diagnose. Branches by environment: dev path runs the bug locally; prod path gathers observational evidence from the deployed environment. Always writes repro.md, even on NOT REPRODUCED. Trigger when the user invokes a fix-pipeline with the reproduce step enabled.
fix-plan-reviewer
Single-agent adversarial reviewer for fix plans. Reads diagnosis.md and fix-plan.md, verifies the plan actually addresses the diagnosed cause, attacks the plan from multiple angles (cause coverage, defense adequacy, scope correctness, regression risk, rollback integrity, test plan integrity, risk honesty), and produces fix-review.md with severity-rated issues. Does NOT propose fixes for the issues — that is the revise mode of adversarial-fix-plan. Does NOT re-investigate the diagnosis. Trigger as the review stage of a fix-pipeline, after adversarial-fix-plan has produced fix-plan.md.
fix-coder
Mechanical single-executor that applies a vetted fix plan to the codebase. Reads fix-plan.md (the Changes, Defenses, and Test Plan sections), translates file-level changes into concrete diffs, applies them, runs the test plan, validates that the bug is no longer reproducible (dev) or that the test exercising the failing path passes (prod), and produces a single fix commit. Stays strictly in scope: does NOT modify the plan, does NOT re-investigate, does NOT touch files outside the plan. Always writes fix-coder-report.md, even on failure. Trigger as the implementation stage of a fix-pipeline, after fix-plan-reviewer has approved fix-plan.md.