Invoked by /removedebt command. Analyzes and removes technical debt with safety gates (snapshot, escape hatch, hard stop). Scopes via git history. Do not invoke directly โ use the /removedebt command.
From hypershipnpx claudepluginhub hgrafa/hypership --plugin hypershipThis skill uses the workspace's default tool permissions.
safety-gates.mdDesigns and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
Analyze and remove technical debt from delivered features. Your audience is senior engineers โ propose tradeoffs, not instructions. They decide what to cut; you execute with precision.
ls ~/.claude/plugins/cache/ | grep -i claude-mem
โ use MCP search tools to query past decisions about the codels ~/.claude/plugins/cache/ | grep -i memsearch
โ use memsearch query for relevant past contextls ~/.claude/projects/*/memory/
โ read MEMORY.md and topic files for relevant decisionsclaude mcp list 2>/dev/null | grep -i memory
โ search knowledge graph for past decisions
Use whichever is found first. If none, proceed without โ analysis
will be based purely on code diff.Report: "Env: Superpowers โ
| GitHub [โ
|โ] | Memory: [claude-mem|memsearch|auto|mcp|none]"
If any memory system returns relevant context, prepend to
each finding: "๐ Memory: [past decision context]"
Parse the user's context argument into a concrete git scope.
| User says | Git interpretation |
|---|---|
the last N features about X | git log --grep="^feat:.*X" -N โ extract SHAs |
after 2.0 release until now | git log v2.0..HEAD |
after tag/release X | git log X..HEAD |
since last consolidation | Read docs/debt-log.md โ last entry date โ git log --after="date" |
everything on module X | git log -- path/to/module/ |
since last /removedebt | Same as "since last consolidation" |
| (empty) | Default to since last entry in docs/debt-log.md, or all of current branch |
"By 'payment methods' do you mean
src/payments/or alsosrc/checkout/payment-*? I see changes in both."
"Scope: 7 commits, 23 files changed, across
src/payments/andsrc/api/routes/payment*.ts. Proceed with analysis?"
Run the debt-scanner agent as a subagent to analyze the scoped diff.
Use the Task tool to dispatch the debt-scanner agent with:
The debt-scanner returns a structured findings report.
Every finding MUST be classified into exactly one category:
| Category | Icon | Definition | Action |
|---|---|---|---|
| Duplication | ๐ | >10 lines of identical or near-identical code across 2+ files | Extract to shared module |
| Dead Code | ๐ | Unreachable code, unused exports, orphaned after refactors | Remove |
| Naming Drift | ๐ท๏ธ | Same concept, different names across features | Unify naming |
| Type Sprawl | ๐ฆ | >2 features define structurally identical types separately | Consolidate types |
| Missing Tests | ๐งช | Delivered code below project's coverage baseline | Add tests |
| Stale Imports | ๐งน | Unused imports left from refactors | Remove |
The following MUST NOT appear in findings. If the scanner returns them, filter them out before presenting to the user:
Present findings grouped by category. For each group, ask a strategic question that helps the senior engineer decide.
## Debt Analysis: [scope description]
### ๐ Duplication (3 findings)
1. `createPaymentIntent()` in `src/payments/stripe.ts:45-67` and
`src/payments/paypal.ts:32-54` โ 22 lines, identical validation
logic with different provider calls.
2. Error handling block in `src/api/routes/payment-create.ts:89-112`
and `src/api/routes/payment-update.ts:45-68` โ same try/catch
structure, same error mapping.
3. `formatCurrency()` implemented in 3 files with identical logic.
**Decision point:** Extract shared validation into
`src/payments/shared/validation.ts`? The provider-specific parts
stay in each file. Estimated: ~30 min, touches 4 files.
Options:
[A] Extract all 3 โ single refactor PR
[B] Extract #1 and #3 only (highest duplication), leave #2 (lower risk)
[C] Skip โ duplication is acceptable for now
[D] I'll handle this manually, just note it
> Your call:
After presenting all findings, suggest a priority:
**My recommendation (you decide):**
Priority 1: ๐ Dead code (3 items) โ zero-risk removal, cleaner codebase
Priority 2: ๐ Duplication #1 and #3 โ high duplication, low effort
Priority 3: ๐งช Missing tests โ prevents regression in next delivery
Skip for now: ๐ท๏ธ Naming drift โ 2 instances, not causing confusion yet
Total estimated effort: ~2h for Priority 1-2, ~1h for Priority 3.
Want to proceed with all, or pick specific priorities?
After the engineer approves findings and before executing any refactor, activate the safety gates protocol.
Load ./safety-gates.md and follow the 3-gate protocol:
escape_list โ immutable once execution beginsThe safety-gates.md fragment contains the full protocol with exact wording for each gate, decision tree, and debt-log test fields template.
For each approved debt item, execute via Superpowers pipeline:
Invoke superpowers:brainstorming with the specific refactor scope.
Invoke superpowers:writing-plans for the approved items.
Invoke superpowers:subagent-driven-development:
Invoke superpowers:finishing-a-development-branch:
refactor/removedebt-YYYY-MM-DD-scoperefactor(debt): [category] [scope]
Example: refactor(debt): extract shared payment validationAfter execution (or if user skips everything), update docs/debt-log.md:
## [YYYY-MM-DD] Debt Removal: [scope description]
### Scope
- Context: "[original user argument]"
- Git range: `[base_sha]..[head_sha]`
- Files analyzed: [N]
- Features in scope: [list]
### Findings
| # | Category | Location | Decision | Status |
|---|----------|----------|----------|--------|
| 1 | ๐ Duplication | payments/stripe,paypal | Extract โ shared | โ
Done |
| 2 | ๐ Duplication | routes/payment-*.ts | Skip (acceptable) | โญ๏ธ Skipped |
| 3 | ๐ Dead Code | utils/legacy-format.ts | Remove | โ
Done |
| 4 | ๐งช Missing Tests | payments/refund.ts | Add coverage | โ
Done |
### Tests
- Baseline: [N] pass, [N] fail (pre-existing), [N]% coverage
- After: [N] pass, [N] fail (pre-existing), [N]% coverage
- Declared breaks: [N] ([description])
- Unexpected breaks: [N]
- Hard stops triggered: [N]
- Coverage delta: [+/-N]% ([reason])
### Branch
- `refactor/removedebt-YYYY-MM-DD-payments`
- PR: #[number] (if created)
/removedebt [context]
โ
โผ
Resolve scope (git range, files)
โ
โผ
Dispatch debt-scanner agent
โ
โผ
Filter out non-debt (YAGNI, premature optimization, etc)
โ
โผ
Present findings with strategic questions (max 5 decision points)
โ
โผ
User decides: proceed / skip / manual per group
โ
โผ
Safety gates: snapshot baseline, declare escape hatch
โ
โผ
Execute approved items via Superpowers pipeline
(brainstorm โ plan โ SDD with TDD + two-stage review)
[Gate 3 delta check after each category]
โ
โผ
Log to docs/debt-log.md
โ
โผ
Summary: what was done, what was skipped, test status