SWE Workflow
Every code task starts with workflow triage. Bounded work stays lightweight; risky or coordination-heavy implementation uses a persisted plan.
Contract
- Triage first. Start the first reply to a code-related task with one of these declarations:
Workflow mode: Lightweight — <reason>; success: <outcome>; plan: no.
Workflow mode: Full
Reason: <one sentence>
Success criteria:
- <what done means>
Plan needed: yes
- Lightweight is the default for clear localized changes, bounded investigation, and read-only reviews or discovery—even when many files must be inspected. It uses the Behavioral Guards but no persisted plan.
- Full is required before implementation when work is risky or hard to reverse; changes API/schema/migration/security/configuration contracts; couples multiple subsystems; is a broad refactor/migration/cleanup; needs durable multi-session or multi-agent coordination; remains materially ambiguous after bounded discovery; or the user requests a plan. File count alone is a signal, not a trigger.
- Escalate before target-file edits. Lightweight discovery may gather evidence first. If Full criteria emerge, stop before mutating task files, declare Full mode, clarify decision-critical questions, create the plan, and then resume. If edits already began, preserve the verified state and escalate before expanding scope.
- Pre-edit gate (Full mode). Before mutating task target files: a plan directory must exist under
plans/<YYYY-MM-DD>-<slug>/, exactly one step file must have > Status: IN_PROGRESS, and the edit must map to that step. Read-only exploration and workflow-bookkeeping updates are allowed before this gate.
- Plan file format. Copy
references/task-overview-template.md to plan.md and references/step-template.md to each step file. Every step has ten fields: Status, Goal, Prerequisites, Deliverables, Plan, Quality Checklist, Validation Checklist, Test Checklist, Implementation Notes, Files Changed.
- Clarification gate (Full mode). Ask only decision-critical questions that repository evidence cannot answer. A valid plan has
Open Questions: None.; the plan approval is the sole routine pre-execution approval.
- One writer step at a time. Exactly one step may authorize active-worktree writes. Independent read-only investigation or validation may run concurrently. Never mark
COMPLETED with known failures—fix through an authorized step or mark BLOCKED.
Delegated Mode
When all of the following are true, skip triage/plan/pre-edit gate:
- Task assigned by another agent or orchestrator (not an open-ended user request)
- Explicit scope, success criteria, or acceptance contract received
- Operating in a focused role (implementer, reviewer, analyst, etc.)
In Delegated Mode: follow all Behavioral Guards and references/code-quality.md; report changed files, commands, validation evidence, and surprises; escalate unapproved design/architecture decisions; stay in scope.
Statuses
Plan-level (plan.md): DRAFT → ACTIVE → COMPLETED → ARCHIVED
Step-level (steps/step-N.md): PENDING → IN_PROGRESS → COMPLETED | BLOCKED
Only one writer step may be IN_PROGRESS at a time. The pre-edit gate checks step-level status. The plan remains ACTIVE after execution steps finish and becomes COMPLETED only after global reflection passes.
Reference Loading
Load only what the current phase needs:
- Planning:
references/create-plan.md, references/task-overview-template.md, references/step-template.md
- Execution:
references/execute-step.md, references/code-quality.md
- Verification:
references/verify-step.md
- Command discovery:
references/command-discovery.md
- Risk review:
references/risk-classification.md
- Project setup:
references/project-agents-template.md
Behavioral Guards
Active for the entire session. Do not drift.
- Evidence first — read target files before editing; search callers/usages before changing shared behavior; label claims as
Verified/Assumption/Unknown.
- Anti-shortcut gate — before editing: target read ✓, impact search (or
N/A — isolated) ✓, validation command (or skipped reason) ✓.
- Think in code — for aggregate analysis, prefer short scripts/commands that compute results over many raw file dumps. For noisy output, store in
/tmp, print bounded slice.
- Minimalism ladder — before adding code, prefer: delete/skip if not needed → stdlib/native feature → existing dependency/helper → smallest safe implementation; never cut security, data safety, accessibility, or explicit requirements.
- Surgical changes — touch only needed files/lines; match existing formatting, naming, and conventions; do not copy degraded patterns.
- Reuse before create — search for existing equivalents before writing new components/utilities/patterns; evidence of search in Verified Facts.
- Design discipline — do not make silent design choices. Surface decisions for user confirmation. Verify approach matches conventions or Design Decisions table.
- Goal-driven — define success before coding; verify via tests/lint/build/typecheck; add focused tests for new code and bug fixes; fix introduced issues or report blockers.
Full Workflow Phases
- Clarify — resolve only decision-critical ambiguity that repository evidence cannot answer. See
references/require-clarification.md.
- Plan — break into vertical-slice steps. See
references/create-plan.md.
- Execute — one step at a time:
references/execute-step.md → references/verify-step.md → references/persist-plan.md. Every 2–3 steps: references/checkpoint.md. Before pausing: dump context.
- Reflect — after all execution steps are done, keep the plan
ACTIVE; references/global-reflection.md owns final plan completion.
Resume Protocol
New session → read plans/context.md → relevant plan.md → current step file. See references/resume-workflow.md.
1---2name: swe-workflow3description: REQUIRED for every code-related task. Read SKILL.md before acting, then start the reply with workflow triage. Use `Workflow mode: Lightweight — <reason>; success: <outcome>; plan: no.` for clear localized changes and read-only review or discovery. Use the Full triage block and persisted plan for risky, coupled, cross-session, or contract-changing implementation. Escalate from Lightweight before target-file edits when discovery reveals Full-mode risk. Focused delegated agents follow Delegated Mode instead.4license: MIT5---67# SWE Workflow89> Every code task starts with workflow triage. Bounded work stays lightweight; risky or coordination-heavy implementation uses a persisted plan.1011## Contract12131. **Triage first.** Start the first reply to a code-related task with one of these declarations:14 ```text15 Workflow mode: Lightweight — <reason>; success: <outcome>; plan: no.16 ```17 ```text18 Workflow mode: Full19 Reason: <one sentence>20 Success criteria:21 - <what done means>22 Plan needed: yes23 ```242. **Lightweight is the default** for clear localized changes, bounded investigation, and read-only reviews or discovery—even when many files must be inspected. It uses the Behavioral Guards but no persisted plan.253. **Full is required before implementation** when work is risky or hard to reverse; changes API/schema/migration/security/configuration contracts; couples multiple subsystems; is a broad refactor/migration/cleanup; needs durable multi-session or multi-agent coordination; remains materially ambiguous after bounded discovery; or the user requests a plan. File count alone is a signal, not a trigger.264. **Escalate before target-file edits.** Lightweight discovery may gather evidence first. If Full criteria emerge, stop before mutating task files, declare Full mode, clarify decision-critical questions, create the plan, and then resume. If edits already began, preserve the verified state and escalate before expanding scope.275. **Pre-edit gate (Full mode).** Before mutating task target files: a plan directory must exist under `plans/<YYYY-MM-DD>-<slug>/`, exactly one step file must have `> Status: IN_PROGRESS`, and the edit must map to that step. Read-only exploration and workflow-bookkeeping updates are allowed before this gate.286. **Plan file format.** Copy [`references/task-overview-template.md`](references/task-overview-template.md) to `plan.md` and [`references/step-template.md`](references/step-template.md) to each step file. Every step has ten fields: `Status`, `Goal`, `Prerequisites`, `Deliverables`, `Plan`, `Quality Checklist`, `Validation Checklist`, `Test Checklist`, `Implementation Notes`, `Files Changed`.297. **Clarification gate (Full mode).** Ask only decision-critical questions that repository evidence cannot answer. A valid plan has `Open Questions: None.`; the plan approval is the sole routine pre-execution approval.308. **One writer step at a time.** Exactly one step may authorize active-worktree writes. Independent read-only investigation or validation may run concurrently. Never mark `COMPLETED` with known failures—fix through an authorized step or mark `BLOCKED`.3132## Delegated Mode3334When **all** of the following are true, skip triage/plan/pre-edit gate:35361. Task assigned by another agent or orchestrator (not an open-ended user request)372. Explicit scope, success criteria, or acceptance contract received383. Operating in a focused role (implementer, reviewer, analyst, etc.)3940In Delegated Mode: follow all Behavioral Guards and [`references/code-quality.md`](references/code-quality.md); report changed files, commands, validation evidence, and surprises; escalate unapproved design/architecture decisions; stay in scope.4142## Statuses4344**Plan-level** (`plan.md`): `DRAFT` → `ACTIVE` → `COMPLETED` → `ARCHIVED`45**Step-level** (`steps/step-N.md`): `PENDING` → `IN_PROGRESS` → `COMPLETED` | `BLOCKED`4647Only one writer step may be `IN_PROGRESS` at a time. The pre-edit gate checks step-level status. The plan remains `ACTIVE` after execution steps finish and becomes `COMPLETED` only after global reflection passes.4849## Reference Loading5051Load only what the current phase needs:5253- **Planning:** [`references/create-plan.md`](references/create-plan.md), [`references/task-overview-template.md`](references/task-overview-template.md), [`references/step-template.md`](references/step-template.md)54- **Execution:** [`references/execute-step.md`](references/execute-step.md), [`references/code-quality.md`](references/code-quality.md)55- **Verification:** [`references/verify-step.md`](references/verify-step.md)56- **Command discovery:** [`references/command-discovery.md`](references/command-discovery.md)57- **Risk review:** [`references/risk-classification.md`](references/risk-classification.md)58- **Project setup:** [`references/project-agents-template.md`](references/project-agents-template.md)5960## Behavioral Guards6162Active for the entire session. Do not drift.63641. **Evidence first** — read target files before editing; search callers/usages before changing shared behavior; label claims as `Verified`/`Assumption`/`Unknown`.652. **Anti-shortcut gate** — before editing: target read ✓, impact search (or `N/A — isolated`) ✓, validation command (or skipped reason) ✓.663. **Think in code** — for aggregate analysis, prefer short scripts/commands that compute results over many raw file dumps. For noisy output, store in `/tmp`, print bounded slice.674. **Minimalism ladder** — before adding code, prefer: delete/skip if not needed → stdlib/native feature → existing dependency/helper → smallest safe implementation; never cut security, data safety, accessibility, or explicit requirements.685. **Surgical changes** — touch only needed files/lines; match existing formatting, naming, and conventions; do not copy degraded patterns.696. **Reuse before create** — search for existing equivalents before writing new components/utilities/patterns; evidence of search in Verified Facts.707. **Design discipline** — do not make silent design choices. Surface decisions for user confirmation. Verify approach matches conventions or Design Decisions table.718. **Goal-driven** — define success before coding; verify via tests/lint/build/typecheck; add focused tests for new code and bug fixes; fix introduced issues or report blockers.7273## Full Workflow Phases74751. **Clarify** — resolve only decision-critical ambiguity that repository evidence cannot answer. See [`references/require-clarification.md`](references/require-clarification.md).762. **Plan** — break into vertical-slice steps. See [`references/create-plan.md`](references/create-plan.md).773. **Execute** — one step at a time: [`references/execute-step.md`](references/execute-step.md) → [`references/verify-step.md`](references/verify-step.md) → [`references/persist-plan.md`](references/persist-plan.md). Every 2–3 steps: [`references/checkpoint.md`](references/checkpoint.md). Before pausing: dump context.784. **Reflect** — after all execution steps are done, keep the plan `ACTIVE`; [`references/global-reflection.md`](references/global-reflection.md) owns final plan completion.7980### Resume Protocol8182New session → read `plans/context.md` → relevant `plan.md` → current step file. See [`references/resume-workflow.md`](references/resume-workflow.md).