Add QA subprocess loop and script-side template assembly#4
Draft
nick-inkeep wants to merge 1 commit intomainfrom
Draft
Add QA subprocess loop and script-side template assembly#4nick-inkeep wants to merge 1 commit intomainfrom
nick-inkeep wants to merge 1 commit intomainfrom
Conversation
…n scripts Restructures /qa from in-process execution to a subprocess iteration loop (matching /implement's architecture) and moves template assembly from the orchestrator into the shell scripts themselves. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Gives /qa the same subprocess iteration architecture that /implement uses: structured state file (qa.json), iteration prompt template, shell loop (qa.sh) that spawns fresh Claude Code subprocesses per scenario. Also moves template assembly out of the orchestrator and into the shell scripts themselves — both implement.sh and qa.sh now read their template, select the correct variant, compute a fresh diff, extract context from JSON, and fill all placeholders each iteration.
Architectural decisions
QA subprocess loop (new): Rather than running QA entirely in-process (single context window, no recovery), QA now follows the same pattern as /implement — an orchestrator generates
qa.json(structured test plan with scenarios), the script assembles the prompt from a template, andqa.shspawns fresh Claude Code subprocesses per scenario. Each subprocess picks up the next incomplete scenario, executes it, records results back to qa.json, and logs progress. The loop detects completion via a sentinel string and cross-verifies against qa.json.Script-side template assembly (both scripts): Previously the orchestrator (Phase 2 agent) had to read the template, select a variant, fill placeholders, and save the prompt — a multi-step manual process that was error-prone and couldn't refresh context between iterations. Now the scripts handle this: they accept
--spec-path,--typecheck-cmd,--lint-cmd,--test-cmdas CLI args, extract context fields from the JSON state file, compute a fresh git diff each iteration (with noise filtering and size-based fallback to stat tree), select the correct template variant (A: with SPEC.md, B: without), and use python3 for multi-line placeholder substitution. The orchestrator's job simplifies to: ensure the JSON state file has rich context fields, then run the script.qa.json schema: Modeled after spec.json but adapted for testing —
scenariosinstead ofuserStories,categoryfield for test classification,toolsper scenario,availableToolsat top level (detected once by orchestrator),resultwith richer status (pass/fail-fixed/blocked/skipped),successCriteriaas explicit pass/fail checklist, andtestContextfor system startup instructions.Changes
New files (QA infrastructure):
qa/scripts/qa.sh— Iteration loop (377 lines), mirrors implement.sh with QA-specific adaptations (reads scenarios, QA COMPLETE sentinel,--spec-pathfor variant selection)qa/scripts/validate-qa.ts— Schema + semantic validator for qa.json (sequential priorities, unique IDs, valid categories/tools, field types)qa/templates/qa-prompt.template.md— Two-variant prompt template (A: with SPEC.md, B: without) with{{PLACEHOLDERS}}for script-side assemblyqa/references/testing-guidance.md— Testing methodology extracted from SKILL.md (scenario categories, tool-specific execution patterns, formalization gate, depth calibration)Modified files:
implement/scripts/implement.sh— Added template assembly:compute_diff(),assemble_prompt(), noise filters, new CLI flags (--spec-path,--template,--typecheck-cmd,--lint-cmd,--test-cmd),{{DIFF}}injectionimplement/templates/implement-prompt.template.md— Added{{DIFF}}placeholder, updated source descriptions to reflect script-side assemblyimplement/SKILL.md— Simplified Phase 2 (no manual template crafting), updated Phase 3 invocation examples with new CLI flagsqa/SKILL.md— Restructured from in-process workflow to orchestrator + subprocess loop (5 phases: gather context, generate qa.json, template assembly, execute loop, report)ship/SKILL.md— Added qa.json and qa-progress.txt to state files table, updated Phase 3 to describe subprocess loop, updated exit gateTest plan
implement.sh --helpshows new flags (--spec-path,--template,--typecheck-cmd,--lint-cmd,--test-cmd)implement.shauto-detects template from../templates/implement-prompt.template.mdwhen--templateis omittedimplement.shassembles prompt correctly: variant A selected when--spec-pathprovided, variant B when omittedimplement.shcomputes diff with noise filtering (excludes lock files, tmp/, dist/, build/)implement.shfalls back to stat tree when diff exceeds 30K charsqa.sh --helpshows expected flagsbun validate-qa.tspasses against a well-formed qa.json and rejects malformed onesqa.shspawns subprocess, reads qa.json, attempts scenario executionqa.sh --max-iterations 1— verify subprocess reads state and attempts the scenarioGenerated with Claude Code