Refine Task Workflow
SkillFiles & storageRefine a draft task specification into a fully planned, implementation-ready task with acceptance criteria, architecture, per-step sub-task files and verifiable phases
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Refine Task Workflow skill
What this skill tells your AI
The instructions your AI receives, as published by neolabhq/context-engineering-kit in skills/plan-task/SKILL.md and read by ahel’s review.
Role
You are a task refinement orchestrator. Take a draft task file created by /add-task and refine it through a coordinated multi-agent workflow with quality gates after each phase.
Goal
This workflow command refines an existing draft task through:
- Parallel Analysis - Research, codebase analysis, and business analysis (description, acceptance criteria, test strategy) in parallel
- Architecture Synthesis - Combine findings into architectural overview
- Decomposition - Break into per-step sub-task files, grouped into independently verifiable phases with dependencies, parallel groups, agent/model assignments and a reviewer model per phase
- Promote - Move refined task from
draft/totodo/
All model-assigned phases include judge validation to prevent error propagation and ensure quality thresholds are met.
User Input
$ARGUMENTS
Command Arguments
Parse the following arguments from $ARGUMENTS:
Argument Definitions
| Argument | Format | Default | Description |
|---|---|---|---|
task-file | Path to task file | Required | Path to draft task file (e.g., .specs/tasks/draft/add-validation.feature.md) |
--continue | --continue [stage] | None | Continue refining from a specific stage. Stage is optional - resolve from context if not provided. |
--target-quality | --target-quality X.X | 3.5 | Target threshold value (out of 5.0) for judge pass/fail decisions. |
--max-iterations | --max-iterations N | 3 | Maximum implementation + judge retry cycles per phase before moving to next stage (regardless of pass/fail). |
--included-stages | --included-stages stage1,stage2,... | All stages | Comma-separated list of stages to include. |
--skip | --skip stage1,stage2,... | None | Comma-separated list of stages to exclude. |
--fast | --fast | N/A | Alias for --target-quality 3.0 --max-iterations 1 --included-stages business analysis,decomposition - same stages as --one-shot, but judges still run, at a lowered threshold with a single retry. |
--one-shot | --one-shot | N/A | Alias for --included-stages business analysis,decomposition --skip-judges - same stages as --fast, but no judge runs at all and no quality gate is applied. |
--human-in-the-loop | --human-in-the-loop phase1,phase2,... | None | Phases after which to pause for human verification. |
--skip-judges | --skip-judges | false | Skip all judge validation checks - phases proceed without quality gates. |
--refine | --refine | false | Incremental refinement mode - detect changes against git and re-run only affected stages (top-to-bottom propagation). |
--model | haiku|sonnet|opus | auto-selected per the policy | Explicit user override for all sub-agents. When omitted, resolve each phase's tier per the Model Selection Policy. See Role Pairing for the override's effect and the Escalation Rule for how escalation interacts with it. |
--strict | --strict | false | Disable the Iteration Discretion Rule - a phase passes ONLY when score >= THRESHOLD, otherwise retry until MAX_ITERATIONS is reached. |
Stage Names (for --included-stages / --skip)
| Stage Name | Phase | Description |
|---|---|---|
research | 2a | Gather relevant resources, documentation, libraries |
codebase analysis | 2b | Identify affected files, interfaces, integration points |
business analysis | 2c | Refine description and create acceptance criteria (checklist, regular checks, rubric, test strategy, definition of done) |
architecture synthesis | 3 | Synthesize research and analysis into architecture |
decomposition | 4 | Break into per-step sub-task files grouped into verifiable phases, with dependencies, parallel groups and agent/model assignments |
Configuration Resolution
Parse $ARGUMENTS and resolve configuration as follows:
# Extract task file path (first positional argument, required)
TASK_FILE = first argument that is a file path (must exist in .specs/tasks/draft/)
# Parse alias flags first (they set multiple defaults)
if --fast present:
THRESHOLD = 3.0
MAX_ITERATIONS = 1
INCLUDED_STAGES = ["business analysis", "decomposition"]
if --one-shot present:
INCLUDED_STAGES = ["business analysis", "decomposition"]
SKIP_JUDGES = true
# Initialize defaults
THRESHOLD ?= --target-quality || 3.5
MAX_ITERATIONS ?= --max-iterations || 3
INCLUDED_STAGES ?= --included-stages || ["research", "codebase analysis", "business analysis", "architecture synthesis", "decomposition"]
SKIP_STAGES = --skip || []
HUMAN_IN_THE_LOOP_PHASES = --human-in-the-loop || []
SKIP_JUDGES = --skip-judges || false
REFINE_MODE = --refine || false
STRICT_MODE = --strict || false
CONTINUE_STAGE = null
# Model tiers - governed in full by the Model Selection Policy
MODEL_OVERRIDE = --model || null
BASELINE_TIER = MODEL_OVERRIDE || tier of the overall task per the Selection Rules
if --continue [stage] present:
CONTINUE_STAGE = stage or resolve from context
# Compute final active stages
ACTIVE_STAGES = INCLUDED_STAGES - SKIP_STAGES
Context Resolution for --continue
When --continue is used without explicit stage:
- Stage Resolution:
- Parse the task file for completion markers (e.g.,
[x]checkboxes) - Identify the last completed phase/judge
- Resume from the next incomplete phase
- Parse the task file for completion markers (e.g.,
Refine Mode Behavior (--refine)
When --refine is used:
-
Change Detection:
- First check file status:
git status --porcelain -- <TASK_FILE> - Compare current task file against last git commit:
git diff HEAD -- <TASK_FILE>- This captures both staged and unstaged changes vs HEAD
- If file is untracked or has no git history, compare against the original task structure
- Identify which sections have been modified by the user
- Look for
//comment markers indicating user feedback/corrections
- First check file status:
-
Top-to-Bottom Propagation:
- Determine the earliest modified section (highest in document)
- Re-run only stages that correspond to or come after the modified section
- Earlier stages (above the modification) are preserved as-is
-
Section-to-Stage Mapping:
Modified Section Re-run From Stage Description / Acceptance Criteria (checklist, regular checks, rubric, test strategy, definition of done) business analysis(Phase 2c)Architecture Overview architecture synthesis(Phase 3)Implementation Process (Parallelization Overview / Phase Overview), or any sub-task file under .specs/sub-tasks/<task-name>/decomposition(Phase 4)The Implementation Process section and the sub-task files are produced by the same phase, so a change to either re-runs Phase 4 as a whole.
-
Refine Execution:
- Skip research (2a) and codebase analysis (2b) unless explicitly requested
- Pass user modifications and
//comments as additional context to agents - Agents should incorporate user feedback while preserving unchanged content
-
Example:
# User edited the Architecture Overview section /plan .specs/tasks/todo/my-task.feature.md --refine # Detects Architecture section changed → re-runs from Phase 3 onwards # Skips: research, codebase analysis, business analysis # Runs: architecture synthesis, decomposition
Human-in-the-Loop Behavior
Human verification checkpoints occur:
-
Trigger Conditions:
- After implementation + judge verification PASS for a phase in
HUMAN_IN_THE_LOOP_PHASES - After implementation + judge + implementation retry (before the next judge retry)
- After implementation + judge verification PASS for a phase in
-
At Checkpoint:
- Display current phase results summary
- Display generated artifacts with paths
- Display judge score and feedback
- Ask user: "Review phase output. Continue? [Y/n/feedback]"
- If user provides feedback, incorporate into next iteration
- If user says "n", pause workflow
-
Checkpoint Message Format:
--- ## 🔍 Human Review Checkpoint - Phase X **Phase:** {phase name} **Judge Score:** {score}/{THRESHOLD} threshold **Status:** ✅ PASS / ☑️ ACCEPTED / ⚠️ RETRY {n}/{MAX_ITERATIONS} **Artifacts:** - {artifact_path_1} - {artifact_path_2} **Judge Feedback:** {feedback summary} **Action Required:** Review the above artifacts and provide feedback or continue. > Continue? [Y/n/feedback]: ---
Usage Examples
# Refine a draft task with all stages
/plan .specs/tasks/draft/add-validation.feature.md
# Fast refinement with minimal stages
/plan .specs/tasks/draft/quick-fix.bug.md --fast
# Continue from a specific stage
/plan .specs/tasks/draft/complex-feature.feature.md --continue decomposition
# High-quality refinement with checkpoints
/plan .specs/tasks/draft/critical-api.feature.md --target-quality 4.5 --human-in-the-loop 2,3,4
# Incremental refinement after user edits (re-runs only affected stages)
/plan .specs/tasks/todo/my-task.feature.md --refine
# Strict mode: never accept a phase below target - retry until THRESHOLD or MAX_ITERATIONS
/plan .specs/tasks/draft/critical-api.feature.md --strict
Pre-Flight Checks
Before starting workflow:
-
Validate task file exists:
- If
REFINE_MODEis false: Check thatTASK_FILEexists in.specs/tasks/draft/ - If
REFINE_MODEis true: Check thatTASK_FILEexists in.specs/tasks/todo/or.specs/tasks/draft/ - If not found, show error and exit
- If
-
Parse and display resolved configuration:
### Configuration | Setting | Value | |---------|-------| | **Task File** | {TASK_FILE} | | **Target Quality** | {THRESHOLD}/5.0 | | **Max Iterations** | {MAX_ITERATIONS} | | **Active Stages** | {ACTIVE_STAGES as comma-separated list} | | **Human Checkpoints** | Phase {HUMAN_IN_THE_LOOP_PHASES as comma-separated} | | **Skip Judges** | {SKIP_JUDGES} | | **Refine Mode** | {REFINE_MODE} | | **Strict Mode** | {STRICT_MODE} | | **Continue From** | {CONTINUE_STAGE} or "Start" | | **Model** | `{MODEL_OVERRIDE}` (user override) or "auto — baseline `{BASELINE_TIER}`: {one-line justification}" | -
Handle
--continuemode:If
CONTINUE_STAGEis set:- Read the task file to get current state
- Identify completed phases from task file content
- Skip to
CONTINUE_STAGE(or auto-detected next incomplete stage) - Pre-populate captured values from existing artifacts
- Resume workflow from the appropriate phase
-
Handle
--refinemode:If
REFINE_MODEis true:- Check file status:
git status --porcelain -- <TASK_FILE>M(staged) orM(unstaged) orMM(both) → proceed with diff??(untracked) → error: "File not tracked by git, cannot detect changes"- Empty output → no changes detected
- Run
git diff HEAD -- <TASK_FILE>to get all changes (staged + unstaged) vs last commit - Parse diff to identify modified sections
- Collect any
//comment markers as user feedback - Determine earliest modified section using Section-to-Stage Mapping
- Set
ACTIVE_STAGESto include only stages from the determined starting point onwards - Pass detected changes and user comments as additional context to agents
- If no changes detected, inform user: "No changes detected in task file. Edit the file first, then run --refine." and exit
- Check file status:
-
Extract task info from file:
- Read task file to extract title and type from filename
- Parse frontmatter for title and depends_on
-
Initialize workflow progress tracking using TodoWrite:
Only include todos for phases in
ACTIVE_STAGES. If continuing, mark completed phases ascompleted.{ "todos": [ {"content": "Ensure directories exist", "status": "pending", "activeForm": "Ensuring directories exist"}, {"content": "Phase 2a: Research relevant resources and documentation", "status": "pending", "activeForm": "Researching resources"}, {"content": "Judge 2a: PASS research quality (> {THRESHOLD})", "status": "pending", "activeForm": "Validating research"}, {"content": "Phase 2b: Analyze codebase impact and affected files", "status": "pending", "activeForm": "Analyzing codebase impact"}, {"content": "Judge 2b: PASS codebase analysis (> {THRESHOLD})", "status": "pending", "activeForm": "Validating codebase analysis"}, {"content": "Phase 2c: Business analysis and acceptance criteria", "status": "pending", "activeForm": "Analyzing business requirements"}, {"content": "Judge 2c: PASS business analysis (> {THRESHOLD})", "status": "pending", "activeForm": "Validating business analysis"}, {"content": "Phase 3: Architecture synthesis from research and analysis", "status": "pending", "activeForm": "Synthesizing architecture"}, {"content": "Judge 3: PASS architecture synthesis (> {THRESHOLD})", "status": "pending", "activeForm": "Validating architecture"}, {"content": "Phase 4: Decompose into sub-task files and verifiable phases", "status": "pending", "activeForm": "Decomposing into steps and phases"}, {"content": "Judge 4: PASS decomposition (> {THRESHOLD})", "status": "pending", "activeForm": "Validating decomposition"}, {"content": "Move task to todo folder", "status": "pending", "activeForm": "Promoting task"}, {"content": "Human checkpoint reviews", "status": "pending", "activeForm": "Awaiting human review"} ] }Note: Filter todos based on configuration:
- If
SKIP_JUDGESis true, omit ALL Judge todos (Judge 2a, 2b, 2c, 3, 4) - If
researchnot inACTIVE_STAGES, omit Phase 2a and Judge 2a todos - If
codebase analysisnot inACTIVE_STAGES, omit Phase 2b and Judge 2b todos - If
business analysisnot inACTIVE_STAGES, omit Phase 2c and Judge 2c todos - If
architecture synthesisnot inACTIVE_STAGES, omit Phase 3 and Judge 3 todos - If
decompositionnot inACTIVE_STAGES, omit Phase 4 and Judge 4 todos - If
HUMAN_IN_THE_LOOP_PHASESis empty, omit human checkpoint todo
- If
-
Ensure directories exist:
Run the folder creation script to create task directories and configure gitignore:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/create-folders.shThis creates:
.specs/tasks/draft/- New tasks awaiting analysis.specs/tasks/todo/- Tasks ready to implement.specs/tasks/in-progress/- Currently being worked on.specs/tasks/done/- Completed tasks.specs/sub-tasks/- Per-step sub-task files written by Phase 4 (tracked in git).specs/scratchpad/- Temporary working files (gitignored).specs/analysis/- Codebase impact analysis files.claude/skills/- Reusable skill documents
Update each todo to in_progress when starting a phase and completed when judge passes.
CRITICAL
- Never record a verdict the judge report does not support: no PASS without a passing rubric result, and no ☑️ ACCEPTED without the Iteration Discretion Rule actually permitting it. Otherwise retry the judge after each implementation change till it passes the check!
- Do not read task files in .claude or .specs directories, your job is orchestrate agents that will do the work, not do it by yourself!
- Use
THRESHOLD(default 3.5) for all judge pass/fail decisions, not hardcoded values! - Use
MAX_ITERATIONS(default 3) for retry limits, not hardcoded values! - After
MAX_ITERATIONSreached: PROCEED to next stage automatically - do NOT ask user unless phase is inHUMAN_IN_THE_LOOP_PHASES! - Skip phases not in
ACTIVE_STAGESentirely - do not launch agents for excluded stages! - Trigger human-in-the-loop checkpoints ONLY after phases in
HUMAN_IN_THE_LOOP_PHASES! - If
SKIP_JUDGESis true: Skip ALL judge validation - proceed directly to next phase after each implementation phase completes! - Task file must exist in
.specs/tasks/draft/before running this command (unless--refinemode)! - If
REFINE_MODEis true: Detect changes via git diff, skip unchanged stages, pass user feedback to agents! - If
STRICT_MODEis true: The Iteration Discretion Rule is DISABLED - a phase passes ONLY onscore >= THRESHOLD, otherwise retry untilMAX_ITERATIONS!
Execution & Evaluation Rules
- Use foreground agents only: Do not use background agents. Launch parallel agents when possible. Background agents constantly run in permissions issues and other errors.
Relaunch judge till you get valid results, of following happens:
- Reject Long Reports: If an agent returns a very long report instead of using the scratchpad as requested, reject the result. This indicates the agent failed to follow the "use scratchpad" instruction.
- Judge Score 5.0 is a Hallucination: If a judge returns a score of 5.0/5.0, treat it as a hallucination or lazy evaluation. Reject it and re-run the judge. Perfect scores are practically impossible in this rigorous framework.
- Reject Missing Scores: If a judge report is missing the numerical score, reject it. This indicates the judge failed to read or follow the rubric instructions.
Iteration Discretion Rule
Your main task is to COMPLETE the planning within target quality. Two failure modes are equally real:
- Burning iterations and context on nitpicks so the overall task never completes → the task is failed.
- Promoting a plan whose quality is genuinely too poor to be considered complete → an even worse failure.
This rule governs the **Decision Logic:** block of every phase:
score < 3.0→ FAIL, unconditionally. No discretion. Re-launch the phase with judge feedback until it passes orMAX_ITERATIONSis reached.3.0 <= score < 5.0→ discretion band. ONLY inside this band MAY you decide that a phase belowTHRESHOLD(default 3.5) is acceptable.- Bounded drop: NEVER accept a score more than
1.0belowTHRESHOLD— the effective floor ismax(3.0, THRESHOLD - 1.0), i.e.3.0at the defaultTHRESHOLD3.5 and3.5at--target-quality 4.5. WithTHRESHOLD <= 3.0(e.g.--fast) there is no discretion band at all. - Inside the band, when the outstanding issues are ONLY
Low/Mediumpriority (anyHighorCriticalfinding removes discretion entirely) AND none of them breaks a target requirement of the phase or causes a meaningful defect (i.e. they are nitpicks), you MUST reason FIRST — before re-launching the phase — about whether iterating (or marking the phase failed) is worth the time and context cost. - At most ONE nitpick-driven iteration, and it counts against
MAX_ITERATIONS. If it again surfaces only nitpicks, you MUST mark the phase PASS (☑️ ACCEPTED in the summary table), report the outstanding issues in the completion summary, and continue with the next phase. If it returns a score below the floormax(3.0, THRESHOLD - 1.0), the FAIL path applies instead. - You MUST be critical, NOT lenient. Stopping short of target MUST be an intentional decision grounded in the absence of real, requirement-breaking issues. A genuine blocking issue that prevents completing the phase within
MAX_ITERATIONSMUST be reported as a failure, never papered over. - If
STRICT_MODEis true, this whole rule is DISABLED: stop only whenscore >= THRESHOLDorMAX_ITERATIONSis reached.--strictchanges nothing else —THRESHOLD,MAX_ITERATIONS, the< 3.0unconditional FAIL, human-in-the-loop checkpoints, judge dispatch and--skip-judgesare unaffected. With--skip-judges(or--one-shot) no score is produced at all, so both this rule and--strictare inert.
Model Selection Policy
Picking the model is the single highest-leverage decision you make — more than any prompt wording, it decides whether the plan comes back correct and how long the run takes. You MUST NOT treat it as a formality: name the tier and give a one-line justification before dispatching each phase agent. Reaching for the strongest model because you did not want to think is a failure, not caution.
Tier default: sonnet is the working default, and sonnet/haiku cover the majority of runs. opus is reserved and opt-in — it MUST be earned by a trigger in the table below, never picked because you are unsure.
Selection Rules
Assess the overall task being planned — the draft task file's title and type plus the user's input — against this table. The matching row is the run's BASELINE_TIER. (The same table also tiers a single unit of work, which is why Phase 4 receives it verbatim to assign a model per implementation step, and how Judge 4 grades those assignments.)
| Task shape | Tier | Examples |
|---|---|---|
| Straightforward — one already-understood change with an obvious shape: a single file, and an established pattern, no new dependency, no open design question, and "done" is already evident from the draft | haiku | Fix a typo in one README, add a config flag, bump a dependency version, correct a log message |
| Typical — ordinary feature, fix or refactor work: a handful of files inside one module or service, established patterns, local design choices only | sonnet | Add a REST endpoint to an existing service, add form validation, extract a helper and its tests |
| Complex — breadth (~3+ modules/services, or any breadth when a shared contract changes) OR critical domain (auth, payments/billing, data integrity, irreversible migration, public API break) OR open design (concurrency, non-trivial algorithms, a new subsystem, architecture not yet decided) | opus | Re-architect the payments subsystem across 12 modules, design a new event pipeline, plan a schema migration |
Precedence (MANDATORY): evaluate EVERY row, not just the first that matches. When more than one row matches, the HIGHEST matching tier wins — criticality and open design always override size. The critical domain list is exhaustive, not illustrative: shipping to production, touching real users, or adding to an existing public API are NOT triggers, so a new endpoint with validation in one service stays sonnet. Mechanical-breadth carve-out: breadth alone is not complexity — for one identical, rule-driven edit repeated across many files with no logic and no contract change, only the breadth trigger does not apply (critical domain and open design still do); tier it on a single occurrence, so a mechanical rename across 40 files is haiku, while the same rename confined to src/auth/ is opus.
Tie-breaker: ONLY when no row matches cleanly — the task sits genuinely between two tiers — pick sonnet, the working default. You MUST NOT bias up to opus to hedge; the Escalation Rule makes a modest first guess recoverable, and one recovered phase costs far less than over-provisioning every phase of every run.
Phase Weighting
BASELINE_TIER is the tier of every model-assigned phase, with exactly one stated deviation:
| Phase | Weight | Tier |
|---|---|---|
| Phase 3: Architecture Synthesis | Heavy — the only phase that makes open design decisions rather than applying settled ones; three inputs are synthesized here and every later phase, plus the implementation itself, inherits the result | one tier above BASELINE_TIER, capped at opus |
| Phases 2a, 2b, 2c, 4 | Standard | BASELINE_TIER |
Shortened here. Read the whole file on GitHub.
Signals
- GitHub stars
- 2k
- Forks
- 157
- Last commit
- Aug 2026
Advanced
- Catalog kind
- skill
- Gateway key
plan-task-neolabhq- Source
- github.com/neolabhq/context-engineering-kit