name: Qcode-run-task description: "Post-implementation quality loop — runs the test → review → fix → retest cycle on code that was just modified, delegating to Eqa-orchestrator by default. Branch points: use THIS after code changes are already on disk and need verification (test failures, type errors, lint hits, coverage gaps); use Qrun-task to EXECUTE a spec/checklist from scratch (this skill runs automatically at the end of its code items); use Qatomic-run for parallel Haiku-wave execution of independent atomic items. Triggered automatically for type:code tasks." invocation_trigger: When code has been modified and needs a quality loop (test-review-fix). recommendedModel: haiku tier: core
Code Quality Verification Loop Skill
When to Use
- Use this skill when: you need to understand or configure the quality verification loop process (test -> review -> fix -> retest cycle definition and procedure)
- Default execution: The quality loop is delegated to
Eqa-orchestratorby default to save main context tokens. The manual step-by-step mode below is for reference and opt-in use only.
Role
An assistant that ensures quality by performing a test → review → fix → retest cycle after code implementation is complete.
MANDATORY: All user confirmations (iteration continue, fix/complete/stop, loop limit) MUST use the interaction adapter. Claude MUST use
AskUserQuestion. Codex interactive may use concise plain-text choices. Codex non-interactive applies the safe recommended default and reports it.
Client Adapter Compatibility
- Claude: default delegation uses
Eqa-orchestratorvia Agent tool. - Codex native: use native Codex subagents if explicitly available.
- Codex inline fallback: if equivalent automatic delegation is unavailable, run the QA roles inline and report
codex-inline-degrade. - Command rendering: examples and handoffs use
adapter.commandPrefix.
Wiki Knowledge Pull (조건부 — .qe/wiki/가 있을 때만)
review/fix 전, test -d .qe/wiki가 참이면 변경 파일 관련 누적 지식(conventions·gotcha·결정)을 회수한다 —
node <QE plugin>/scripts/lib/wiki-retrieve.mjs "<변경 요지/파일>" (cwd=현재 프로젝트) → 리뷰 기준에
반영(tier: reviewed 우선). .qe/wiki/가 없으면 명령 실행 없이 조용히 skip(비-wiki 무영향).
Prerequisites
- Step 3 (implementation execution) of
/Qrun-taskis complete - Task has
type: codespecified in TASK_REQUEST - TASK_REQUEST and VERIFY_CHECKLIST documents exist
In the primary Qplan chain, /Qcode-run-task is the verification stage that follows /Qatomic-run.
Workflow Overview
Qrun-task Step 3 complete (implementation done)
↓
[Qcode-run-task starts]
↓
Step 1: Collect context
↓
Step 2+3: Test + Review (parallel)
├── Ecode-test-engineer (test)
└── Ecode-reviewer (review)
↓
Step 4: Issues found → Fix (Ecode-debugger) → Return to Step 2+3
No issues → Step 5
↓
Step 5: Report results
Loop Limit
- Maximum iterations: 3
- Use the interaction adapter to confirm continuation at each iteration
- If 3 iterations are exceeded, delegate judgment to the user and report current state
Default Execution: Eqa-orchestrator Delegation
By default on Claude, delegate the entire quality loop to the Eqa-orchestrator sub-agent via Agent tool. This is the recommended approach because:
- Saves main context tokens (only final summary returns)
- Eqa-orchestrator internally coordinates Ecode-test-engineer, Ecode-reviewer, and Ecode-debugger
- Supports automatic escalation from MEDIUM to HIGH tier on repeated failures
Information to pass on delegation:
- List of changed files (from
git diff --name-only) - TASK_REQUEST content (functional goals, constraints)
- VERIFY_CHECKLIST content (validation criteria)
- Project test structure and patterns
After Eqa-orchestrator returns, proceed directly to Step 5 (Report Results) using the returned summary.
On Codex, use a native Codex subagent if one is explicitly available. Otherwise
run the same test/review/fix roles inline and label the report
codex-inline-degrade.
Manual Execution Procedure (Opt-in)
Step 1: Collect Context
Identify changed code and related documents.
- Read TASK_REQUEST_{UUID}.md to confirm task goals and checklist
- Read VERIFY_CHECKLIST_{UUID}.md to confirm validation criteria
- Collect the list of files changed/created during the implementation step
- Use
git diff --name-onlyto check changed files - If no changed files, ask the user for target files
- Use
Context summary output:
## Quality Verification Targets
**Task:** [Task name] (UUID)
**Changed files:** N files
- [file list]
**Validation criteria:** M items (see VERIFY_CHECKLIST)
Step 2+3: Test + Review (parallel)
Spawn both agents in parallel using a single message with two Agent tool calls:
Agent 1 — Ecode-test-engineer:
- List of changed files and paths
- "What is wanted" section from TASK_REQUEST (functional goals)
- Validation criteria from VERIFY_CHECKLIST
- Existing test structure and patterns in the project
- Scope: unit tests, VERIFY_CHECKLIST criteria tests, regression tests
Agent 2 — Ecode-reviewer:
- List of changed files and paths
- Notes from TASK_REQUEST (constraints)
Collect results from both before proceeding to Step 4:
Collect review results:
## Review Results (Iteration N/3)
### Critical (must fix)
- [file:line] description
### Warning (recommended fix)
- [file:line] description
### Suggestion (improvement proposal)
- [file:line] description
Step 4: Judgment and Fix
Assess based on combined test and review results.
Step 4.5: Phase Goal Alignment (QE Verifier Logic)
... (omitted) ...
Step 4.6: Regression Gate
... (omitted) ...
Step 4.8: Cross-Phase Regression Gate
Before declaring the Phase complete, verify prior phases have not regressed:
- Resolve the active plan (session binding →
.qe/planning/ACTIVE_PLAN→ flat fallback) and read.qe/planning/plans/{slug}/ROADMAP.md(or flat.qe/planning/ROADMAP.mdfor legacy projects) to identify completed phases - For each completed phase, re-verify key items from its VERIFY_CHECKLIST (in
.qe/checklists/completed/) - Focus on: file existence, test suite passes, build success
- If regression found, report and block completion until fixed
- Implementation:
hooks/scripts/lib/regression-gate.mjsprovidesbuildRegressionPlan(),checkPriorPhaseTests(),formatRegressionReport()
Skip conditions:
- Phase 1 (no prior phases to regress)
- Non-code tasks (
type: docsortype: analysis)
Step 4.85: Smoke Test Gate
After all review/regression gates pass, verify that the code changes actually work in the real system — not just that they compile or pass self-review.
Why this gate exists: Self-referential verification (Claude reviewing Claude's code) suffers from self-preferential bias. Code that looks correct to review may fail when actually executed. This gate requires external ground truth.
Procedure:
- For each changed
.mjsfile, run:node -c {file}(syntax check) ANDecho '{}' | node {file}(execution test for hooks) - For changed JSON files (plugin.json, schema), run:
node -e 'JSON.parse(require("fs").readFileSync("{file}","utf8"))' - For new modules with exports, run:
node -e 'import("./{file}").then(m => console.log(Object.keys(m)))' - For plugin changes, verify:
claude plugin installwould accept the manifest (check against known valid fields) - For hook changes, test with sample input:
echo '{"cwd":"/tmp"}' | node hooks/scripts/{handler}.mjs
Failure handling:
- Any execution error → treat as Step 4 failure, enter fix loop
- Syntax errors → Critical, must fix before proceeding
- Runtime errors on sample input → Warning, investigate before proceeding
Skip conditions:
type: docsortype: analysistasks- Changes to
.mdfiles only (no executable code)
Step 4.7: Nyquist Audit (Gap Discovery)
Even if tests pass, perform a Coverage Gap Audit:
- Review implementation vs. Requirements.
- Identify: Are there any "Ghost Requirements" (implied but not tested)?
- Audit: Do the tests cover edge cases (null inputs, network timeouts, etc.)?
- If gaps are found, add them to the Decimal Phase list for the next iteration.
Pass criteria:
- 0 test failures (Current + Prior phases)
- 0 review Critical items
- 100% Alignment with Phase Goal and Requirements
On pass: → Proceed to Step 5
On failure:
Report discovered issues to the user
Confirm with the interaction adapter:
- "Fix and re-verify" → proceed with fix
- "Complete as-is" → proceed to Step 5 (Warning/Suggestion can be ignored)
- "Stop" → report current state and exit
If a fix is needed:
- Delegate the fix to the
Ecode-debuggersub-agent via Agent tool on Claude, or native Codex subagent/inline degraded fix on Codex - Pass on delegation: test failure details + review Critical items + related code
- After fix is complete, return to Step 2 (test) → loop counter +1
- Delegate the fix to the
When loop counter reaches 3:
## Loop Limit Reached (3/3) Issues not yet resolved: - [remaining issue list] User judgment is required.- Confirm with the interaction adapter: "Additional attempt" / "Complete as-is" / "Manual fix"
Step 4.8: Comment Coverage Gate
After test+review, verify documentation coverage of changed code:
- Run
checkComments()fromhooks/scripts/lib/comment-checker.mjson all changed files - Report format: "Comment coverage: {documented}/{total} ({coverage}%)"
- Threshold: 80% minimum for public functions, classes, and exported symbols
- Below 80%: Warn and list undocumented items (optional fix)
- Below 50%: Flag as FAIL in verification (blocks completion)
Skip conditions:
- Type:
docsoranalysistasks - Test-only files or internal utilities marked with
@internalJSDoc
On failure (below 50%):
- Report uncovered items to the user
- Delegate documentation fix to
Ecode-debuggerwith coverage report - After fix, re-run comment checker and return to verification
- If coverage reaches 80%+, proceed to Step 5
Step 4.86: Native Verification Alternatives
Before running the self-referential QA loop, consider these Claude Code native alternatives that eliminate self-preferential bias:
Option A — /goal (Recommended for bias-free verification)
Set a completion condition evaluated by a separate lightweight model:
/goal all tests pass and no lint errors, or stop after 10 turns
The /goal evaluator is a different model from the one doing the work, which breaks the self-preferential bias that caused the 27-hook incident. See /goal docs.
Option B — claude ultrareview (External code review)
Run a cloud-hosted multi-agent code review:
claude ultrareview --timeout 10
This is an external review service, not self-review. Use when the changes are substantial enough to warrant independent verification.
When to use native vs PSE verification:
- Simple code changes (≤3 files): PSE Qcode-run-task is sufficient
- Complex changes with external dependencies: Use
/goalwith measurable condition - Large refactors or PR-ready code: Use
ultrareviewfor independent review
Step 4.9: Adversarial Gate
After all verification passes (Steps 4–4.8), run the mandatory Verify gate —
an adversarial stress-test before final completion. This is the SIVS Verify-stage
self-reference defense; full protocol:
skills/Qcritical-review/reference/verify-gate-protocol.md.
Applies to type:code AND type:other (R3 — always mandatory; no ≤ N items
skip). Skip only type: docs/analysis. Any missing/unrecognized type is
normalized to gate-running (never silently bypassed). In Utopia --work the gate
still runs for code/other (the --work skip applies only to docs/analysis) and
runs non-interactively; --qa is mandatory as before.
Procedure:
- Invoke
/Qcritical-review --stage verifywith:- Changed files list (from Step 1)
- TASK_REQUEST goals and constraints
- VERIFY_CHECKLIST validation criteria
- Qcritical-review spawns the three Verify-stage agents (Critical mode) —
Devil's Advocate (cross-model when codex reachable), Security Auditor,
Performance Skeptic — that stress-test:
- Unhandled edge cases in the implementation
- Assumptions that were never validated
- Security implications of the changes
- Regression risks for adjacent functionality
- Results feed back into judgment (FAIL routes backward, not a dead-end — DECISION_LOG D014/D015):
| Verdict | Action |
|---|---|
| PASS | Proceed to Step 5 (Report) |
| WARN | Interactive: ask user "Fix and re-verify" / "Accept warnings" / "Stop". Non-interactive (Utopia --work): auto-accept + log. |
| FAIL | Backward routing. Per-finding root_cause_stage: spec → regenerate the spec (Spec gate) and restart; otherwise → Implement (fix loop via Ecode-debugger, return to Step 2). Unclear cause → nearest-first (Implement). Honors the 3-round Loop Limit; after 3 rounds still FAIL → escalate to user (Utopia --work: leave needs-attention with a blocking marker, never silent auto-proceed). |
Output:
[Adversarial Gate] PASS — no critical issues found
or
[Adversarial Gate] WARN — 2 edge cases identified:
- {issue 1}
- {issue 2}
Step 4.10: Contract Conformance Gate
After the adversarial gate passes (Step 4.9), run contract conformance verification for any business-logic contracts stored under .qe/contracts/active/. This gate protects user-defined business logic from "vibe coding" drift by comparing each contract against its implementation and tests via LLM judge.
Skip conditions (fast path):
- No
.qe/contracts/active/*.mdfiles exist → skip entirely. type: docs/type: analysistasks (no code to verify).
Procedure:
- Invoke
/Qverify-contract --all(seeskills/Qverify-contract/SKILL.md). - The skill lists active contracts, computes 3-hash cache keys, returns cached verdicts on hit, or invokes the
Econtract-judgeagent on miss. - Collect aggregated output:
N PASS, M FAIL. - Results feed back into judgment:
| Verdict | Action |
|---|---|
| ALL PASS | Proceed to Step 5 (Report) |
| Any FAIL | Treat as Step 4 failure — show findings via the interaction adapter: "Fix contract drift" / "Accept as-is (accept FAIL)" / "Stop". On "Fix", delegate to Ecode-debugger on Claude or native Codex subagent/inline degraded fix on Codex, then return to Step 2 (loop counter +1). |
Output example:
[Contract Gate] PASS — 7/7 contracts honored by implementation
or
[Contract Gate] FAIL — 2 contracts have drift:
- sivs-enforcer: Implementation does not handle SIVS_BLOCK_REASON as stated in contract (critical)
- user-service: Missing DuplicateEmailError handling (critical)
Why this gate exists: Tests verify BEHAVIOR; contracts verify INTENT. A passing test can still silently drift from the contract's declared invariants after an AI refactor. This gate catches that class of regression. (See docs/contract-layer.md.)
Step 5: Report Results
Summarize and report final results.
## Quality Verification Complete: [Task Name]
**UUID:** {UUID}
**Iterations:** N/3
**Final status:** Pass / Partial pass (user approved)
### Test Results
- Passed: X / Failed: Y
### Review Results
- Critical: 0 / Warning: N / Suggestion: M
### Fix History
| Iteration | Issue Found | Fix Applied |
|-----------|-------------|-------------|
| 1 | [issue] | [fix] |
| 2 | [issue] | [fix] |
### Changed Files (final)
- [file list]
Qrun-task Integration
This skill can be called independently as {adapter.commandPrefix}Qcode-run-task, or it can be automatically triggered from Qrun-task.
Independent Call
{adapter.commandPrefix}Qcode-run-task {UUID}
- References TASK_REQUEST and VERIFY_CHECKLIST for the given UUID
- Changed files are auto-detected via git diff
Triggered from Qrun-task
- Automatically entered after Qrun-task Step 3 is complete when
type: code - Uses the changed file list already collected by Qrun-task
- Returns to Qrun-task Step 4 (final verification) after quality verification is complete
Coding Expert References (deterministic resolution)
During quality verification, the review must be graded against the same language/framework standards the code was written to. Resolve them deterministically rather than relying on the reviewer to guess:
- After Step 1 collects the changed files, run:
→ JSON arraynode <QE plugin>/scripts/lib/expert-resolver.mjs --files $(git diff --name-only)[{ slug, path, reason }](top 2, may be empty). - When delegating to
Eqa-orchestrator(default path), include the resolved paths in the delegation prompt:Review/test against these expert guideline files: {absolute paths}. Eqa-orchestrator forwards them toEcode-reviewerandEcode-test-engineeras part of their context. - In manual mode, pass the same paths directly to the
Ecode-revieweragent. - Empty result → reviewer falls back to
skills/coding-experts/PRINCIPLES.md. Skip entirely fortype: docs/type: analysis.
Full human-readable catalog: skills/coding-experts/CATALOG.md · machine map: skills/coding-experts/STACK_MAP.json.
Role Constraints
- This skill focuses exclusively on the test, review, and fix loop
- Does not add new features or change requirements
- Fix scope is limited to resolving discovered issues