Dev Workflow
Usage
/dev-workflow --init # Project setup (detect check/test commands)
/dev-workflow [-i N | --iterations N] <task> # Execute workflow (default)
/dev-workflow --resume <state-file> [-i N] # Resume next subtask from a decomposition state file
Prerequisites
- Reviewer skill (
reviewersetting, default: ask-peer): Required for plan/code review. Supported: ask-peer, ask-claude, ask-codex, ask-gemini, ask-copilot. If the configured skill is unavailable, ask user directly instead. - rules-review skill: Required for rules compliance review (Step 7.5). If unavailable, skip Step 7.5 with message.
- extract-rules skill: Required for rule update. If unavailable, skip with message.
Configuration
Settings files (YAML frontmatter only, merged across layers):
~/.claude/dev-workflow.local.md— User global defaults (lowest priority).claude/dev-workflow.md— Project shared settings (git tracked, team-shared).claude/dev-workflow.local.md— Personal overrides (gitignored, highest priority)
Merge strategy per key type:
- Scalar (
reviewer,review_iterations,task_decomposition,custom_instructions): higher layer wins (replaces) - List (
check_commands): append — lower-layer items first, then higher-layer items, duplicates removed (keep first occurrence).test_commandsis excluded from merge — always fixed to["Skill(run-tests)"] hooks: deep-merge at thehookslevel — each sub-key (on_complete) is merged as a list (append, deduplicated)
Keys absent from a higher layer inherit from lower layers. Only specify keys you want to override or extend.
---
reviewer: "ask-peer"
review_iterations: 3
task_decomposition: true
custom_instructions: "Always use TDD. Write tests before implementation."
check_commands:
- "pnpm run lint:fix"
- "pnpm run format"
- "pnpm run typecheck"
test_commands:
- "Skill(run-tests)"
hooks:
on_complete:
- "Skill(work-complete)"
---
- reviewer: Reviewer skill name (default:
ask-peer). Choose from: ask-peer, ask-claude, ask-codex, ask-gemini, ask-copilot. Unsupported values fall back toask-peer - review_iterations: Max iterations for Plan Review (Step 3) and Code Review (Step 8) (default:
3, must be a positive integer). Can be overridden per invocation with-i N/--iterations N - task_decomposition: Whether Step 1.5 runs the auto-decomposition check in Normal sub-mode (default:
true). Set tofalseto treat Normal sub-mode requests (/dev-workflow <task>) as single tasks — Step 1.5 is omitted from TodoWrite and the decomposition judgment is skipped entirely.--resume <state-file>is unaffected and still executes existing state files. Non-boolean values fall back totruewith a warning - custom_instructions: Free-form development instructions applied as guiding principles across planning, implementation, review, and simplification (e.g., "Always use TDD", "Prefer functional style"). Optional.
.claude/rules/and explicit user requests take precedence if they conflict - check_commands: Static checks (lint, format, typecheck, etc.). Always run all in order
- test_commands: Always
["Skill(run-tests)"]. Therun-testsskill is generated by--initand handles test execution via subagent (see Step 7). Run--initto generate or update the skill - hooks: Execute skills/commands at specific workflow timing points
- on_complete: Runs after Step 9. Entry format:
Skill(<name>)or shell command string - Entries not covered by allowed-tools require user approval
- on_complete: Runs after Step 9. Entry format:
Mode Detection
--init→ Init Mode (-i/--iterationsis ignored)--resume <state-file>→ Execution Mode (Resume sub-mode; see Step 1.5)- Otherwise → Execution Mode (Normal sub-mode)
Init Mode
Read references/init-mode.md and follow the procedure.
Note: Skills generated by
--init(e.g.run-tests) are recognized from the next session onward. Do not run/dev-workflow <task>in the same session as--init.
Execution Mode
Step 1: Load Settings
- Read settings from up to three layers and merge (type-aware):
"Overlay" = for each key present in the file:merged = {} if ~/.claude/dev-workflow.local.md exists: overlay its frontmatter onto merged if .claude/dev-workflow.md exists: overlay its frontmatter onto merged if .claude/dev-workflow.local.md exists: overlay its frontmatter onto merged- Scalar keys:
merged[key] = file[key](replace) - List keys (
check_commands): appendfile[key]items aftermerged[key], then deduplicate (keep first occurrence) hooks: deep-merge — for each sub-key (e.g.on_complete), append and deduplicate the listnullor empty ([],{}) explicitly clears the key — lower-layer value is discarded, not inherited- Key absent from the file: left untouched (inherit from lower layers) If a file's YAML frontmatter is malformed (parse error), warn the user naming the file, skip that layer, and continue with remaining layers.
- Scalar keys:
- If none of the three files exist, prompt user to run
/dev-workflow --initand stop - Resolve
reviewerfrom config. If not specified or not in the supported list (ask-peer, ask-claude, ask-codex, ask-gemini, ask-copilot), useask-peer - Resolve N (review iteration count):
- If
-i/--iterationsoption is present and is a positive integer, use it - Else if config
review_iterationsis present and is a positive integer, use it - Else use default
3
- If
- Parse
hooksfrom config. Warn and ignore ifhooks.on_completehas invalid format. Parsecustom_instructionsfrom config (optional, string). Warn and ignore if not a string. Parsetask_decompositionfrom config (optional, boolean, defaulttrue). Warn and fall back totrueif present but not a boolean - Determine execution sub-mode: Resume if
--resume <state-file>was provided, otherwise Normal. Step 1.5 branches on this - Register all workflow phases with
TodoWrite, including review iterations. Do NOT skip any phase:- Step 1.5: Task Decomposition (Normal sub-mode only, AND only when
task_decompositionistrue— omit this entry entirely in Resume sub-mode or whentask_decompositionisfalse, since in either case the step has nothing to do at registration time) - Step 2: Create Plan
- Step 3: Plan Review
- Step 3-1 through Step 3-N: Plan Review - iteration 1 through N (generate N items based on resolved N)
- Step 4: Finalize Plan
- Step 5: Implement
- Step 6: Simplify
- Step 7: Check / Test [check: {check_commands} | test: {test_commands}]
- Step 7.5: Rules Compliance Review
- Step 8: Code Review
- Step 8-1 through Step 8-N: Code Review - iteration 1 through N (generate N items based on resolved N)
- Step 9: Update Rules
- Step 10: Completion Hooks (only if
hooks.on_completeis configured) Mark each itemin_progresswhen starting andcompletedwhen done. Registering all phases upfront gives the user visibility into overall progress and prevents steps from being accidentally dropped. Implementation sub-tasks in Step 5 are additions, not replacements. Note: Unless-i/--iterationswas explicitly specified, Step 2 may reduce N based on task difficulty.
- Step 1.5: Task Decomposition (Normal sub-mode only, AND only when
Step 1.5: Task Decomposition
This step decides whether the user's request should be split into multiple smaller subtasks (each delivered as its own PR), or — in Resume sub-mode — picks the next subtask from an existing state file under .claude/plans/dev-workflow.<slug>.md.
State-file semantics are critical (a malformed or mis-routed file silently corrupts subtask boundaries), so the full procedure lives in a dedicated reference. Dispatch:
- Resume sub-mode (
--resume <state-file>was provided): readreferences/task-decomposition.mdand follow section A. Resume sub-mode from top to bottom. - Normal sub-mode +
task_decomposition: true(the default): readreferences/task-decomposition.mdand follow section B. Normal sub-mode. - Normal sub-mode +
task_decomposition: false: no decomposition work. Set the "effective task" to the original request and proceed to Step 2 without creating a state file. Step 1.5 is not in TodoWrite in this case (see Step 1), so there is nothing to markcompleted. You do not need to read the reference file.
EnterPlanMode is reserved for Step 2 — any decomposition proposal in Step 1.5 is a plain yes/no dialogue, not a plan.
After section A or B completes, the "effective task" is set for Step 2 onward: the selected subtask when decomposed, otherwise the original request.
Step 2: Create Plan
- Record the current commit as base-commit (
git rev-parse HEAD) for later diff comparison EnterPlanMode- Analyze the task and codebase, create implementation plan. Apply
custom_instructionsto shape plan priorities and structure (must include test plan: what to test, test types, scope, and which existing test files to update or new test files to create — or justification why no tests are needed)- If a state file exists (this run is executing one subtask of a decomposed parent): the "effective task" = the current
in_progresssubtask. Frame the plan around just this subtask while keeping the full parent task and other subtasks as background context so the plan stays consistent with the overall direction. Do not plan work belonging to other subtasks
- If a state file exists (this run is executing one subtask of a decomposed parent): the "effective task" = the current
- No code changes in this phase
- Adjust N by difficulty (skip if
-i/--iterationswas explicitly specified): A typo fix doesn't need 3 rounds of review. Based on the plan just created, assess task difficulty and reduce N to avoid unnecessary iterations — the configured value is a ceiling, not a target:- Simple (typo fix, config tweak, straightforward bug fix with obvious solution): N = 1
- Moderate (multi-file within one module, feature following existing patterns): N = min(2, N)
- Complex (cross-module, new patterns, API changes, significant refactoring): keep N
File count is a hint, not the sole criterion. If adjusted, mark excess TodoWrite iteration items (Step 3-x and Step 8-x) as
completed. Log the assessed difficulty and effective N.
- Do not present the plan to the user or ask for approval/confirmation — presenting an unreviewed plan wastes user time and risks approval of a suboptimal approach. Proceed to Step 3. The user will see the reviewed plan in Step 4.
Step 3: Plan Review
This step is an internal review — the reviewer refines the plan before the user sees it, so the user receives a higher-quality plan in Step 4. Do not present the plan to the user or ask for feedback during this step.
Mark Step 3: Plan Review as in_progress. Process each pending iteration item (Step 3-1 through 3-N) in order:
- Mark the iteration item as
in_progress. Call the reviewer skill resolved in Step 1 (e.g.Skill(ask-peer)): Review the plan.- Instruct reviewer to read all files under
.claude/rules/for project conventions - Request feedback organized into three categories:
a. Scope & feasibility: scope appropriateness, dependencies, risks,
.claude/rules/compliance b. Approach & alternatives: simpler methods, architectural fit with existing code c. Completeness: edge cases, error handling, test plan adequacy (verify specific test files are identified and existing related tests are covered for update) - If
custom_instructionsis configured, include the instructions text in the review request and have the reviewer verify alignment and report conflicts - Reviewer should only report actionable findings. If none, explicitly state "No actionable findings"
- Instruct reviewer to read all files under
- If reviewer returned "No actionable findings": mark this and remaining iteration items as
completed(skip). MarkStep 3: Plan Reviewascompletedand proceed to Step 4. - Otherwise: autonomously apply improvements or reject inapplicable points with reason — do not ask the user for judgment on individual review findings. Mark this iteration item as
completed.- If the plan was modified: continue to the next pending iteration item (back to step 1). Plan modifications often introduce new gaps or ripple effects that the previous reviewer had no chance to see — the re-review round-trip is cheap compared to shipping a plan that looks fine to the author but has an unvetted section. Don't short-circuit even when the fixes feel airtight
- If all points were rejected (no modifications): mark remaining iteration items as
completed(skip — there is nothing new for the next reviewer to look at) Continue to the next pending iteration item with: - the updated plan
- a summary of changes made and rejections with reasons
- the same three-category structure,
.claude/rules/reference, and "No actionable findings" requirement
- If all N iteration items are completed and actionable feedback still remains, carry the unresolved points forward to Step 4.
Mark Step 3: Plan Review as completed.
Step 4: Finalize Plan (USER APPROVAL GATE)
- This is the first time the user sees the plan. Present the reviewed plan to the user (include any unresolved review points from Step 3)
- Collaborate with the user to refine the plan as needed (normal Plan Mode interaction). If the user requests material changes to scope or approach, add a new review iteration item (e.g. Step 3-(N+1)) and return to Step 3 to process it before asking for acceptance.
- Wait for explicit user acceptance. After the user accepts,
ExitPlanModeand begin implementation
Step 5: Implement
- Follow the plan, track progress with
TodoWrite. Applycustom_instructionsthroughout implementation
Step 6: Simplify
Implementation often introduces unnecessary complexity that's easier to spot in a dedicated pass after the code works.
Skill(simplify): Review changed code for reuse, quality, and efficiency, then fix any issues found. Passcustom_instructionsas constraints for simplification
Step 7: Check / Test (max 3 retries)
- Run
check_commandsin order (always run all)- On failure, fix and retry (do not proceed to test execution)
- Run
Skill(run-tests)with--base-commit <sha>(from Step 2) via$ARGUMENTS- The skill handles scope decision and test execution internally via subagent
- Returns structured summary: SUCCESS / TEST_FAILED / EXECUTION_ERROR
- After 3 retries, report to user and stop
GATE: Verify Steps 2-7 are completed (check TodoWrite status; if status is inconsistent, verify actual completion by reviewing work done). Mark Step 7.5 as
in_progress.
Step 7.5: Rules Compliance Review
Dedicated rules compliance check, separate from code review (Step 8). This ensures rule enforcement gets focused attention rather than competing with correctness and design concerns.
Skill(rules-review)with--base-commit <sha>(base-commit recorded in Step 2) via$ARGUMENTS- If result indicates no violations (e.g., "All rules compliant", "No applicable rules for changed files", "No changed files", "No rule files found"): mark completed, proceed to Step 8
- If violations found:
a. Fix all reported violations
b. Re-run Step 7 (Check / Test) to ensure fixes did not break anything
c. Re-run
Skill(rules-review)with--base-commit <sha>for verification (2nd cycle) d. If violations persist after 2 cycles, present remaining violations to user for decision. Wait for user response before marking completed.
Mark Step 7.5: Rules Compliance Review as completed only after all violations are resolved or user has decided on remaining violations.
GATE: Verify Steps 2-7.5 are completed (check TodoWrite status; if status is inconsistent, verify actual completion by reviewing work done). Mark Step 8 as
in_progress.
Step 8: Code Review
Code review catches bugs, convention violations, and design issues that tests alone miss — skipping it risks shipping preventable defects. Always run this step even when tests pass cleanly.
Mark Step 8: Code Review as in_progress. Process each pending iteration item (Step 8-1 through 8-N) in order:
- Mark the iteration item as
in_progress. Call the reviewer skill resolved in Step 1 (e.g.Skill(ask-peer)): Review code changes.- Include
git diff <base-commit>(base-commit recorded in Step 2) to capture all changes since workflow start - Thorough rules compliance has been verified in Step 7.5, but instruct reviewer to also flag any obvious
.claude/rules/violations as a safety net — especially for code modified after Step 7.5 - Request feedback organized into three categories:
a. Correctness & edge cases: bugs, error handling gaps, race conditions, missing validations, missing or insufficient tests for changes (verify planned test files from Step 2 are present in the diff)
b. Conventions & consistency: naming, file structure, patterns,
.claude/rules/compliance (lightweight check — Step 7.5 handles the thorough review) c. Simplicity & maintainability: unnecessary complexity, duplication, unclear abstractions - If
custom_instructionsis configured, include the instructions text in the review request and have the reviewer verify compliance and report conflicts - Reviewer should only report actionable findings. If none, explicitly state "No actionable findings"
- Include
- If reviewer returned "No actionable findings": mark this and remaining iteration items as
completed(skip). MarkStep 8: Code Reviewascompletedand proceed to Step 9. - Otherwise: autonomously fix genuine issues or reject inapplicable points with reason — do not ask the user for judgment on individual review findings. Mark this iteration item as
completed.- If code was modified: re-run Step 7 and Step 7.5 (with same base-commit from Step 2), then continue to the next pending iteration item (back to step 1). Code fixes routinely introduce fresh bugs, tighten one place while loosening another, or miss a caller the author didn't know about — the next review round is how those leaks get caught. Don't short-circuit based on confidence in the fix itself
- If all points were rejected (no modifications): mark remaining iteration items as
completed(skip — there is nothing new for the next reviewer to look at) Continue to the next pending iteration item with: - the latest
git diff <base-commit> - a summary of fixes made and rejections with reasons
- the same three-category structure,
.claude/rules/reference, and "No actionable findings" requirement
- If all N iteration items are completed and actionable feedback still remains, present the unresolved points to user for decision.
Mark Step 8: Code Review as completed.
Step 9: Update Rules
Skill(extract-rules)with--from-conversation(always)Skill(extract-rules)with--update(only if significant structural/pattern changes occurred)- If extract-rules is unavailable, skip this step and inform user
Step 10: Completion Hooks
Skip this step if hooks.on_complete is not configured. Mark Step 10: Completion Hooks as in_progress.
- Execute each entry in
hooks.on_completein order:Skill(<name>)pattern: invoke the skill- Other strings: execute as a Bash command
- If a hook fails, report the error but continue executing remaining hooks. Include as warnings in the Completion summary
- After all hooks complete (or are skipped), mark
Step 10: Completion Hooksascompletedand proceed to Completion
Completion
Report summary: tasks completed, files modified, test results, review outcomes, rules updated.
If this run was executing a subtask from a decomposition state file, also do the following (all reads/writes target the canonical state-file path recorded in Step 1.5):
- Mark the current subtask's
statusascompletedin the canonical state file and write back - Ask the user for an optional PR URL for this subtask. On a non-empty answer, set the subtask's
prfield and write back; otherwise leave itnull - Refresh the parent-task TodoWrite row's
<done>/<total>count - Find the next runnable subtask (smallest-id
pendingwith alldepends_oncompleted) - If a next subtask exists: tell the user to commit the current subtask's changes and open a PR before resuming, then start a new session with
/dev-workflow --resume <slug>. Explain why this matters: the next run records a fresh base-commit from HEAD, so uncommitted changes would leak into the next subtask's diff. The workflow itself never stages, commits, or pushes - If no next subtask exists (all subtasks completed): delete the canonical state file via
rm <canonical-path>, remove the parent-task TodoWrite row, and include every subtask's title and recordedpr(if any) in the parent-task completion summary