Stale comment and doc cleanup 🦆🧹. Audit-first, evidence-backed staleness detection.
Purpose
Identify stale/outdated comments and non-CONTEXT docs so they stop polluting
future sessions and confusing agents and developers. Audit-first; edits hand
off to duck-patch.
Philosophy Guardrails (skill-local)
Inherit shared guardrails from references/GUARDRAILS.md.
- ask 1-3 targeted clarifying questions when context is incomplete
- state assumptions explicitly when evidence is missing
Skill-specific delta:
- Staleness evidence-backed: comment contradicts current code, describes
behavior no longer existing, or documents worktree-only add/remove never
merged to main.
- TODO/FIXME/HACK/XXX markers out of scope (duck-debt owns the ledger).
- ADR/design notes historic by design: if info is superseded, flag it; do not edit.
Activation
Audit-only (default): scan, report, no edits. Signals: "duck-tidy",
"stale comments audit", "outdated docs audit".
Audit-and-edit: audit, then hand agreed findings to duck-patch. Signals:
"tidy and fix comments", "clean up stale comments".
Method
1. Scan scope
Scope: explicit paths/globs from user, else worktree files (tracked +
untracked, git-ignored excluded) minus CONTEXT.md, .duck-tape/, and common
generated dirs (build/, dist/, node_modules/, coverage/, target/).
If the repo's generated dirs differ, ask one question before scanning.
If scope unclear, ask one question: single file / directory / worktree diff
vs default branch.
Collect code comments, doc comments, non-CONTEXT markdown in scope.
2. Gather staleness evidence
Stale iff any rule holds:
- Contradiction: text contradicts current code (outdated invariants, wrong
parameter semantics, old return type or signature).
- Removed behavior: describes functionality no longer present (referenced
symbol/function/feature deleted).
- Worktree-only add/remove: documents behavior added then removed in the
current worktree, never merged to the default branch. Verify via
git diff <default-branch>: behavior exists only in unmerged worktree
changes. Resolve default branch with git symbolic-ref refs/remotes/origin/HEAD,
fall back to main. For untracked files, confirm worktree-only status via
git status --porcelain.
Cross-reference each suspect: symbol resolves? tests exercise it? Cite the
contradiction (file:line, symbol, diff hunk). No vibes-based staleness.
3. Classify findings
stale-comment: actionable (contradiction / removed behavior /
worktree-only). Editable.
superseded-doc: ADR/design note now outdated. If outdated, flag only; do not edit.
skip: TODO markers (duck-debt), accurate or historic comments,
CONTEXT.md/.duck-tape content (duck-tape).
4. Produce audit report
Ledger per finding: location (file:line), class, evidence (one cited line),
proposed action (delete / reword / flag).
ADR findings grouped separately as flags: "outdated — do not cite as current",
with supersession evidence.
Audit-only mode stops here. Report only; no edits.
5. Patch handoff
Audit-and-edit only:
- Present audit ledger.
- User selects findings to fix.
- Hand selected edits to duck-patch as bounded scope.
- Walk execution approval before edits.
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.
Verify with smallest runnable check (build/test, or re-audit of changed hunks).
Boundaries
- No auto-edits without approval.
- If a target is a TODO/FIXME/HACK/XXX marker, leave it — duck-debt owns those.
- If a target is an ADR/design note, flag only; do not edit.
- If a target is CONTEXT.md or .duck-tape state, leave it — duck-tape owns those.
- Every deletion carries cited evidence.
1---2name: duck-tidy3description: Stale/outdated comment and doc cleanup audit. Flags comments contradicting current code, removed behavior, or worktree-only add/remove never merged. Audit-first, patch handoff. Use when: "tidy comments", "clean up stale comments", "outdated docs audit", "duck-tidy".4license: MIT5---67Stale comment and doc cleanup 🦆🧹. Audit-first, evidence-backed staleness detection.89## Purpose1011Identify stale/outdated comments and non-CONTEXT docs so they stop polluting12future sessions and confusing agents and developers. Audit-first; edits hand13off to duck-patch.1415## Philosophy Guardrails (skill-local)1617Inherit shared guardrails from `references/GUARDRAILS.md`.18- ask 1-3 targeted clarifying questions when context is incomplete19- state assumptions explicitly when evidence is missing2021Skill-specific delta:2223- Staleness evidence-backed: comment contradicts current code, describes24 behavior no longer existing, or documents worktree-only add/remove never25 merged to main.26- TODO/FIXME/HACK/XXX markers out of scope (duck-debt owns the ledger).27- ADR/design notes historic by design: if info is superseded, flag it; do not edit.2829## Activation3031**Audit-only** (default): scan, report, no edits. Signals: "duck-tidy",32"stale comments audit", "outdated docs audit".3334**Audit-and-edit**: audit, then hand agreed findings to duck-patch. Signals:35"tidy and fix comments", "clean up stale comments".3637## Method3839### 1. Scan scope4041Scope: explicit paths/globs from user, else worktree files (tracked +42untracked, git-ignored excluded) minus CONTEXT.md, .duck-tape/, and common43generated dirs (build/, dist/, node_modules/, coverage/, target/).4445If the repo's generated dirs differ, ask one question before scanning.4647If scope unclear, ask one question: single file / directory / worktree diff48vs default branch.4950Collect code comments, doc comments, non-CONTEXT markdown in scope.5152### 2. Gather staleness evidence5354Stale iff any rule holds:5556- **Contradiction**: text contradicts current code (outdated invariants, wrong57 parameter semantics, old return type or signature).58- **Removed behavior**: describes functionality no longer present (referenced59 symbol/function/feature deleted).60- **Worktree-only add/remove**: documents behavior added then removed in the61 current worktree, never merged to the default branch. Verify via62 `git diff <default-branch>`: behavior exists only in unmerged worktree63 changes. Resolve default branch with `git symbolic-ref refs/remotes/origin/HEAD`,64 fall back to `main`. For untracked files, confirm worktree-only status via65 `git status --porcelain`.6667Cross-reference each suspect: symbol resolves? tests exercise it? Cite the68contradiction (file:line, symbol, diff hunk). No vibes-based staleness.6970### 3. Classify findings7172- `stale-comment`: actionable (contradiction / removed behavior /73 worktree-only). Editable.74- `superseded-doc`: ADR/design note now outdated. If outdated, flag only; do not edit.75- `skip`: TODO markers (duck-debt), accurate or historic comments,76 CONTEXT.md/.duck-tape content (duck-tape).7778### 4. Produce audit report7980Ledger per finding: location (file:line), class, evidence (one cited line),81proposed action (delete / reword / flag).8283ADR findings grouped separately as flags: "outdated — do not cite as current",84with supersession evidence.8586Audit-only mode stops here. Report only; no edits.8788### 5. Patch handoff8990Audit-and-edit only:91921. Present audit ledger.932. User selects findings to fix.943. Hand selected edits to duck-patch as bounded scope.954. Walk execution approval before edits.9697**Workspace-changing actions** (require approval based on change type):9899**Semantic changes** (require full execution approval):100101- Code/logic changes102- Documentation/planning changes (README, markdown docs, ADRs, CONTEXT.md, runbooks, design notes), except typo-only fixes in non-code text files103- Config/schema changes (settings, env vars, build config)104- Dependency changes (package.json, requirements.txt, etc.)105- File operations (create, delete, move)106- Mutating commands (git commit, install, build, deploy)107- Task delegation for implementation/patching108109**Cosmetic changes** (require lightweight confirmation):110111- Formatting/whitespace-only changes112- Typo fixes in non-code text files113- Confirmation phrase: "Confirm to proceed with [formatting change/typo fix]?"114115**Edge cases:**116117- JSDoc/docstring changes in code files are semantic (affects generated docs, code contracts)118- Comments explaining logic in code are semantic (affects maintainability understanding)119- Config comments are semantic (affects interpretation)120- Document updates (ADRs, CONTEXT.md) are semantic121- Examples in README that are code snippets are semantic (users copy-paste)122123**Approval workflow:**124Before any semantic change, require execution approval:125126 1. **Preflight** (required for every approval ask; if a field is missing, ask one clarifying question):127 - target phase:128 - Phase 1: stubs/skeleton/interfaces129 - Phase 2: wiring/integration130 - Phase 3: concrete implementation131 - phase-fit statement (why this diff matches phase constraints)132 - target files (bounded for selected phase)133 - expected behavior change134 - smallest verification check135 2. **Present list of changes broken down by file as formatted diff**136 - File exists: unified diff (`---`/`+++`/`@@` hunks, `-`/`+` prefixes)137 - File does not exist: full content in fenced code block, file path as header138 - One file per diff block139 - Inline an annotation above the diff hunks explaining each change140 - If any file violates phase constraints, split and re-propose before approval ask141 3. **Approval ask**: `Approve this scope? (examples: approve/ok/confirm)`142 4. **Wait for approval**: do not proceed with edits/commands/task delegation until user replies with explicit approval intent143144**Rules:**145146- No workspace-changing action without user approval/confirmation147**Approval intent tokens:**148149- Accept as approval intent: "approve", "approved", "ok", "go ahead", "confirm", "yes"150- Also accept option-referencing approval sentences: "Proceed with option B in files X and Y.", "Approved. Run verification plan as proposed."151- Examples are non-exhaustive. Any clear approval intent is accepted.152- Do not treat non-approval continuation signals as approval: bare "continue", bare option letters ("B"), "next". No approval verb, no scope reference — not approval.153154**Scope rules:**155156- Phase caps (default):157 - Phase 1 (stubs/skeleton/interfaces): up to 6 files158 - Phase 2 (wiring/integration): up to 4 files159 - Phase 3 (concrete implementation): up to 2 files160161- **Phase content constraints (hard gate):**162 - **Phase 1 (stubs/skeleton/interfaces) must contain only:**163 - file/module skeleton shape (folders, exports, section layout)164 - type/interface declarations165 - function/class signatures166 - placeholder returns/errors/TODO markers167 - minimal no-op wiring with no business logic168 - **Phase 1 must not contain:**169 - full feature/business logic170 - side-effectful flows (DB/network/auth/file writes)171 - complete UI behavior beyond placeholders172 - **Phase 2 (wiring/integration) can contain:**173 - route registration, DI/container wiring, module composition, event hookups174 - adaptation glue between existing components175 - **Phase 2 must not contain:**176 - substantial new business logic blocks177 - **Phase 3 (concrete implementation) contains:**178 - business logic, algorithms, side effects, full behavior completion179180- **New-file bootstrap rule:**181 - If scope introduces new feature files, first approval pass must be Phase 1 stubs/skeleton/interfaces only.182 - Implement bodies in later Phase 2/3 approvals.183 - If a new file exceeds stub/skeleton intent, split that file into stub-first then implementation follow-up.184- If a phase exceeds its cap, split into smaller bounded approvals before executing.185- Review-fatigue triggers (objective):186 - Phase 1 (stubs/skeleton/interfaces):187 - 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).188 - If any single file exceeds 90 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.189 - Phase 2 (wiring/integration):190 - 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).191 - If any single file exceeds 60 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.192 - Phase 3 (concrete implementation):193 - 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).194 - If any single file exceeds 40 changed lines (additions + deletions), split that file into a separate approval or smaller sequential edits.195 - If reviewer requests clarification on more than 2 files in same batch, reduce next batch by at least 1 file.196- If complexity or review fatigue increases, reduce cap further and continue in smaller batches.197- Reopen execution approval between phases, even when objective stays same.198- If scope changes after approval, reopen scope confirmation before continuing.199200- Phase examples (application):201 - 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.202 - Phase 2 example: 4 files, 130 changed lines (additions + deletions) total. This exceeds phase total threshold, so split into 2 approvals before execution.203 - Phase 3 example: 2 files, one file at 45 changed lines (additions + deletions). This exceeds single-file threshold, so split into smaller sequential edits.204205Verify with smallest runnable check (build/test, or re-audit of changed hunks).206207## Boundaries208209- No auto-edits without approval.210- If a target is a TODO/FIXME/HACK/XXX marker, leave it — duck-debt owns those.211- If a target is an ADR/design note, flag only; do not edit.212- If a target is CONTEXT.md or .duck-tape state, leave it — duck-tape owns those.213- Every deletion carries cited evidence.