Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
Tech Debt Cleaner (L3 Worker)
Automated cleanup of safe, low-risk tech debt findings from codebase audits.
Purpose & Scope
- Consume audit findings from
docs/project/codebase_audit.md (ln-620 output) or ln-511 code quality output
- Filter to auto-fixable findings with confidence >=90%
- Apply safe fixes: remove unused imports, delete dead code, clean commented-out blocks, remove deprecated aliases
- Never touch business logic, complex refactoring, or architectural changes
- Create single commit with structured summary of all changes
- Invocable from ln-510 quality coordinator pipeline or standalone
Auto-Fixable Categories
| Category |
Source Prefix |
Risk |
Auto-Fix Action |
| Unused imports |
MNT-DC- |
LOW |
Delete import line |
| Unused variables |
MNT-DC- |
LOW |
Delete declaration |
| Unused functions (unexported) |
MNT-DC- |
LOW |
Delete function block |
| Commented-out code (>5 lines) |
MNT-DC- |
LOW |
Delete comment block |
| Backward-compat shims (>6 months) |
MNT-DC- |
MEDIUM |
Delete shim + update re-exports |
| Deprecated aliases |
MNT-DC- |
LOW |
Delete alias line |
| Trailing whitespace / empty lines |
MNT- |
LOW |
Trim / collapse |
NOT Auto-Fixable (skip always)
| Category |
Reason |
| DRY violations (MNT-DRY-) |
Requires architectural decision on where to extract |
| God classes (MNT-GOD-) |
Requires domain knowledge for splitting |
| Security issues (SEC-) |
Requires context-specific fix |
| Architecture violations (ARCH-*) |
Requires design decision |
| Performance issues (PERF-*) |
Requires benchmarking |
| Any finding with effort M or L |
Too complex for auto-fix |
When to Use
- Invoked by ln-510-quality-coordinator Phase 3 (after ln-511 code quality check)
- Standalone: After
ln-620 codebase audit completes (user triggers manually)
- Scheduled: As periodic "garbage collection" for codebase hygiene
Inputs
- Pipeline mode (ln-510): findings from ln-511 code quality output (passed via coordinator context)
- Standalone mode:
docs/project/codebase_audit.md (ln-620 output)
Workflow
Load findings: Read docs/project/codebase_audit.md. Parse findings from Dead Code section (ln-626 results) and Code Quality section (ln-624 results).
Filter to auto-fixable:
- Category must be in Auto-Fixable table above
- Severity must be LOW or MEDIUM (no HIGH/CRITICAL)
- Effort must be S (small)
- Skip files in:
node_modules/, vendor/, dist/, build/, *.min.*, generated code, test fixtures
Verify each finding (confidence check):
MANDATORY READ: shared/references/clean_code_checklist.md
For each candidate fix:
a) Read the target file at specified location
b) Confirm the finding still exists (file may have changed since audit)
c) Confirm removal is safe:
- For unused imports: grep codebase for usage (must have 0 references)
- For unused functions: grep for function name (must have 0 call sites)
- For commented-out code: verify block is code, not documentation
- For deprecated aliases: verify no consumers remain
d) Assign confidence score (0-100). Only proceed if confidence >=90
Apply fixes with per-fix keep/discard (autoresearch pattern):
MANDATORY READ: Load shared/references/ci_tool_detection.md for discovery hierarchy. Detect lint + typecheck commands once (reuse for all fixes).
Group verified fixes by file. For each file (process files independently):
- Sort fixes within file by line number descending (bottom-up prevents line shift)
- Apply ALL fixes for this file using Edit tool
- Run lint/typecheck on the modified file
- IF passes →
git add {file} (status: keep)
- IF fails →
git checkout -- {file} (status: discard), log discarded fixes
- Track per fix: file, lines removed, category, finding ID, status (keep/discard)
If no lint/type commands detected: apply all fixes, skip per-file verification with warning, git add all modified files.
Create commit (kept fixes only):
Update audit report:
Output Format
verdict: CLEANED | NOTHING_TO_CLEAN | ALL_DISCARDED
stats:
total_findings: {from audit}
auto_fixable: {filtered count}
kept: {files that passed lint/typecheck}
discarded: {files that failed lint/typecheck}
skipped: {confidence <90 or stale}
fixes:
- file: "src/utils/helpers.ts"
line: 45
category: "unused_function"
removed: "formatDate()"
finding_id: "MNT-DC-003"
status: "keep"
- file: "src/api/v1/auth.ts"
line: 12
category: "deprecated_alias"
removed: "export { newAuth as oldAuth }"
finding_id: "MNT-DC-007"
status: "discard"
discard_reason: "typecheck failed: Type error in auth.ts:15"
commit_sha: "abc1234" | null
Critical Rules
- Safety first: Never fix if confidence <90%. When in doubt, skip.
- Bottom-up editing: Always apply fixes from bottom to top of file to avoid line number shifts.
- Per-file keep/discard: If linter/type-checker fails for a file, revert only that file (
git checkout -- {file}), keep other successful files.
- No business logic: Never modify function bodies, conditionals, or control flow.
- Explicit staging: Stage files by name, never
git add . or git add -A.
- Idempotent: Running twice produces no changes if audit report unchanged.
- Git-aware: Only operate on tracked files. Skip untracked or ignored files.
- Exclusions: Skip generated code, vendor directories, minified files, test fixtures.
Definition of Done
- Audit report loaded and parsed
- Findings filtered to auto-fixable categories
- Each finding verified with confidence >=90%
- Fixes applied bottom-up per file
- Build integrity verified (lint + type check) or skipped with warning
- Single commit created with structured message (or all reverted on build failure)
- Audit report updated with "Last Automated Cleanup" section
- Output YAML returned to caller
Reference Files
- Clean code checklist:
shared/references/clean_code_checklist.md
- Audit output schema:
shared/references/audit_output_schema.md
- Audit report template:
shared/templates/codebase_audit_template.md
Version: 1.0.0
Last Updated: 2026-02-15
1---2name: ln-512-tech-debt-cleaner3description: Applies safe auto-fixes for low-risk audit findings (unused imports, dead code, commented-out code). Confidence >=90% only. Creates single commit with summary.4license: MIT5---67> **Paths:** File paths (`shared/`, `references/`, `../ln-*`) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.89# Tech Debt Cleaner (L3 Worker)1011Automated cleanup of safe, low-risk tech debt findings from codebase audits.1213## Purpose & Scope1415- **Consume** audit findings from `docs/project/codebase_audit.md` (ln-620 output) or ln-511 code quality output16- **Filter** to auto-fixable findings with confidence >=90%17- **Apply** safe fixes: remove unused imports, delete dead code, clean commented-out blocks, remove deprecated aliases18- **Never touch** business logic, complex refactoring, or architectural changes19- **Create** single commit with structured summary of all changes20- Invocable from ln-510 quality coordinator pipeline or standalone2122## Auto-Fixable Categories2324| Category | Source Prefix | Risk | Auto-Fix Action |25|----------|--------------|------|-----------------|26| Unused imports | MNT-DC- | LOW | Delete import line |27| Unused variables | MNT-DC- | LOW | Delete declaration |28| Unused functions (unexported) | MNT-DC- | LOW | Delete function block |29| Commented-out code (>5 lines) | MNT-DC- | LOW | Delete comment block |30| Backward-compat shims (>6 months) | MNT-DC- | MEDIUM | Delete shim + update re-exports |31| Deprecated aliases | MNT-DC- | LOW | Delete alias line |32| Trailing whitespace / empty lines | MNT- | LOW | Trim / collapse |3334## NOT Auto-Fixable (skip always)3536| Category | Reason |37|----------|--------|38| DRY violations (MNT-DRY-) | Requires architectural decision on where to extract |39| God classes (MNT-GOD-) | Requires domain knowledge for splitting |40| Security issues (SEC-) | Requires context-specific fix |41| Architecture violations (ARCH-*) | Requires design decision |42| Performance issues (PERF-*) | Requires benchmarking |43| Any finding with effort M or L | Too complex for auto-fix |4445## When to Use4647- **Invoked by ln-510-quality-coordinator** Phase 3 (after ln-511 code quality check)48- **Standalone:** After `ln-620` codebase audit completes (user triggers manually)49- **Scheduled:** As periodic "garbage collection" for codebase hygiene5051## Inputs5253- **Pipeline mode (ln-510):** findings from ln-511 code quality output (passed via coordinator context)54- **Standalone mode:** `docs/project/codebase_audit.md` (ln-620 output)5556## Workflow57581) **Load findings:** Read `docs/project/codebase_audit.md`. Parse findings from Dead Code section (ln-626 results) and Code Quality section (ln-624 results).59602) **Filter to auto-fixable:**61 - Category must be in Auto-Fixable table above62 - Severity must be LOW or MEDIUM (no HIGH/CRITICAL)63 - Effort must be S (small)64 - Skip files in: `node_modules/`, `vendor/`, `dist/`, `build/`, `*.min.*`, generated code, test fixtures65663) **Verify each finding (confidence check):**67 **MANDATORY READ:** `shared/references/clean_code_checklist.md`68 For each candidate fix:69 a) Read the target file at specified location70 b) Confirm the finding still exists (file may have changed since audit)71 c) Confirm removal is safe:72 - For unused imports: grep codebase for usage (must have 0 references)73 - For unused functions: grep for function name (must have 0 call sites)74 - For commented-out code: verify block is code, not documentation75 - For deprecated aliases: verify no consumers remain76 d) Assign confidence score (0-100). Only proceed if confidence >=9077784) **Apply fixes with per-fix keep/discard (autoresearch pattern):**79 **MANDATORY READ:** Load `shared/references/ci_tool_detection.md` for discovery hierarchy. Detect lint + typecheck commands once (reuse for all fixes).8081 Group verified fixes by file. For each file (process files independently):82 - Sort fixes within file by line number descending (bottom-up prevents line shift)83 - Apply ALL fixes for this file using Edit tool84 - Run lint/typecheck on the modified file85 - **IF passes** → `git add {file}` (status: **keep**)86 - **IF fails** → `git checkout -- {file}` (status: **discard**), log discarded fixes87 - Track per fix: file, lines removed, category, finding ID, status (keep/discard)8889 If no lint/type commands detected: apply all fixes, skip per-file verification with warning, `git add` all modified files.90915) **Create commit (kept fixes only):**92 - All kept files already staged via `git add` in step 493 - If zero files kept (all discarded): skip commit, report all failures94 - Commit message format:95 ```96 chore: automated tech debt cleanup9798 Removed {N} auto-fixable findings from codebase audit:99 - {count} unused imports100 - {count} dead functions101 - {count} commented-out code blocks102 - {count} deprecated aliases103104 Source: docs/project/codebase_audit.md105 Confidence threshold: >=90%106 ```1071087) **Update audit report:**109 - Add "Last Cleanup" section to `docs/project/codebase_audit.md`:110 ```markdown111 ## Last Automated Cleanup112 **Date:** YYYY-MM-DD113 **Findings fixed:** N of M auto-fixable114 **Skipped:** K (confidence <90% or verification failed)115 **Build check:** PASSED / SKIPPED116 ```117118## Output Format119120```yaml121verdict: CLEANED | NOTHING_TO_CLEAN | ALL_DISCARDED122stats:123 total_findings: {from audit}124 auto_fixable: {filtered count}125 kept: {files that passed lint/typecheck}126 discarded: {files that failed lint/typecheck}127 skipped: {confidence <90 or stale}128fixes:129 - file: "src/utils/helpers.ts"130 line: 45131 category: "unused_function"132 removed: "formatDate()"133 finding_id: "MNT-DC-003"134 status: "keep"135 - file: "src/api/v1/auth.ts"136 line: 12137 category: "deprecated_alias"138 removed: "export { newAuth as oldAuth }"139 finding_id: "MNT-DC-007"140 status: "discard"141 discard_reason: "typecheck failed: Type error in auth.ts:15"142commit_sha: "abc1234" | null143```144145## Critical Rules146147- **Safety first:** Never fix if confidence <90%. When in doubt, skip.148- **Bottom-up editing:** Always apply fixes from bottom to top of file to avoid line number shifts.149- **Per-file keep/discard:** If linter/type-checker fails for a file, revert only that file (`git checkout -- {file}`), keep other successful files.150- **No business logic:** Never modify function bodies, conditionals, or control flow.151- **Explicit staging:** Stage files by name, never `git add .` or `git add -A`.152- **Idempotent:** Running twice produces no changes if audit report unchanged.153- **Git-aware:** Only operate on tracked files. Skip untracked or ignored files.154- **Exclusions:** Skip generated code, vendor directories, minified files, test fixtures.155156## Definition of Done157158- Audit report loaded and parsed159- Findings filtered to auto-fixable categories160- Each finding verified with confidence >=90%161- Fixes applied bottom-up per file162- Build integrity verified (lint + type check) or skipped with warning163- Single commit created with structured message (or all reverted on build failure)164- Audit report updated with "Last Automated Cleanup" section165- Output YAML returned to caller166167## Reference Files168169- **Clean code checklist:** `shared/references/clean_code_checklist.md`170- **Audit output schema:** `shared/references/audit_output_schema.md`171- **Audit report template:** `shared/templates/codebase_audit_template.md`172173---174**Version:** 1.0.0175**Last Updated:** 2026-02-15