From qa-swarm
Implement fixes from a QA swarm analysis: write TDD tests, fix code by priority, loop until tests pass. Takes the 3 output file paths from a /qa-swarm:attack run.
How this skill is triggered — by the user, by Claude, or both
Slash command
/qa-swarm:implement <report.md> <spec.md> <tests.md><report.md> <spec.md> <tests.md>The summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are orchestrating QA Swarm implementation. You will write tests, fix code, and loop until green.
You are orchestrating QA Swarm implementation. You will write tests, fix code, and loop until green.
Use Claude Tasks (TaskCreate, TaskUpdate) throughout this pipeline to track progress. The user should always be able to see what has been done, what is in progress, and what remains.
Reference the implementation plan: The spec and report files contain the prioritized findings and fix details. All tasks you create should reference the relevant finding IDs and spec sections so that agents and the user can trace each task back to the plan.
After ingesting the report and the user selecting phases, create tasks structured as follows:
Mark tasks in_progress when starting work on them. Mark completed immediately when done -- do not batch completions. If a task fails or is skipped, update it with the reason.
Use these conventions in task descriptions:
IMPORTANT: Before modifying any code, verify that the current working tree is clean or committed. If there are uncommitted changes, warn the user:
Warning: You have uncommitted changes. If fixes go wrong, you may lose work.
Recommendation: Commit or stash your changes before proceeding.
Continue anyway? (Y/n)
Wait for confirmation before proceeding.
Parse the three file paths from the arguments: {$ARGUMENTS}
Expected: <report_path> <spec_path> <test_plan_path>
Parse the three file paths from the arguments. If fewer than three paths are provided, print:
Error: Expected 3 file paths, got {N}.
Usage: /qa-swarm:implement <report.md> <spec.md> <test_plan.md>
Example: /qa-swarm:implement docs/qa-swarm/2026-04-02-report.md docs/qa-swarm/2026-04-02-spec.md docs/qa-swarm/2026-04-02-tests.md
Run /qa-swarm:attack first to generate these files.
Then STOP.
Check that all three files exist. For EACH missing file, collect the error. If any are missing, print:
Cannot start implementation -- missing files:
{path_1} <-- not found
{path_2} <-- not found
Expected files in docs/qa-swarm/:
{date}-report.md (ranked findings)
{date}-spec.md (implementation spec)
{date}-tests.md (TDD test plan)
Run /qa-swarm:attack first to generate these files.
Then STOP.
Read all three files.
Parse the report to extract findings grouped by priority (P0, P1, P2, P3).
Count total findings per priority level. If total findings is 0, print:
No findings to implement -- the report contains 0 actionable findings.
Then STOP.
Check for an existing results file at docs/qa-swarm/{DATE}-results.md.
Present the user with a summary table and let them choose what to tackle:
QA Swarm Implementation
========================
Report: {report_path}
Spec: {spec_path}
Test Plan: {test_plan_path}
Phase | Priority | Issues | Status
-------|-------------|--------|------------
1 | P0 Critical | {N} | {status}
2 | P1 High | {N} | {status}
3 | P2 Medium | {N} | {status}
4 | P3 Low | {N} | {status}
Status key: Not started | Partial (N/M) | Done (N/N)
Options:
[A] All phases (P0 -> P1 -> P2 -> P3)
[1] Phase 1 only
[2] Phase 2 only
[3] Phase 3 only
[4] Phase 4 only
[1-2] Phases 1 through 2
[1,3] Phases 1 and 3
Select phases:
Wait for user selection before proceeding. Parse their input to determine which phases to run.
Once the user selects phases, create the full task tree using TaskCreate:
"TDD Setup: Write test files for selected phases""Phase 1: P0 Critical ({N} issues)" with description referencing the spec:
"Fix {N} P0 findings. See {spec_path} > P0 Fixes for implementation-ready details. Strict ordering: one at a time, 4 retry max, halt on failure.""Fix {finding_id}: {title}" with description:
"Location: {file}:{line}. Fix details: {spec_path} > P0 Fixes > Fix {finding_id}. Test: {test_file_path (once known)}. Confidence: {confidence}. Corroborated by: {N} agents.""Final test suite verification""Write results report to docs/qa-swarm/{DATE}-results.md"Mark the TDD Setup task as in_progress.
Check whether the Context7 MCP server is available in this session by looking for the tools mcp__context7__resolve-library-id and mcp__context7__query-docs. Record the result as context7_available: true | false. You will pass this flag to each test-writer agent.
If available, print: Context7 MCP detected -- test-writer agents will use it for current framework docs.
If not available, print: Context7 MCP not detected -- test-writer agents will rely on existing test conventions only.
ALREADY COVERED in the plan.test_file_path. Each group represents one test file's worth of work.slice-A, slice-B, slice-C.Print a partition summary:
TDD partitioning:
slice-A: {N} findings across {M} test files
slice-B: {N} findings across {M} test files
slice-C: {N} findings across {M} test files
Launch the test-writer agents in a single message with multiple Agent tool calls so they run concurrently. Each agent (model: sonnet, Mode 2) receives:
context7_available booleanEach agent returns a structured JSON summary:
{
"slice": "slice-A",
"files_written": ["tests/unit/test_auth.py", ...],
"tests_written": [{"finding_id": "P0-001", "test_name": "test_sql_injection_login", "file": "..."}],
"context7_queries": [{"library": "pytest", "purpose": "confirm fixture API"}],
"skipped": [{"finding_id": "...", "reason": "..."}]
}
After all 3 agents return, run the FULL test suite (detected test command for the project).
Classify each new test:
Tests already passing (removed from queue):
- {finding_id}: {title} -- likely already fixed or false positive
Mark that finding's sub-task completed with the "already passing" note.in_progress with a note, and continue -- the fix agent in Step 4 may correct it.Update each remaining finding sub-task description to include its test file path.
Mark the TDD Setup task as completed.
Execute selected phases in priority order (P0 always runs first even if user selected [2,1]).
Mark the Phase 1 task as in_progress.
For EACH P0 finding, one at a time:
Mark the finding sub-task as in_progress.
Print: Fixing P0: [{finding_id}] {title} (attempt 1/{max_retries})
Launch an implementation agent (model: opus) with:
After the agent completes, run the FULL test suite (not just the new tests).
Check results:
P0 [{finding_id}] FIXED. Mark the sub-task as completed. Move to next P0.HALTED: P0 [{finding_id}] could not be fixed after 4 attempts.
What was tried:
{summary of each attempt}
Last error:
{test output}
Options:
1. Type your fix guidance and I will retry
2. Type "skip" to move on
3. Type "abort" to stop implementation entirely
Wait for user input. If they provide guidance, retry with their instructions. If "skip", mark sub-task as completed with note "Skipped by user". If "abort", jump to Step 5.Mark the Phase 1 task as completed when all P0 findings are processed.
For each selected priority level (P1, then P2, then P3):
Mark the phase task as in_progress. Mark all finding sub-tasks in this phase as in_progress.
Print:
Implementing {N} P{level} fixes...
Launch an implementation agent (model: sonnet) with:
After the agent completes, run the FULL test suite.
Check results:
P{level} fixes complete: {N}/{N} fixed. Mark all sub-tasks and the phase task as completed.completed. Mark failing sub-tasks as completed with note: "Unresolved after 2 attempts: {error_summary}".
Skipped {N} P{level} fixes (unresolved after 2 attempts):
- [{finding_id}] {title}: {error_summary}
Mark the phase task as completed. Continue to next priority level.After all selected phases finish:
Mark the "Final test suite verification" task as in_progress.
Run the full test suite for verification.
Mark it as completed.
Mark the "Write results report" task as in_progress.
Update the results file incrementally at docs/qa-swarm/{DATE}-results.md.
Mark it as completed.
Print phase summary:
Phase(s) complete.
Fixed: {N}/{N} issues
Unresolved: {N} issues
Halted: {N} (required intervention)
Tests: {N} passing, {N} failing
If unselected phases remain, present the continue prompt:
Remaining phases:
Phase | Priority | Issues | Status
-------|-------------|--------|------------
3 | P2 Medium | {N} | Not started
4 | P3 Low | {N} | Not started
Continue? [3/4/3-4/A/done]
If user selects more phases:
If user selects "done" or no phases remain, proceed to Step 6.
Get today's date and save/update the results:
Write to docs/qa-swarm/{DATE}-results.md:
# QA Swarm Implementation Results
**Date:** {DATE}
**Source spec:** {spec_path}
**Duration:** {elapsed time if available}
## Summary
- Fixed: {N}/{total} issues
- Unresolved: {N} issues
- Halted: {N} P0s (required human intervention)
- Skipped (phases not selected): {N} issues
- Already passing: {N} issues
## Test Results
- Total tests: {N}
- Passing: {N}
- Failing: {N}
## Fixed Issues
{for each fixed issue}
### [{finding_id}] {title}
**Priority:** {P0|P1|P2|P3}
**Phase:** {N}
**Attempts:** {N}
**Fix applied:** {brief description of what was changed}
**Files modified:** {list}
## Unresolved Issues
{for each unresolved issue}
### [{finding_id}] {title}
**Priority:** {P0|P1|P2|P3}
**Attempts:** {max_retries}
**Last error:** {error message}
**What was tried:** {brief summary}
**Recommendation:** {what a human should look at}
## Halted Issues
{for each halted P0}
### [{finding_id}] {title}
**Attempts:** 4
**What was tried:** {summary of all 4 attempts}
**Why it failed:** {analysis}
**Recommendation:** {what needs human attention}
## Phases Not Selected
{list of phases the user chose not to run, with issue counts}
## Already Passing (Skipped)
{for each finding whose tests already passed}
- [{finding_id}] {title} -- {likely already fixed / false positive}
Print the summary:
QA Swarm Implementation Complete
===================================
Fixed: {N}/{total} issues
Unresolved: {N} issues
Halted: {N} P0s
Skipped: {N} (phases not selected)
Already OK: {N} (tests already passing)
Tests: {passing} passing, {failing} failing
Results: docs/qa-swarm/{DATE}-results.md
Next steps:
1. Review changes: git diff
2. Run your tests: {detected test command, or "your test command"}
3. Run linter: {detected lint command, if any}
4. Commit: git add -A && git commit -m "fix: resolve QA swarm findings"
5. Open a PR for review
Provides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.
npx claudepluginhub mistervitopro/qa-claude-market