Plan (QRSPI Step 7)
PRECONDITION: Invoke qrspi:using-qrspi skill to ensure global pipeline rules are in context. (Idempotent on session re-entry. Subagents are exempt — SUBAGENT-STOP in using-qrspi handles that.)
Announce at start: "I'm using the QRSPI Plan skill to create detailed task specs."
Overview
Break the structure into ordered, self-contained tasks following vertical slices and phases from the design. Each task spec includes exact file paths, descriptions, test expectations, dependencies, and LOC estimates. Large plans (6+ tasks) fan per-task specs out to sub-subagents.
Plan OWNS / Plan DEFERS
!cat skills/plan/owns-defers.md
Artifact Gating
Read config.md to determine pipeline mode. If config.md doesn't exist or has no route field, refuse to proceed and tell the user to re-run Goals. The route field is authoritative; pipeline is informational (see using-qrspi Config File).
Full pipeline (pipeline: full) — required inputs:
goals.md—status: approvedresearch/summary.md—status: approveddesign.md—status: approvedstructure.md—status: approvedphasing.md—status: approved
Quick fix (pipeline: quick) — required inputs: goals.md, research/summary.md — each status: approved. Design and Structure don't exist on quick.
If any required artifact is missing or not approved, refuse to run and name the missing artifact. Read config.md to determine whether Codex reviews are enabled.
Config Validation
Apply the Config Validation Procedure in using-qrspi/SKILL.md. Plan validates pipeline, route, second_reviewer, and (when pipeline: quick) question_budget.
<HARD-GATE>
Do NOT produce plan.md without all required artifacts approved (full: goals + research + design + structure; quick: goals + research).
Do NOT use placeholder content in task specs: no TBD, TODO, "similar to Task N", "add appropriate handling".
Every task spec must be self-contained — an implementation agent reading only that task must have everything it needs.
</HARD-GATE>
Execution Model
Subagent produces plan.md overview. For large plans (6+ tasks), per-task specs farm out to sub-subagents (one per task) to keep context manageable. Iterative with human feedback.
Phase-Scoped Content Rules
plan.md contains ONLY current-phase tasks. Each task must reference goal IDs that exist in goals.md. Tasks for goals not in the current phase must not appear. The goal_ids frontmatter list (e.g. [G1, G2] — see ID-Hygiene Contract below) must contain only IDs in goals.md. <!-- id-hygiene-exempt -->
Task Sizing
Each task implements exactly one observable behavior — one request handler, one use case, one user-visible change. The task title names exactly one feature, with no + joining feature names and no two distinct verbs joined by and.
LOC budget per task: Target ~100 LOC (matches OpenAI AGENTS.md). Policy ceiling 200 LOC — split unless sizing_exception (post-split frontmatter) or Sizing exception bullet (in-plan) names one of: schema migration, CI scaffolding, reusable primitives.
"LOC" = implementation source only (across files in Target files: excluding tests/). Test code has no ceiling but should be roughly 1.5–2× impl LOC. 100 src + 250 test = fine; 250 src needs sizing_exception or split.
Why: SWE-Bench Pro reports median patch 107 LOC / 4.1 files at ~23% frontier-model success (GPT-5, Opus 4.1). OpenAI AGENTS.md targets ~100 lines per agentic task. Our 200-LOC ceiling sits at the lower bound of Cisco/SmartBear's code-review sweet spot with margin for QRSPI scaffolding. Multi-feature titles like auth + allowlist + rename + admin are the visible symptom; the cause is bundling N request handlers into one task, re-coupling slices that vertical-slice decomposition exists to separate.
Splitting protocol. A task >200 LOC splits into N tasks at or below ~100 LOC, each implementing one handler with explicit dependency ordering. Closed exception set: schema migration, CI scaffolding, reusable primitives. Mark sizing_exception: <reason> (frontmatter, post-split) or Sizing exception bullet (in-plan), and explain in Description.
Floor — a task is too small if any hold:
- Does not traverse the layers needed for its behavior (UI-only, schema-only, mock-only, test-only)
- Produces no observable behavior change when merged alone (pure refactor with no callers, scaffold with no consumer)
- Depends on a sibling task to compile or pass tests
- Cannot be merged to main alone (must batch with peers to ship)
Failing a floor check → merge into the parent task that gives it observable behavior; do not ship sub-atomic tasks.
Schema-Migration Task Shape
A schema-migration task applies an identical mechanical change to N files of the same shape (e.g., deleting one frontmatter key from every agent file). This is the narrow exception to the LOC ceiling and file-count guidance. The full contract — eligibility, the mandatory sizing_exception: schema-migration + sizing_rationale: + structural_lint: trio, the script-path ERE, the diff-must-be-non-empty rule, and the six plan-spec defect conditions — lives in references/schema-migration-task-shape.md. Read that reference whenever authoring or reviewing such a task. The plan reviewer (agents/qrspi-plan-reviewer.md § Schema-migration exception review) enforces the same six defects.
Multi-Actor Flow Check
!cat skills/_shared/multi-actor-flow-check.md
Process
Plan Overview Subagent
Inputs: goals.md, research/summary.md, design.md, structure.md, prior feedback files.
Task: Break the structure into ordered tasks following vertical slices and phases.
- Pre-fanout absorption-map gate. Before drafting any per-task spec, run
scripts/design-absorption-markers.sh <design-path>and ingest the absorbed-goal redirect map (<absorbed-ID> → <absorbing-ID|"no-task">). For any goal ID present in the map, DO NOT draft a standalone task; if the original intent surfaces residual work that genuinely needs implementation, attach it to the absorbing CD's task scope, NOT to a new "post-<absorbing-ID> cleanup" wrapper task. If residual work genuinely fits nowhere in the surviving goal/CD set, halt with BLOCKED and surface the case to the user instead of manufacturing a task home. - Break structure into ordered tasks following vertical slices and phases from
design.md. - Each task spec includes: exact file paths to create/modify; description; test expectations in plain language (behaviors, inputs/outputs, edge cases, error conditions); dependencies; LOC estimate.
- No placeholders, no TBDs, no "similar to Task N" — each spec is self-contained.
PRECONDITION: skills/_shared/prompt-prose-detection.md, skills/_shared/prompt-prose-writer-addition.md, and skills/_shared/prompt-prose-test-expectations-clause.md MUST exist on disk; halt with a named diagnostic if any is missing rather than proceeding with empty include content.
!cat skills/_shared/prompt-prose-detection.md
!cat skills/_shared/prompt-prose-writer-addition.md
!cat skills/_shared/prompt-prose-test-expectations-clause.md
Small plans (<6 tasks): overview subagent writes the full merged plan.md directly. Large plans (6+): overview subagent writes plan.md overview only; per-task specs dispatch to sub-subagents — one per task. The fan-out shape is load-bearing for per-spec focus; a single merged-author subagent optimizes for cross-spec consistency over per-spec depth and drops edge cases.
Quick-Fix Plan Behavior
When config.md has pipeline: quick: the plan subagent receives goals.md + research/summary.md only (no design/structure) and produces a single-task plan directly — no sub-subagent dispatch, no merge/split lifecycle. The task spec derives file paths and test expectations from research findings and goals; merged plan.md carries both overview and the single spec. After approval, the task writes to tasks/task-01.md and plan.md reduces to overview-only. Review round, human gate, and approval process are identical to full pipeline.
Sub-Subagent Dispatch (Large Plans Only)
Compaction checkpoint: pre-fanout. Per-task spec-generation fan-out — one subagent per task. The orchestrator's post-fanout merge re-aggregates output into plan.md; that re-aggregation is where context saturation bites. See using-qrspi ## Compaction Checkpoints.
Surface a todo: title Recommend /compact (pre-fanout) — plan, description per-task spec fan-out merges into plan.md; user decides /compact..
Sub-subagent inputs: plan.md overview; relevant structure.md sections; design.md (for per-goal Acceptance blocks + vertical-slice context); skills/plan/owns-defers.md (the layer-depth clamp — without it, sub-subagents drift into Implement/Structure scope: algorithm pseudocode, regex grammar, literal-value hard-coding, line-numbered citations, exact @test counts, shebang/file-mode specifics); the three skills/_shared/prompt-prose-* shared files included at Plan Overview Subagent above (re-checked at dispatch; same PRECONDITION).
Each sub-subagent writes tasks/task-NN.md — and ONLY that file. Sub-subagents MUST NOT create or modify any implementation file (script, test, SKILL.md, agent body, etc.) the task describes; those land in Implement. After all complete, Plan appends each task file as a section to plan.md and deletes the individuals — single document is the only source of truth during review.
Per-Task Classification (`task_type` and `tier`)
Every task spec sets task_type and tier in frontmatter (the per-task model: field is retired in favor of tier:-based resolution through model_routing:). task_type selects the TDD or lightweight implementer dispatch chain; tier is consumed by the Tier Resolution Chain (scripts/_resolve-lib.sh), which maps the tier to a (vendor, model) pair via config.md's model_routing: block — NOT a per-invocation override.
task_type dispatch:
- Absent or
code— TDD path: whentask_type: code(or absent), the test-writer dispatches first, then the implementer, with the RED-verification gate between them. Absenttask_type:defaults to the TDD path identically. Dispatch order: test-writer → RED-verification gate → implementer. lightweight— whentask_type: lightweight, the lightweight-only dispatch fires: no test-writer, no RED gate. Dispatch order: implementer only. Implement dispatchesqrspi-implementer-lightweightdirectly.
TDD-task specs must carry an explicit dispatch-ordering note in ## Description or atop ## Test Expectations:
Dispatch order: test-writer → RED-verification gate → implementer.
Lightweight tasks omit this note.
Step 1 — Classify. Default code. Assign lightweight when the task's primary deliverable is prompt prose OR non-prompt prose / docs / config with no executable behavior to test. Apply the detection in skills/_shared/prompt-prose-detection.md (included at Plan Overview Subagent above; PRECONDITION re-asserted — halt with a named diagnostic if missing). Mixed-deliverable tasks require ALL target files to satisfy the lightweight test; otherwise default to code and split per Goal-Specificity if genuinely mixed. Prompt prose NEVER lands on the TDD path.
Step 2 — tier (run after task_type):
lightweight→tier: low. No exception.code→tier: highif any of:Target filescount > 3; any target matches a core-surface glob (skills/**/SKILL.md,skills/_shared/**,agents/qrspi-implementer*.md,agents/qrspi-implementer-lightweight*.md,skills/reviewer-protocol/**,skills/implementer-protocol/**); fix-task spawned by Replan (fix_task_retry: true); carriessizing_exception.- Otherwise →
tier: medium.
Operator override. tier: is editable before plan approval — the heuristic is a default, not a contract. Absent fields. Plans omitting task_type: and tier: are read by Implement as code with default_tier: from config.md and a one-line warning at dispatch — no hard failure.
Plan Document Structure (During Review)
The template below embeds information-mapping patterns: claim-before-evidence, one-paragraph-per-claim, scannable bullets, required structural slots (Phase / Target files / Dependencies / LOC estimate / Description / Test expectations). No brevity directives — they degrade factual reliability (Phare benchmark, Hakim). Per-task specs are short by structural design.
!cat skills/_shared/evergreen-output-rule.md
---
status: draft
phase_start_commit: null
test_writer_tier: null # optional: low | medium | high. When unset, per-task `tier:` drives co-escalated qrspi-test-writer dispatch (high-tier co-escalates implementer + test-writer). Set only to pin test-writer tier independent of per-task tier.
---
# Implementation Plan
## Overview
{Phase structure, task ordering, dependency graph}
## Phase N: {name}
{Tasks in this phase, ordering rationale}
### Phase N Acceptance Criteria
Per-phase criteria observable end-to-end at phase boundary (independent of any single task):
- [ ] {Criterion 1}
- [ ] {Criterion 2}
(Per-task criteria live in each `tasks/task-NN.md`'s `## Test Expectations`; this block captures cross-task observable behavior at phase end.)
---
## Task Specs
### Task 1: {name — one observable behavior; no `+` joining feature names; no two distinct verbs joined by `and`}
- **Phase:** 1
- **Target files:** {exact paths, create/modify}
- **Dependencies:** none
- **LOC estimate:** ~{N}
- **Sizing exception:** {only for legitimate bundles; reason ∈ {schema migration, CI scaffolding, reusable primitives}}
- **Description:** {observable-behavior sentence first, then context. Plain language; no function signatures (→ Structure); no pseudocode (→ Implement); no architecture rationale (→ Design).}
- **Test expectations:**
- {behavior 1 — plain language; no `expect(...)` or assertion code (→ Implement-TDD)}
- {edge case 1}
- {error condition 1}
### Task 2: {name}
...
Per-phase acceptance block authoring. Per-phase criteria trace upstream to goals.md goals but are AUTHORED in plan.md, not goals.md. The block lives directly under each ## Phase N: {name} heading. Downstream consumers (test/SKILL.md, qrspi-plan-spec-reviewer, qrspi-plan-goal-traceability-reviewer) read these to verify end-to-end observable behavior at phase boundary.
Conformance for per-task spec writer. Each spec satisfies: required-section presence; claim-line ≤ 250 chars per bullet; description paragraph ≤ 150 words; section ≤ 300 words before bullets split; no brevity directives ("be concise", "brief summary", "≤ N lines" are forbidden — see lint allowlist for legitimate length-target exceptions). The DEFERS list says what NOT to include; this says how to structure what IS.
Smoke-check requirement. Any task adding or modifying a route, page, layout, or user-facing component MUST include a smoke_checks: block per