Patch execution 🦆. Smallest safe diff first.
Purpose
Execute a narrowly scoped code change once the fix direction is known.
Philosophy Guardrails (skill-local)
Inherit shared guardrails from references/GUARDRAILS.md.
Skill-specific delta:
- Executes bounded implementation only; product and architecture decisions remain with user.
Activation
Use when user asks for a targeted code edit and scope is clear (or can be clarified quickly).
Method
Subagent execution mode
When running as a subagent without a user channel (e.g., via duckling): do not apply edits or run commands. Execute scope clarification, Duck Ladder, and patch derivation as analysis; replace "apply minimal safe diff" and "run smallest agreed check" with approval-package content: the derived per-file diff blocks and verification plan. Emit per the host wrapper's contract (preflight + diffs + approval ask + status footer).
1. Clarify scope (if incomplete)
- ask 1-3 targeted clarifying questions when context is incomplete
- state assumptions explicitly when evidence is missing
Mutating action gate:
Workspace-changing actions (require approval based on change type):
Semantic changes (require full execution approval):
- Code/logic changes
- Documentation/planning changes (README, markdown docs, ADRs, CONTEXT.md, runbooks, design notes), except typo-only fixes in non-code text files
- Config/schema changes (settings, env vars, build config)
- Dependency changes (package.json, requirements.txt, etc.)
- File operations (create, delete, move)
- Mutating commands (git commit, install, build, deploy)
- Task delegation for implementation/patching
Cosmetic changes (require lightweight confirmation):
- Formatting/whitespace-only changes
- Typo fixes in non-code text files
- Confirmation phrase: "Confirm to proceed with [formatting change/typo fix]?"
Edge cases:
- JSDoc/docstring changes in code files are semantic (affects generated docs, code contracts)
- Comments explaining logic in code are semantic (affects maintainability understanding)
- Config comments are semantic (affects interpretation)
- Document updates (ADRs, CONTEXT.md) are semantic
- Examples in README that are code snippets are semantic (users copy-paste)
Approval workflow:
Before any semantic change, require execution approval:
- Preflight (required for every approval ask; if a field is missing, ask one clarifying question):
- target phase:
- Phase 1: stubs/skeleton/interfaces
- Phase 2: wiring/integration
- Phase 3: concrete implementation
- phase-fit statement (why this diff matches phase constraints)
- target files (bounded for selected phase)
- expected behavior change
- smallest verification check
- Present list of changes broken down by file as formatted diff
- File exists: unified diff (
---/+++/@@ hunks, -/+ prefixes)
- File does not exist: full content in fenced code block, file path as header
- One file per diff block
- Inline an annotation above the diff hunks explaining each change
- If any file violates phase constraints, split and re-propose before approval ask
- Approval ask:
Approve this scope? (examples: approve/ok/confirm)
- Wait for approval: do not proceed with edits/commands/task delegation until user replies with explicit approval intent
Rules:
No workspace-changing action without user approval/confirmation
Approval intent tokens:
Accept as approval intent: "approve", "approved", "ok", "go ahead", "confirm", "yes"
Also accept option-referencing approval sentences: "Proceed with option B in files X and Y.", "Approved. Run verification plan as proposed."
Examples are non-exhaustive. Any clear approval intent is accepted.
Do not treat non-approval continuation signals as approval: bare "continue", bare option letters ("B"), "next". No approval verb, no scope reference — not approval.
Scope rules:
Phase caps (default):
- Phase 1 (stubs/skeleton/interfaces): up to 6 files
- Phase 2 (wiring/integration): up to 4 files
- Phase 3 (concrete implementation): up to 2 files
Phase content constraints (hard gate):
- Phase 1 (stubs/skeleton/interfaces) must contain only:
- file/module skeleton shape (folders, exports, section layout)
- type/interface declarations
- function/class signatures
- placeholder returns/errors/TODO markers
- minimal no-op wiring with no business logic
- Phase 1 must not contain:
- full feature/business logic
- side-effectful flows (DB/network/auth/file writes)
- complete UI behavior beyond placeholders
- Phase 2 (wiring/integration) can contain:
- route registration, DI/container wiring, module composition, event hookups
- adaptation glue between existing components
- Phase 2 must not contain:
- substantial new business logic blocks
- Phase 3 (concrete implementation) contains:
- business logic, algorithms, side effects, full behavior completion
New-file bootstrap rule:
- If scope introduces new feature files, first approval pass must be Phase 1 stubs/skeleton/interfaces only.
- Implement bodies in later Phase 2/3 approvals.
- If a new file exceeds stub/skeleton intent, split that file into stub-first then implementation follow-up.
If a phase exceeds its cap, split into smaller bounded approvals before executing.
Review-fatigue triggers (objective):
- Phase 1 (stubs/skeleton/interfaces):
- If proposed diff in one approval exceeds 180 changed lines (additions + deletions) total, reduce current phase cap by at least 1 file (minimum cap is 1 file).
- If any single file exceeds 90 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.
- Phase 2 (wiring/integration):
- If proposed diff in one approval exceeds 120 changed lines (additions + deletions) total, reduce current phase cap by at least 1 file (minimum cap is 1 file).
- If any single file exceeds 60 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.
- Phase 3 (concrete implementation):
- If proposed diff in one approval exceeds 80 changed lines (additions + deletions) total, reduce current phase cap by at least 1 file (minimum cap is 1 file).
- If any single file exceeds 40 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.
- If reviewer requests clarification on more than 2 files in same batch, reduce next batch by at least 1 file.
If complexity or review fatigue increases, reduce cap further and continue in smaller batches.
Reopen execution approval between phases, even when objective stays same.
If scope changes after approval, reopen scope confirmation before continuing.
Phase examples (application):
- Phase 1 example: 5 files, 170 changed lines (additions + deletions) total, max single file 80 changed lines (additions + deletions). This is within cap and thresholds, so one approval can proceed.
- Phase 2 example: 4 files, 130 changed lines (additions + deletions) total. This exceeds phase total threshold, so split into 2 approvals before execution.
- Phase 3 example: 2 files, one file at 45 changed lines (additions + deletions). This exceeds single-file threshold, so split into smaller sequential edits.
2. Apply Duck Ladder
Before introducing new constructs, stop at first rung that holds:
- No change needed (YAGNI)
- Reuse existing local helper/pattern
- Replace with stdlib/native
- Use already-installed dependency
- Shrink to smallest safe diff
- Only then add new code/abstraction
3. Execute patch
- Restate bounded scope and expected behavior.
- Touch the smallest shared fix location (avoid caller-by-caller patching).
- Reuse existing local helpers/patterns before adding new abstraction.
- Apply minimal safe diff.
- Run smallest agreed check.
- Report exactly: changed files, behavior delta, verification result.
Output:
- one-line execution plan (file(s) + expected behavior)
- minimal patch summary (what changed, not a full essay)
- one smallest verification check and result
- if blocked: one-line blocker + next required input
Boundaries
- Do not weaken security, trust boundaries, data-loss prevention, accessibility, or explicit user requirements.
- If root cause is unclear, hand back to
duck-debug (trace mode if needed) instead of speculative edits.
- If verification cannot run locally, provide exact command user should run and expected signal.
1---2name: duck-patch3description: Surgical implementation for small, bounded code edits after direction is clear. Use when: "apply this fix", "make a targeted edit", "patch this", "implement the agreed change".4license: MIT5---67Patch execution 🦆. Smallest safe diff first.89## Purpose1011Execute a narrowly scoped code change once the fix direction is known.1213## Philosophy Guardrails (skill-local)1415Inherit shared guardrails from `references/GUARDRAILS.md`.1617Skill-specific delta:1819- Executes bounded implementation only; product and architecture decisions remain with user.2021## Activation2223Use when user asks for a targeted code edit and scope is clear (or can be clarified quickly).2425## Method2627### Subagent execution mode2829When running as a subagent without a user channel (e.g., via duckling): do not apply edits or run commands. Execute scope clarification, Duck Ladder, and patch derivation as analysis; replace "apply minimal safe diff" and "run smallest agreed check" with approval-package content: the derived per-file diff blocks and verification plan. Emit per the host wrapper's contract (preflight + diffs + approval ask + status footer).3031### 1. Clarify scope (if incomplete)3233- ask 1-3 targeted clarifying questions when context is incomplete34- state assumptions explicitly when evidence is missing3536**Mutating action gate:**37**Workspace-changing actions** (require approval based on change type):3839**Semantic changes** (require full execution approval):4041- Code/logic changes42- Documentation/planning changes (README, markdown docs, ADRs, CONTEXT.md, runbooks, design notes), except typo-only fixes in non-code text files43- Config/schema changes (settings, env vars, build config)44- Dependency changes (package.json, requirements.txt, etc.)45- File operations (create, delete, move)46- Mutating commands (git commit, install, build, deploy)47- Task delegation for implementation/patching4849**Cosmetic changes** (require lightweight confirmation):5051- Formatting/whitespace-only changes52- Typo fixes in non-code text files53- Confirmation phrase: "Confirm to proceed with [formatting change/typo fix]?"5455**Edge cases:**5657- JSDoc/docstring changes in code files are semantic (affects generated docs, code contracts)58- Comments explaining logic in code are semantic (affects maintainability understanding)59- Config comments are semantic (affects interpretation)60- Document updates (ADRs, CONTEXT.md) are semantic61- Examples in README that are code snippets are semantic (users copy-paste)6263**Approval workflow:**64Before any semantic change, require execution approval:6566 1. **Preflight** (required for every approval ask; if a field is missing, ask one clarifying question):67 - target phase:68 - Phase 1: stubs/skeleton/interfaces69 - Phase 2: wiring/integration70 - Phase 3: concrete implementation71 - phase-fit statement (why this diff matches phase constraints)72 - target files (bounded for selected phase)73 - expected behavior change74 - smallest verification check75 2. **Present list of changes broken down by file as formatted diff**76 - File exists: unified diff (`---`/`+++`/`@@` hunks, `-`/`+` prefixes)77 - File does not exist: full content in fenced code block, file path as header78 - One file per diff block79 - Inline an annotation above the diff hunks explaining each change80 - If any file violates phase constraints, split and re-propose before approval ask81 3. **Approval ask**: `Approve this scope? (examples: approve/ok/confirm)`82 4. **Wait for approval**: do not proceed with edits/commands/task delegation until user replies with explicit approval intent8384**Rules:**8586- No workspace-changing action without user approval/confirmation87**Approval intent tokens:**8889- Accept as approval intent: "approve", "approved", "ok", "go ahead", "confirm", "yes"90- Also accept option-referencing approval sentences: "Proceed with option B in files X and Y.", "Approved. Run verification plan as proposed."91- Examples are non-exhaustive. Any clear approval intent is accepted.92- Do not treat non-approval continuation signals as approval: bare "continue", bare option letters ("B"), "next". No approval verb, no scope reference — not approval.9394**Scope rules:**9596- Phase caps (default):97 - Phase 1 (stubs/skeleton/interfaces): up to 6 files98 - Phase 2 (wiring/integration): up to 4 files99 - Phase 3 (concrete implementation): up to 2 files100101- **Phase content constraints (hard gate):**102 - **Phase 1 (stubs/skeleton/interfaces) must contain only:**103 - file/module skeleton shape (folders, exports, section layout)104 - type/interface declarations105 - function/class signatures106 - placeholder returns/errors/TODO markers107 - minimal no-op wiring with no business logic108 - **Phase 1 must not contain:**109 - full feature/business logic110 - side-effectful flows (DB/network/auth/file writes)111 - complete UI behavior beyond placeholders112 - **Phase 2 (wiring/integration) can contain:**113 - route registration, DI/container wiring, module composition, event hookups114 - adaptation glue between existing components115 - **Phase 2 must not contain:**116 - substantial new business logic blocks117 - **Phase 3 (concrete implementation) contains:**118 - business logic, algorithms, side effects, full behavior completion119120- **New-file bootstrap rule:**121 - If scope introduces new feature files, first approval pass must be Phase 1 stubs/skeleton/interfaces only.122 - Implement bodies in later Phase 2/3 approvals.123 - If a new file exceeds stub/skeleton intent, split that file into stub-first then implementation follow-up.124- If a phase exceeds its cap, split into smaller bounded approvals before executing.125- Review-fatigue triggers (objective):126 - Phase 1 (stubs/skeleton/interfaces):127 - If proposed diff in one approval exceeds 180 changed lines (additions + deletions) total, reduce current phase cap by at least 1 file (minimum cap is 1 file).128 - If any single file exceeds 90 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.129 - Phase 2 (wiring/integration):130 - If proposed diff in one approval exceeds 120 changed lines (additions + deletions) total, reduce current phase cap by at least 1 file (minimum cap is 1 file).131 - If any single file exceeds 60 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.132 - Phase 3 (concrete implementation):133 - If proposed diff in one approval exceeds 80 changed lines (additions + deletions) total, reduce current phase cap by at least 1 file (minimum cap is 1 file).134 - If any single file exceeds 40 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.135 - If reviewer requests clarification on more than 2 files in same batch, reduce next batch by at least 1 file.136- If complexity or review fatigue increases, reduce cap further and continue in smaller batches.137- Reopen execution approval between phases, even when objective stays same.138- If scope changes after approval, reopen scope confirmation before continuing.139140- Phase examples (application):141 - Phase 1 example: 5 files, 170 changed lines (additions + deletions) total, max single file 80 changed lines (additions + deletions). This is within cap and thresholds, so one approval can proceed.142 - Phase 2 example: 4 files, 130 changed lines (additions + deletions) total. This exceeds phase total threshold, so split into 2 approvals before execution.143 - Phase 3 example: 2 files, one file at 45 changed lines (additions + deletions). This exceeds single-file threshold, so split into smaller sequential edits.144145### 2. Apply Duck Ladder146147Before introducing new constructs, stop at first rung that holds:1481. No change needed (YAGNI)1492. Reuse existing local helper/pattern1503. Replace with stdlib/native1514. Use already-installed dependency1525. Shrink to smallest safe diff1536. Only then add new code/abstraction154155### 3. Execute patch1561571. Restate bounded scope and expected behavior.1582. Touch the smallest shared fix location (avoid caller-by-caller patching).1593. Reuse existing local helpers/patterns before adding new abstraction.1604. Apply minimal safe diff.1615. Run smallest agreed check.1626. Report exactly: changed files, behavior delta, verification result.163164Output:165166- one-line execution plan (file(s) + expected behavior)167- minimal patch summary (what changed, not a full essay)168- one smallest verification check and result169- if blocked: one-line blocker + next required input170171## Boundaries172173- Do not weaken security, trust boundaries, data-loss prevention, accessibility, or explicit user requirements.174- If root cause is unclear, hand back to `duck-debug` (trace mode if needed) instead of speculative edits.175- If verification cannot run locally, provide exact command user should run and expected signal.