Execute Work
Use the actual current date from runtime context when identifying the latest
plan document or updating dated execution artifacts.
$fw:work is the execution router and completion gate in Flywheel's compact
project loop. It takes a plan, spec, todo file, or clear work request and turns
it into implemented, validated repo changes. The goal is not to stay busy. The
goal is to finish complete vertical slices, validate them against repo truth,
pull in helper workflows only when the task actually needs them, and leave the
tree ready for review and commit.
$fw:brainstorm defines WHAT to build. $fw:plan defines HOW to build
it. $fw:work executes the plan, stays grounded in the repo, and absorbs
helper-stage selection for things like docs, browser proof, rollout, verify,
observability, logging, architecture strategy, maintainability, or
simplification when the work needs those surfaces before review.
When directly invoked, always execute. Do not treat a direct invocation as
"not an execution task" and exit. If the work is large or underdefined enough
that execution would be irresponsible, recommend $fw:brainstorm or
$fw:plan, explain why, and honor the user's choice if they want to continue.
Interaction Method
Follow ../references/host-interaction-contract.md.
Call the exact host question tool named in
../references/host-interaction-contract.md when that tool is available. Do
not ask for raw 1/2/3 replies when the host already offers a choice surface.
When the workflow spans multiple material steps, use the host task-tracking
tool named in ../references/host-interaction-contract.md to create and
maintain a short task list.
Ask one question at a time. Prefer concise single-select choices when natural
options exist.
When runtime tradeoffs are real, present a short predicted choice list with the
recommended label first and rely on the host's native freeform final path when
it exists.
In automated or non-interactive contexts, skip approval prompts once ambiguity
is low enough to proceed responsibly.
Reference Loading Map
Do not preload every reference. Load only what the current phase needs:
- Read
references/commit-workflow.md only when all implementation tasks are
complete and execution transitions from Phase 2 into quality check and
commit.
- Read
references/execution-router.md when execution needs detailed
delegation rules, parallel safety checks, test-completeness reminders, or
incremental commit heuristics.
- Read
../references/workflow-gates.md when execution is ready to hand off to
review, rollout, spin, or commit.
- Read
../observability/references/service-readiness-matrix.md only when the
work changes runtime behavior, contracts, state, rollout posture, retries,
queues, migrations, or other blast-radius-sensitive boundaries.
Core Principles
- Finish complete slices — finishing the feature matters more than looking
busy.
- Touch grass before and during execution — replace guesses with repo
truth by finding the actual commands, policies, and patterns that can prove
or falsify the plan's hypotheses.
- Use the plan as a decision artifact — follow its scope, sequencing, and
rationale, but adapt implementation details when the codebase proves a
better path.
- Follow what exists — mirror current naming, architecture, and test
idioms before inventing anything new.
- Use specialist skills at activation points — load TDD, browser proof,
docs, rollout, observability, logging, simplify, or commit guidance only
when the current slice needs that surface.
- Respect context and decisions — when the plan or code touches domain
language, boundaries, workflow contracts, or durable product choices, carry
existing context and decision records into execution and route conflicts to
decision.
- Use TDD for behavior work — feature work, bug fixes, public contract
changes, regression-prone paths, and behavior-preserving refactors load
tdd before implementation unless an explicit exception applies.
- Test continuously — run the right checks while the work is still fresh.
- Keep progress visible — maintain task state, note blockers, and finish
with a clean quality gate.
- Prefer fewer extra visible handoffs — use helper workflows when they add
real value beyond the default shape -> work -> review -> optional spin ->
commit loop.
Input Document
#$ARGUMENTS
If <input_document> is blank:
- Search
docs/plans/ for the most recent *-plan.md.
- If one obvious candidate exists, announce that it will be used and continue.
- If no plan is found or multiple candidates are equally plausible, ask the
user what to implement.
If the input resolves to an existing file path, treat it as the work document.
If the input is not a file path, treat it as a bare prompt describing the work.
Workflow
Phase 0: Input Triage
Determine how to proceed based on what was provided in <input_document>.
Plan or specification document — the input is a file path to an existing
plan, specification, or todo file. Skip to Phase 1. In interactive contexts,
execution from a plan or specification still requires the plan-to-work approval
gate in Phase 1 unless the user explicitly asked to implement that artifact in
the same turn.
Bare prompt — the input describes work rather than pointing at a file:
Scan the work area
- Identify files likely to change based on the prompt.
- Find existing test files for those areas by looking for test or spec files
that import, reference, or share naming with the implementation files.
- Note local patterns and conventions in the affected areas.
Assess complexity and route
| Complexity |
Signals |
Action |
| Trivial |
1-2 files, no behavioral change, typo, rename, narrow config edit |
Proceed to Phase 1 step 2, then implement directly. Skip task-list construction and the execution strategy phase. If discovery proves the change is behavior-bearing after all, apply the TDD default before implementation. |
| Small / Medium |
Clear scope, bounded change, usually under 10 files |
Build a host-tracked task list from discovery and proceed to Phase 1 step 2. |
| Large |
Cross-cutting, architectural, high-risk, or likely 10+ files, including auth, payments, migrations, or shared infra |
Explain that the work would benefit from $fw:brainstorm or $fw:plan to surface edge cases and scope boundaries. Honor the user's choice. If proceeding, build a host-tracked task list and continue to Phase 1 step 2. |
Phase 1: Quick Start
1. Read Plan and Clarify
Skip this step when arriving from Phase 0 with a bare prompt.
- Read the work document completely.
- Treat the plan as a decision artifact, not an execution script.
- If the plan includes sections such as
Implementation Units,
Work Breakdown, Requirements Trace, Files, Test Scenarios, or
Verification, use those as the primary source material for execution.
- If the plan includes
Dependencies And Parallelism or per-unit
Execution mode, use them as the default execution shape. Treat
parallel-ready as eligible rather than mandatory, and keep serial units
ordered.
- Check for
Test posture on each implementation unit. If it is tdd, load
the tdd skill before writing implementation code for that unit. If it is
characterization, capture current behavior before changing it. Treat
no-new-tests as valid only when the plan gives a clear exception reason.
- If a behavior-bearing feature, bug fix, public contract change,
regression-prone path, or behavior-preserving refactor lacks an explicit
Test posture, treat it as tdd by default and load the tdd skill before
implementation. Use a different posture only with a recorded exception and
verification path.
- Check each unit's
Vertical slice field when present. Execute vertical
behavior slices one at a time. If the plan is organized as horizontal artifact
batches such as all tests, all service edits, all docs, all migrations, or all
generated artifacts, pause and route back to fw:deepen unless the plan marks
those units as justified horizontal exceptions.
- Check for
Execution note on each implementation unit and carry any
sequencing, rollout, or other non-test posture into the task.
- If the plan includes
Architecture and Pattern Decisions or an equivalent
section, carry those boundary, pattern, and clean-code constraints into the
task instead of rediscovering them ad hoc.
- Check for
Deferred to Implementation or Implementation-Time Unknowns.
These are questions intentionally left for execution. Note them before
starting so they guide the work instead of surprising you mid-flight.
- Check for a
Scope Boundaries section and keep its explicit non-goals active
while implementing.
- Review any references or links provided in the plan.
- If the plan already has checked implementation-unit checkboxes, treat those
units as already completed unless repo truth clearly contradicts them.
- If the user explicitly asks for TDD, test-first, or red-green-refactor
execution in this session, load the
tdd skill and honor that request even
if the plan is silent.
- If the user explicitly asks for characterization-first execution in this
session, honor that request even if the plan is silent.
- If anything important is unclear or ambiguous, ask clarifying questions now.
- In interactive mode, get user approval to proceed after clarifications.
When the work document is a plan or specification, call the exact host
question tool named in the host interaction contract when it is available and
ask whether the user is happy to start implementation from this artifact.
Use a portable choice surface such as:
- Start work now (Recommended) - confirms the artifact is accepted as
the implementation basis
- Review or deepen first - pause execution and route back to the
appropriate shaping or document-review path
- Done for now - leave the artifact saved without starting work
A direct same-turn instruction such as "implement this plan now" or a
selection from the
fw:plan post-generation question counts as approval.
A generic mention of a plan path does not.
- Do not skip clarification when the plan leaves room for materially different
outcomes.
2. Touch Grass and Setup Environment
Before creating tasks or editing code, perform a Touch Grass pass. The
point is to find the repo's actual truth sources for validation rather than
assuming commands, policies, or conventions from memory.
Build a short ground-truth ledger from the repo:
- Read the repo-root
AGENTS.md when present. Read CLAUDE.md only when
present or when the repo still uses it as compatibility context.
- Read
.flywheel/config.local.yaml when present and carry forward only the
local policy gates that materially affect this task, such as browser proof,
reproducer-before-fix, review-before-commit, or runtime validation.
- When the active repo has
docs/solutions/, search that local store for the
target area before editing. Prefer frontmatter-first lookup by
files_touched, module, tags, problem_type, component, and title,
then read only the strongest hits. Prefer doc_status: active and follow
superseded_by when present.
- Inspect the nearest project manifests and automation surfaces that can prove
how the repo wants work validated. Depending on stack, this may include
package.json, pyproject.toml, Gemfile, go.mod, Makefile,
justfile, turbo.json, nx.json, CI workflows, or repo-local scripts.
- Capture repo axioms and non-negotiables surfaced by those sources, including
review expectations, branch safety rules, tracker or release workflow hints,
and other project-level constraints that should shape execution.
- Confirm the actual commands, tasks, or entry points for:
- tests
- linting or formatting
- typechecking or static analysis
- audit, security, or policy checks when relevant
- app boot or dev server commands when relevant to manual validation
- Identify the repo's observability surfaces when the work changes runtime
behavior, for example:
- logging wrappers or event helpers
- tracing or correlation libraries
- metrics, dashboards, or alert references
- error trackers or saved log queries
- For runtime-risky work, capture the current behavior on the affected path and
the likely blast radius if the change is wrong. Prefer concrete boundaries
such as single request, single tenant, queue, worker pool, node, region, or
data-correctness impact over generic "high risk" labels.
- Read nearby implementation and test files to confirm local code and test
idioms.
- Prefer facts backed by files over hypotheses from the plan. If a plan names a
command that is not confirmed in the repo, correct course to repo truth and
note the adjustment.
- If a needed validation command cannot be established from repo evidence, ask
now or explicitly mark the gap before proceeding.
When runtime-facing work depends on telemetry design or log quality, load
$fw:observability and $fw:logging instead of improvising a new instrumentation
shape from memory.
When runtime-risky work changes contracts, state, retries, queueing, or
cross-service behavior, read
../observability/references/service-readiness-matrix.md and keep the
applicable dimensions in the ground-truth ledger.
Use that ledger throughout execution. The ledger should answer: "What commands
or artifacts will tell me whether the plan's hypothesis is actually true?"
For runtime-facing work, the ledger should also answer: "What logs, traces,
metrics, dashboards, or queries will tell me this change is healthy or broken?"
For runtime-risky work, the ledger should also answer: "What does this path do
today, what failure modes matter most, and how far can a mistake spread?"
If a local workflow policy file exists, the ledger should also answer: "Which
completion gates in this repo are required here versus merely recommended?"
If the repo truth reveals multiple viable reliability postures, such as retry
vs fail-fast or fail-open vs fail-closed, call the host question tool with a
concise choice surface before editing:
- current repo truth
- top failure modes
- likely blast radius
- 2-3 viable options at most
- recommendation and proof hooks
If a relevant active-repo docs/solutions/ entry exists and the current work
would contradict it, update the plan of attack immediately instead of plowing
ahead as though the prior learning does not exist.
Then check the current branch:
current_branch=$(git branch --show-current)
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
# Safer fallbacks if remote HEAD isn't set
if [ -z "$default_branch" ]; then
default_branch=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' | head -n1)
fi
if [ -z "$default_branch" ] && command -v gh >/dev/null 2>&1; then
default_branch=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name 2>/dev/null)
fi
if [ -z "$default_branch" ]; then
echo "Unable to determine the default branch safely. Ask the user or run $fw:setup worktrees before creating a branch or worktree."
exit 1
fi
If already on a feature branch (not the default branch):
Check whether the branch name is meaningful. Names like
feat/crowd-sniff or fix/email-validation communicate intent. Opaque or
auto-generated names do not.
If the branch name is meaningless or auto-generated, recommend renaming it
before continuing:
git branch -m <meaningful-name>
Derive the new name from the plan title or work description.
Ask: "Continue working on [current_branch], or create a new branch?"
- If continuing, proceed to step 3.
- If creating new, follow Option A or B below.
If on the default branch, choose how to proceed:
Option A: Create a new branch
git pull origin [default_branch]
git checkout -b feature-branch-name
Use a meaningful branch name based on the work, for example
feat/user-authentication or fix/email-validation.
Option B: Use a worktree (recommended for parallel development)
Prefer $fw:worktree when it is available. Use the bundled manager script
instead of raw git worktree add so ignore hygiene and env-file copying stay
consistent.
If no manager is available, create an isolated worktree directly with git,
for example:
git worktree add ../<worktree-dir> -b <feature-branch-name> <default_branch>
Continue the task from that isolated worktree.
Option C: Continue on the default branch
- Requires explicit user confirmation.
- Only proceed after the user explicitly says "yes, commit to [default_branch]".
- Never commit directly to the default branch without explicit permission.
Recommendation: Prefer a worktree when:
- parallel feature development is likely
- keeping the default branch clean matters
- frequent branch switching is expected
3. Create Task List
Skip this step if Phase 0 already built the task list or if Phase 0 classified
the work as Trivial.
- Use the host task-tracking tool named in
../references/host-interaction-contract.md to break the work into
actionable tasks. If the host does not expose one, keep a concise visible
checklist in chat.
- For plan-driven work, default to one host task per remaining vertical
implementation slice. Reuse the unit label in the task name so the task tool
and plan stay aligned.
- Add separate tasks only for cross-cutting work not already represented by a
unit, such as initial bare-prompt discovery or the final quality gate.
- Derive tasks from the plan's implementation units, dependencies, files, test
targets, and verification criteria.
- Use each unit's
Execution mode plus Dependencies to determine whether it
is blocked, serial, or eligible for a later parallel-ready batch. If the plan
lacks Execution mode, default units to serial.
- Carry each unit's
Test posture and Execution note into the task when
present.
- Read every unit's
Patterns to follow field before implementing. Those
references exist to keep execution aligned with the codebase.
- Use each unit's
Red signal, Green signal, and Verification fields as
the primary proof path when the unit is tdd; otherwise use Verification
as the primary "done" signal.
- Keep proof slice-local. Do not write all tests for every unit first, then all
implementation, then all docs, config, migrations, or generated artifacts.
Finish the current slice's red, green, refactor, and relevant proof before
starting the next behavior slice.
- Keep the host task list and the plan document synchronized: the task tool
carries
in_progress and blocked, while the plan checkbox flips to [x]
only after the unit's verification passes.
- Do not expect the plan to contain implementation code, shell choreography, or
micro-step TDD instructions. Do expect a
tdd unit to provide enough red and
green signal to start test-first execution.
- Include testing and quality-check tasks, not just code-edit tasks.
- Keep tasks specific, dependency-aware, and completable.
4. Choose Execution Strategy
Default to inline execution. Load references/execution-router.md only when
delegation, parallel-ready units, test-completeness checks, or incremental
commit heuristics need more detail.
Parallel work is allowed only when the user explicitly asked for delegated or
parallel agent work, dependencies are clear, and the file-overlap check passes.
Serial units stay serial.
Phase 2: Execute
1. Task Execution Loop
For plan-driven work, treat each unchecked vertical implementation slice as the
default task. Start with the first serial slice or the first
dependency-cleared parallel-ready batch identified by the plan. Horizontal
exception units are serial unless the plan gives a concrete independence reason
and the shared-write safety check still passes.
For each task, read the relevant repo files, execute only the current slice,
run its proof, and update task state only after verification passes. Keep plan
checkboxes synchronized with completed slices; use host task state for
in_progress or blocked.
When a unit carries a Test posture, honor it:
- tdd — load
tdd, write the failing test before implementation, verify
the red failure, implement the smallest green change for the current vertical
slice, refactor if useful, and report
red/green/refactor evidence before moving to the next slice
- characterization-first — capture current behavior before changing it
- no-new-tests — only when the unit is truly mechanical, config-only, or
otherwise justified
For bare-prompt tasks or plan units without Test posture, apply the same TDD
default to behavior-bearing feature work, bug fixes, public contracts,
regression-prone paths, and behavior-preserving refactors before editing
implementation code. Record the exception when TDD is not warranted.
When a unit carries an Execution note, honor it as sequencing, rollout, or
other execution guidance. Do not use Execution note as a substitute for
Test posture.
Before editing behavior, find the nearest existing tests. If test coverage or
parallel execution detail is not obvious, load references/execution-router.md
for the fuller checklist.
2. Incremental Commits
After each verified logical unit, decide whether an incremental commit is useful
or whether the unit should remain part of a larger coherent commit. Load
references/execution-router.md if the commit boundary is non-obvious.
3. Follow Existing Patterns
- Read the plan's similar-code references before implementing.
- Match naming conventions and file organization exactly.
- Reuse existing components, helpers, and test idioms where possible.
- Follow project coding standards from
AGENTS.md and repo-local instruction
files.
- When in doubt, search for similar implementations and mirror them.
4. Test Continuously
- Run the relevant checks after each significant change.
- Do not wait until the end to find out the approach was wrong.
- Fix failures immediately.
- Add tests for new behavior, update tests for changed behavior, and remove or
update tests for deleted behavior.
- Prefer public interfaces and real chains where practical. Use mocks for true
system boundaries, not internal convenience.
5. Simplify as You Go
After a cluster of related units, or every 2-3 units, review the changed files
for simplification opportunities:
- consolidate duplicated patterns
- extract shared helpers where the repo already favors that shape
- improve reuse and efficiency when it reduces real complexity
- route to
maintainability when the issue is future edit cost rather than
removable complexity
- route to
architecture-strategy or pattern-recognition when current repo
truth invalidates a planned boundary or named-pattern choice
Do not simplify after every single task. Early duplication can still be
intentional until the shape of the work is clear.
If a simplify skill or equivalent exists, use it. If the main issue is future
edit cost rather than removable complexity, use a maintainability pass instead.
Otherwise perform the review yourself.
6. Figma Design Sync
If the work is UI-heavy and the task includes Figma designs:
- implement the components to spec
- compare implementation against the design iteratively
- fix visual differences before moving on
7. Track Progress
- Keep the host task list current as work completes.
- When the input document is a plan, mirror completed unit state back into the
plan checkboxes and keep in-progress state in the host task tool rather than
faking an in-progress checkbox format.
- Note blockers and unexpected discoveries.
- Create new tasks if scope legitimately expands.
- Keep the user informed at major milestones.
Phase 3-4: Quality Check and Commit It
If the completed change likely changed setup steps, public interfaces, config
contracts, CLI behavior, or user workflows, offer $fw:docs before final
review. If the user agrees, complete that docs pass first and then resume the
path into review and commit.
When all Phase 2 tasks are complete and execution transitions to quality check,
read ../references/workflow-gates.md and references/commit-workflow.md.
Apply the Work-Ready gate before handing off to $fw:review: implementation,
posture-specific evidence, relevant checks, task state, plan checkbox state,
and worktree status must be complete or listed as blockers. Close the execution
portion with the canonical handoff card: Stage, Artifact, Ready, Open
decisions, Evidence, and Next.
If the completed change is runtime-risky and the release posture is still
unclear, route through $fw:rollout after $fw:review and before
$fw:commit so activation sequence, validation window, and rollback
triggers are explicit instead of being squeezed into the final commit step.
Common Failure Modes
- Analysis paralysis — read enough to move, then execute.
- Skipping clarification — ask before building the wrong thing.
- Ignoring plan references — they exist to keep the work aligned.
- Guessing commands — Touch Grass first and let repo truth drive checks.
- Testing only at the end — continuous testing prevents surprise piles.
- Losing task state — update progress as you go.
- Blind parallelism — only batch units that are explicitly
parallel-ready and still pass a fresh overlap check.
- Premature checkbox flips — do not mark a plan unit complete until its
verification and relevant tests pass.
- Stopping at 80% — finish the feature and close the quality gate.
- Skipping review — every change gets reviewed, even when the review is
lightweight.
- Turning helper checks into default ceremony — use docs, browser proof,
rollout, and verify when the task needs them, not as a fixed visible
checklist layered on top of the default review step.
1---2name: work3description: Execute ready implementation work. Use for plans, specs, todos, or clear requests that need tracked changes and validation.4---56# Execute Work78Use the actual current date from runtime context when identifying the latest9plan document or updating dated execution artifacts.1011`$fw:work` is the execution router and completion gate in Flywheel's compact12project loop. It takes a plan, spec, todo file, or clear work request and turns13it into implemented, validated repo changes. The goal is not to stay busy. The14goal is to finish complete vertical slices, validate them against repo truth,15pull in helper workflows only when the task actually needs them, and leave the16tree ready for review and commit.1718`$fw:brainstorm` defines **WHAT** to build. `$fw:plan` defines **HOW** to build19it. `$fw:work` executes the plan, stays grounded in the repo, and absorbs20helper-stage selection for things like docs, browser proof, rollout, verify,21observability, logging, architecture strategy, maintainability, or22simplification when the work needs those surfaces before review.2324**When directly invoked, always execute.** Do not treat a direct invocation as25"not an execution task" and exit. If the work is large or underdefined enough26that execution would be irresponsible, recommend `$fw:brainstorm` or27`$fw:plan`, explain why, and honor the user's choice if they want to continue.2829## Interaction Method3031Follow `../references/host-interaction-contract.md`.3233Call the exact host question tool named in34`../references/host-interaction-contract.md` when that tool is available. Do35not ask for raw `1/2/3` replies when the host already offers a choice surface.3637When the workflow spans multiple material steps, use the host task-tracking38tool named in `../references/host-interaction-contract.md` to create and39maintain a short task list.4041Ask one question at a time. Prefer concise single-select choices when natural42options exist.4344When runtime tradeoffs are real, present a short predicted choice list with the45recommended label first and rely on the host's native freeform final path when46it exists.4748In automated or non-interactive contexts, skip approval prompts once ambiguity49is low enough to proceed responsibly.5051## Reference Loading Map5253Do not preload every reference. Load only what the current phase needs:5455- Read `references/commit-workflow.md` only when all implementation tasks are56 complete and execution transitions from Phase 2 into quality check and57 commit.58- Read `references/execution-router.md` when execution needs detailed59 delegation rules, parallel safety checks, test-completeness reminders, or60 incremental commit heuristics.61- Read `../references/workflow-gates.md` when execution is ready to hand off to62 review, rollout, spin, or commit.63- Read `../observability/references/service-readiness-matrix.md` only when the64 work changes runtime behavior, contracts, state, rollout posture, retries,65 queues, migrations, or other blast-radius-sensitive boundaries.6667## Core Principles68691. **Finish complete slices** — finishing the feature matters more than looking70 busy.712. **Touch grass before and during execution** — replace guesses with repo72 truth by finding the actual commands, policies, and patterns that can prove73 or falsify the plan's hypotheses.743. **Use the plan as a decision artifact** — follow its scope, sequencing, and75 rationale, but adapt implementation details when the codebase proves a76 better path.774. **Follow what exists** — mirror current naming, architecture, and test78 idioms before inventing anything new.795. **Use specialist skills at activation points** — load TDD, browser proof,80 docs, rollout, observability, logging, simplify, or commit guidance only81 when the current slice needs that surface.826. **Respect context and decisions** — when the plan or code touches domain83 language, boundaries, workflow contracts, or durable product choices, carry84 existing context and decision records into execution and route conflicts to85 `decision`.867. **Use TDD for behavior work** — feature work, bug fixes, public contract87 changes, regression-prone paths, and behavior-preserving refactors load88 `tdd` before implementation unless an explicit exception applies.898. **Test continuously** — run the right checks while the work is still fresh.909. **Keep progress visible** — maintain task state, note blockers, and finish91 with a clean quality gate.9210. **Prefer fewer extra visible handoffs** — use helper workflows when they add93 real value beyond the default shape -> work -> review -> optional spin ->94 commit loop.9596## Input Document9798<input_document> #$ARGUMENTS </input_document>99100If `<input_document>` is blank:1011021. Search `docs/plans/` for the most recent `*-plan.md`.1032. If one obvious candidate exists, announce that it will be used and continue.1043. If no plan is found or multiple candidates are equally plausible, ask the105 user what to implement.106107If the input resolves to an existing file path, treat it as the work document.108109If the input is not a file path, treat it as a bare prompt describing the work.110111## Workflow112113### Phase 0: Input Triage114115Determine how to proceed based on what was provided in `<input_document>`.116117**Plan or specification document** — the input is a file path to an existing118plan, specification, or todo file. Skip to Phase 1. In interactive contexts,119execution from a plan or specification still requires the plan-to-work approval120gate in Phase 1 unless the user explicitly asked to implement that artifact in121the same turn.122123**Bare prompt** — the input describes work rather than pointing at a file:1241251. **Scan the work area**126127 - Identify files likely to change based on the prompt.128 - Find existing test files for those areas by looking for test or spec files129 that import, reference, or share naming with the implementation files.130 - Note local patterns and conventions in the affected areas.1311322. **Assess complexity and route**133134 | Complexity | Signals | Action |135 | --- | --- | --- |136 | **Trivial** | 1-2 files, no behavioral change, typo, rename, narrow config edit | Proceed to Phase 1 step 2, then implement directly. Skip task-list construction and the execution strategy phase. If discovery proves the change is behavior-bearing after all, apply the TDD default before implementation. |137 | **Small / Medium** | Clear scope, bounded change, usually under 10 files | Build a host-tracked task list from discovery and proceed to Phase 1 step 2. |138 | **Large** | Cross-cutting, architectural, high-risk, or likely 10+ files, including auth, payments, migrations, or shared infra | Explain that the work would benefit from `$fw:brainstorm` or `$fw:plan` to surface edge cases and scope boundaries. Honor the user's choice. If proceeding, build a host-tracked task list and continue to Phase 1 step 2. |139140### Phase 1: Quick Start141142#### 1. Read Plan and Clarify143144Skip this step when arriving from Phase 0 with a bare prompt.145146- Read the work document completely.147- Treat the plan as a decision artifact, not an execution script.148- If the plan includes sections such as `Implementation Units`,149 `Work Breakdown`, `Requirements Trace`, `Files`, `Test Scenarios`, or150 `Verification`, use those as the primary source material for execution.151- If the plan includes `Dependencies And Parallelism` or per-unit152 `Execution mode`, use them as the default execution shape. Treat153 `parallel-ready` as eligible rather than mandatory, and keep `serial` units154 ordered.155- Check for `Test posture` on each implementation unit. If it is `tdd`, load156 the `tdd` skill before writing implementation code for that unit. If it is157 `characterization`, capture current behavior before changing it. Treat158 `no-new-tests` as valid only when the plan gives a clear exception reason.159- If a behavior-bearing feature, bug fix, public contract change,160 regression-prone path, or behavior-preserving refactor lacks an explicit161 `Test posture`, treat it as `tdd` by default and load the `tdd` skill before162 implementation. Use a different posture only with a recorded exception and163 verification path.164- Check each unit's `Vertical slice` field when present. Execute vertical165 behavior slices one at a time. If the plan is organized as horizontal artifact166 batches such as all tests, all service edits, all docs, all migrations, or all167 generated artifacts, pause and route back to `fw:deepen` unless the plan marks168 those units as justified horizontal exceptions.169- Check for `Execution note` on each implementation unit and carry any170 sequencing, rollout, or other non-test posture into the task.171- If the plan includes `Architecture and Pattern Decisions` or an equivalent172 section, carry those boundary, pattern, and clean-code constraints into the173 task instead of rediscovering them ad hoc.174- Check for `Deferred to Implementation` or `Implementation-Time Unknowns`.175 These are questions intentionally left for execution. Note them before176 starting so they guide the work instead of surprising you mid-flight.177- Check for a `Scope Boundaries` section and keep its explicit non-goals active178 while implementing.179- Review any references or links provided in the plan.180- If the plan already has checked implementation-unit checkboxes, treat those181 units as already completed unless repo truth clearly contradicts them.182- If the user explicitly asks for TDD, test-first, or red-green-refactor183 execution in this session, load the `tdd` skill and honor that request even184 if the plan is silent.185- If the user explicitly asks for characterization-first execution in this186 session, honor that request even if the plan is silent.187- If anything important is unclear or ambiguous, ask clarifying questions now.188- In interactive mode, get user approval to proceed after clarifications.189 When the work document is a plan or specification, call the exact host190 question tool named in the host interaction contract when it is available and191 ask whether the user is happy to start implementation from this artifact.192 Use a portable choice surface such as:193 1. **Start work now (Recommended)** - confirms the artifact is accepted as194 the implementation basis195 2. **Review or deepen first** - pause execution and route back to the196 appropriate shaping or document-review path197 3. **Done for now** - leave the artifact saved without starting work198 A direct same-turn instruction such as "implement this plan now" or a199 selection from the `fw:plan` post-generation question counts as approval.200 A generic mention of a plan path does not.201- Do not skip clarification when the plan leaves room for materially different202 outcomes.203204#### 2. Touch Grass and Setup Environment205206Before creating tasks or editing code, perform a **Touch Grass pass**. The207point is to find the repo's actual truth sources for validation rather than208assuming commands, policies, or conventions from memory.209210Build a short **ground-truth ledger** from the repo:211212- Read the repo-root `AGENTS.md` when present. Read `CLAUDE.md` only when213 present or when the repo still uses it as compatibility context.214- Read `.flywheel/config.local.yaml` when present and carry forward only the215 local policy gates that materially affect this task, such as browser proof,216 reproducer-before-fix, review-before-commit, or runtime validation.217- When the active repo has `docs/solutions/`, search that local store for the218 target area before editing. Prefer frontmatter-first lookup by219 `files_touched`, `module`, `tags`, `problem_type`, `component`, and title,220 then read only the strongest hits. Prefer `doc_status: active` and follow221 `superseded_by` when present.222- Inspect the nearest project manifests and automation surfaces that can prove223 how the repo wants work validated. Depending on stack, this may include224 `package.json`, `pyproject.toml`, `Gemfile`, `go.mod`, `Makefile`,225 `justfile`, `turbo.json`, `nx.json`, CI workflows, or repo-local scripts.226- Capture repo axioms and non-negotiables surfaced by those sources, including227 review expectations, branch safety rules, tracker or release workflow hints,228 and other project-level constraints that should shape execution.229- Confirm the actual commands, tasks, or entry points for:230 - tests231 - linting or formatting232 - typechecking or static analysis233 - audit, security, or policy checks when relevant234 - app boot or dev server commands when relevant to manual validation235- Identify the repo's observability surfaces when the work changes runtime236 behavior, for example:237 - logging wrappers or event helpers238 - tracing or correlation libraries239 - metrics, dashboards, or alert references240 - error trackers or saved log queries241- For runtime-risky work, capture the current behavior on the affected path and242 the likely blast radius if the change is wrong. Prefer concrete boundaries243 such as single request, single tenant, queue, worker pool, node, region, or244 data-correctness impact over generic "high risk" labels.245- Read nearby implementation and test files to confirm local code and test246 idioms.247- Prefer facts backed by files over hypotheses from the plan. If a plan names a248 command that is not confirmed in the repo, correct course to repo truth and249 note the adjustment.250- If a needed validation command cannot be established from repo evidence, ask251 now or explicitly mark the gap before proceeding.252253When runtime-facing work depends on telemetry design or log quality, load254`$fw:observability` and `$fw:logging` instead of improvising a new instrumentation255shape from memory.256257When runtime-risky work changes contracts, state, retries, queueing, or258cross-service behavior, read259`../observability/references/service-readiness-matrix.md` and keep the260applicable dimensions in the ground-truth ledger.261262Use that ledger throughout execution. The ledger should answer: "What commands263or artifacts will tell me whether the plan's hypothesis is actually true?"264265For runtime-facing work, the ledger should also answer: "What logs, traces,266metrics, dashboards, or queries will tell me this change is healthy or broken?"267268For runtime-risky work, the ledger should also answer: "What does this path do269today, what failure modes matter most, and how far can a mistake spread?"270271If a local workflow policy file exists, the ledger should also answer: "Which272completion gates in this repo are required here versus merely recommended?"273274If the repo truth reveals multiple viable reliability postures, such as retry275vs fail-fast or fail-open vs fail-closed, call the host question tool with a276concise choice surface before editing:277278- current repo truth279- top failure modes280- likely blast radius281- 2-3 viable options at most282- recommendation and proof hooks283284If a relevant active-repo `docs/solutions/` entry exists and the current work285would contradict it, update the plan of attack immediately instead of plowing286ahead as though the prior learning does not exist.287288Then check the current branch:289290```bash291current_branch=$(git branch --show-current)292default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')293294# Safer fallbacks if remote HEAD isn't set295if [ -z "$default_branch" ]; then296 default_branch=$(git remote show origin 2>/dev/null | sed -n '/HEAD branch/s/.*: //p' | head -n1)297fi298299if [ -z "$default_branch" ] && command -v gh >/dev/null 2>&1; then300 default_branch=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name 2>/dev/null)301fi302303if [ -z "$default_branch" ]; then304 echo "Unable to determine the default branch safely. Ask the user or run $fw:setup worktrees before creating a branch or worktree."305 exit 1306fi307```308309**If already on a feature branch** (not the default branch):310311- Check whether the branch name is meaningful. Names like312 `feat/crowd-sniff` or `fix/email-validation` communicate intent. Opaque or313 auto-generated names do not.314- If the branch name is meaningless or auto-generated, recommend renaming it315 before continuing:316317 ```bash318 git branch -m <meaningful-name>319 ```320321 Derive the new name from the plan title or work description.322323- Ask: "Continue working on `[current_branch]`, or create a new branch?"324 - If continuing, proceed to step 3.325 - If creating new, follow Option A or B below.326327**If on the default branch**, choose how to proceed:328329**Option A: Create a new branch**330331```bash332git pull origin [default_branch]333git checkout -b feature-branch-name334```335336Use a meaningful branch name based on the work, for example337`feat/user-authentication` or `fix/email-validation`.338339**Option B: Use a worktree** (recommended for parallel development)340341- Prefer `$fw:worktree` when it is available. Use the bundled manager script342 instead of raw `git worktree add` so ignore hygiene and env-file copying stay343 consistent.344- If no manager is available, create an isolated worktree directly with git,345 for example:346347 ```bash348 git worktree add ../<worktree-dir> -b <feature-branch-name> <default_branch>349 ```350351- Continue the task from that isolated worktree.352353**Option C: Continue on the default branch**354355- Requires explicit user confirmation.356- Only proceed after the user explicitly says "yes, commit to [default_branch]".357- Never commit directly to the default branch without explicit permission.358359**Recommendation:** Prefer a worktree when:360361- parallel feature development is likely362- keeping the default branch clean matters363- frequent branch switching is expected364365#### 3. Create Task List366367Skip this step if Phase 0 already built the task list or if Phase 0 classified368the work as Trivial.369370- Use the host task-tracking tool named in371 `../references/host-interaction-contract.md` to break the work into372 actionable tasks. If the host does not expose one, keep a concise visible373 checklist in chat.374- For plan-driven work, default to one host task per remaining vertical375 implementation slice. Reuse the unit label in the task name so the task tool376 and plan stay aligned.377- Add separate tasks only for cross-cutting work not already represented by a378 unit, such as initial bare-prompt discovery or the final quality gate.379- Derive tasks from the plan's implementation units, dependencies, files, test380 targets, and verification criteria.381- Use each unit's `Execution mode` plus `Dependencies` to determine whether it382 is blocked, serial, or eligible for a later parallel-ready batch. If the plan383 lacks `Execution mode`, default units to `serial`.384- Carry each unit's `Test posture` and `Execution note` into the task when385 present.386- Read every unit's `Patterns to follow` field before implementing. Those387 references exist to keep execution aligned with the codebase.388- Use each unit's `Red signal`, `Green signal`, and `Verification` fields as389 the primary proof path when the unit is `tdd`; otherwise use `Verification`390 as the primary "done" signal.391- Keep proof slice-local. Do not write all tests for every unit first, then all392 implementation, then all docs, config, migrations, or generated artifacts.393 Finish the current slice's red, green, refactor, and relevant proof before394 starting the next behavior slice.395- Keep the host task list and the plan document synchronized: the task tool396 carries `in_progress` and `blocked`, while the plan checkbox flips to `[x]`397 only after the unit's verification passes.398- Do not expect the plan to contain implementation code, shell choreography, or399 micro-step TDD instructions. Do expect a `tdd` unit to provide enough red and400 green signal to start test-first execution.401- Include testing and quality-check tasks, not just code-edit tasks.402- Keep tasks specific, dependency-aware, and completable.403404#### 4. Choose Execution Strategy405406Default to inline execution. Load `references/execution-router.md` only when407delegation, parallel-ready units, test-completeness checks, or incremental408commit heuristics need more detail.409410Parallel work is allowed only when the user explicitly asked for delegated or411parallel agent work, dependencies are clear, and the file-overlap check passes.412Serial units stay serial.413414### Phase 2: Execute415416#### 1. Task Execution Loop417418For plan-driven work, treat each unchecked vertical implementation slice as the419default task. Start with the first `serial` slice or the first420dependency-cleared `parallel-ready` batch identified by the plan. Horizontal421exception units are serial unless the plan gives a concrete independence reason422and the shared-write safety check still passes.423424For each task, read the relevant repo files, execute only the current slice,425run its proof, and update task state only after verification passes. Keep plan426checkboxes synchronized with completed slices; use host task state for427`in_progress` or `blocked`.428429When a unit carries a `Test posture`, honor it:430431- **tdd** — load `tdd`, write the failing test before implementation, verify432 the red failure, implement the smallest green change for the current vertical433 slice, refactor if useful, and report434 red/green/refactor evidence before moving to the next slice435- **characterization-first** — capture current behavior before changing it436- **no-new-tests** — only when the unit is truly mechanical, config-only, or437 otherwise justified438439For bare-prompt tasks or plan units without `Test posture`, apply the same TDD440default to behavior-bearing feature work, bug fixes, public contracts,441regression-prone paths, and behavior-preserving refactors before editing442implementation code. Record the exception when TDD is not warranted.443444When a unit carries an `Execution note`, honor it as sequencing, rollout, or445other execution guidance. Do not use `Execution note` as a substitute for446`Test posture`.447448Before editing behavior, find the nearest existing tests. If test coverage or449parallel execution detail is not obvious, load `references/execution-router.md`450for the fuller checklist.451452#### 2. Incremental Commits453454After each verified logical unit, decide whether an incremental commit is useful455or whether the unit should remain part of a larger coherent commit. Load456`references/execution-router.md` if the commit boundary is non-obvious.457458#### 3. Follow Existing Patterns459460- Read the plan's similar-code references before implementing.461- Match naming conventions and file organization exactly.462- Reuse existing components, helpers, and test idioms where possible.463- Follow project coding standards from `AGENTS.md` and repo-local instruction464 files.465- When in doubt, search for similar implementations and mirror them.466467#### 4. Test Continuously468469- Run the relevant checks after each significant change.470- Do not wait until the end to find out the approach was wrong.471- Fix failures immediately.472- Add tests for new behavior, update tests for changed behavior, and remove or473 update tests for deleted behavior.474- Prefer public interfaces and real chains where practical. Use mocks for true475 system boundaries, not internal convenience.476477#### 5. Simplify as You Go478479After a cluster of related units, or every 2-3 units, review the changed files480for simplification opportunities:481482- consolidate duplicated patterns483- extract shared helpers where the repo already favors that shape484- improve reuse and efficiency when it reduces real complexity485- route to `maintainability` when the issue is future edit cost rather than486 removable complexity487- route to `architecture-strategy` or `pattern-recognition` when current repo488 truth invalidates a planned boundary or named-pattern choice489490Do not simplify after every single task. Early duplication can still be491intentional until the shape of the work is clear.492493If a simplify skill or equivalent exists, use it. If the main issue is future494edit cost rather than removable complexity, use a maintainability pass instead.495Otherwise perform the review yourself.496497#### 6. Figma Design Sync498499If the work is UI-heavy and the task includes Figma designs:500501- implement the components to spec502- compare implementation against the design iteratively503- fix visual differences before moving on504505#### 7. Track Progress506507- Keep the host task list current as work completes.508- When the input document is a plan, mirror completed unit state back into the509 plan checkboxes and keep in-progress state in the host task tool rather than510 faking an in-progress checkbox format.511- Note blockers and unexpected discoveries.512- Create new tasks if scope legitimately expands.513- Keep the user informed at major milestones.514515### Phase 3-4: Quality Check and Commit It516517If the completed change likely changed setup steps, public interfaces, config518contracts, CLI behavior, or user workflows, offer `$fw:docs` before final519review. If the user agrees, complete that docs pass first and then resume the520path into review and commit.521522When all Phase 2 tasks are complete and execution transitions to quality check,523read `../references/workflow-gates.md` and `references/commit-workflow.md`.524Apply the `Work-Ready` gate before handing off to `$fw:review`: implementation,525posture-specific evidence, relevant checks, task state, plan checkbox state,526and worktree status must be complete or listed as blockers. Close the execution527portion with the canonical handoff card: Stage, Artifact, Ready, Open528decisions, Evidence, and Next.529530If the completed change is runtime-risky and the release posture is still531unclear, route through `$fw:rollout` after `$fw:review` and before532`$fw:commit` so activation sequence, validation window, and rollback533triggers are explicit instead of being squeezed into the final commit step.534535## Common Failure Modes536537- **Analysis paralysis** — read enough to move, then execute.538- **Skipping clarification** — ask before building the wrong thing.539- **Ignoring plan references** — they exist to keep the work aligned.540- **Guessing commands** — Touch Grass first and let repo truth drive checks.541- **Testing only at the end** — continuous testing prevents surprise piles.542- **Losing task state** — update progress as you go.543- **Blind parallelism** — only batch units that are explicitly544 `parallel-ready` and still pass a fresh overlap check.545- **Premature checkbox flips** — do not mark a plan unit complete until its546 verification and relevant tests pass.547- **Stopping at 80%** — finish the feature and close the quality gate.548- **Skipping review** — every change gets reviewed, even when the review is549 lightweight.550- **Turning helper checks into default ceremony** — use docs, browser proof,551 rollout, and verify when the task needs them, not as a fixed visible552 checklist layered on top of the default review step.