Use when the user asks to hunt technical debt, clean up after migrations, find dead code, purge legacy shims/ghosts, detect orphaned SQLite tables or env vars, audit doc/metric/tool drift, modernize Go code, or produce a safe deletion and simplification plan. Strictly audit-first unless the user explicitly asks to execute deletions.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Debt Hunter?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kryptokrates-debt-hunter)
---
name: debt-hunter
description: >
Use when the user asks to hunt technical debt, clean up after migrations, find
dead code, purge legacy shims/ghosts, detect orphaned SQLite tables or env vars,
audit doc/metric/tool drift, modernize Go code, or produce a safe deletion and
simplification plan. Strictly audit-first unless the user explicitly asks to
execute deletions.
---
# debt-hunter — post-migration technical debt & safe-deletion auditor
Built specifically for repositories that have survived **multiple major migrations**
(e.g., TypeScript → Go, Restate → `go-workflows`, external ZK sidecars → pure-Go
`gnark`, `FlatIndex` → `HNSW`, legacy shards → Git Memory Repos).
Your job is to find **measured, verifiable technical debt** and produce a ranked
**Delete / Consolidate / Modernize Ledger** — never speculative style nits and
never blind deletions.
## Operating rules
1. **Audit-first, zero blind deletions.** Do NOT delete or edit source code during
a debt hunt unless the user explicitly approves the deletion ledger or asks you
to clean up a specific item.
2. **Every candidate must pass the 4-way reachability check before being marked `SAFE-DELETE`:**
- Unreachable from `cmd/nektar` (`deadcode`)
- Zero production callers (`git grep` excluding `*_test.go`)
- Zero dynamic/string bindings (MCP tool names, HTTP routes, JSON/CBOR tags, Cedar actions, `go-workflows` registered activity/workflow names, `//go:embed`)
- Cross-package `*_test.go` usage explicitly classified (`0 test callers` → `SAFE-DELETE`, `test-only callers` → `TEST-FOSSIL` requiring test migration/pruning)
3. **Never touch cryptographic, custody, or wire-compatibility invariants** without
flagging them as `HIGH-RISK` (e.g., CBOR odd extension keys, legacy anchor v3
decoders, BRC-42/BRC-29/BRC-369 derivation paths, `SpendGuard` fail-closed caps).
4. **Quote exact commands, file paths, and LOC deltas** for every finding.
---
## Six Debt-Hunting Lenses
Run these lenses in order and record measured counts for each.
### Lens 1 — Whole-Program Reachability & Dead Code
```bash
# Unreachable functions from cmd/nektar (note: does not see cross-package _test.go callers)
go run golang.org/x/tools/cmd/deadcode@latest -test ./cmd/nektar
# Unexported unused symbols, dead params, and redundant conversions
golangci-lint run --disable-all -E unused,unparam,ineffassign,unconvert ./...
```
Classify every flagged symbol into:
- **True dead code (`SAFE-DELETE`)**: 0 prod callers, 0 test callers, 0 dynamic registrations.
- **Test-only fossil (`TEST-FOSSIL`)**: 0 prod callers, only legacy `*_test.go` callers left over from a migration.
- **False positive (`KEEP`)**: interface implementation, reflection/JSON/workflow activity, or intentional public SDK surface.
### Lens 2 — Migration Ghosts & Dual-Path Shims
Search for leftover code, adapters, comments, scripts, and CI steps from retired eras:
```bash
# Retired stack ghosts
git grep -n -i -E 'restate|awakeable|risc.?zero|circom|snarkjs|bulletproof|flatindex|packages/automaton|\.runar\.ts' -- cmd/ internal/ docs/ deploy/ scripts/ .github/
# Dual-path feature flags / legacy fallbacks / TODO-remove markers
git grep -n -i -E 'legacy|deprecated|compat|fallback|TODO.*remove|FIXME|HACK|XXX' -- cmd/ internal/
```
For each hit, decide: **intentional backward-compat wire/on-chain decoder (`KEEP`)** vs **dead migration shim (`DELETE`)** vs **stale prose (`UPDATE-DOC`)**.
### Lens 3 — Orphaned Persistence, Schema & KV Residue
```bash
# Every SQLite table created in internal/store
git grep -n -E 'CREATE TABLE' -- internal/store/
# Every KV key prefix read or written via GetJSON / SetJSON / GetKV / SetKV
git grep -n -E '(Get|Set)(JSON|KV)\(' -- cmd/ internal/
```
Flag any table, index, column, or KV key that is:
- Created/migrated but never queried in production code, OR
- Written but never read (write-only zombie state), OR
- Read but never written (dead legacy reader).
### Lens 4 — Config, Env Var, CLI, Tool & Doc Drift
1. **Env-var drift:** Compare every `NEKTAR_*` env var read in `cmd/` and `internal/` against `docs/ENVIRONMENT.md` (flag undocumented live vars AND documented dead vars).
2. **Package-map drift:** Compare actual `internal/*` directories against the Package Map in `AGENTS.md`.
3. **Tool/MCP/Skill parity:** Verify `Toolbox.ListTools()`, `Toolbox.toolHandlers()`, `internal/server/mcp.go`, and `skills/nektar-memory/SKILL.md` match.
4. **Metrics/Alerts parity:** Verify every metric referenced in `ops/alerts.yml` is still emitted by `internal/server/metrics.go`.
### Lens 5 — Structural Complexity, Duplication & Dependency Bloat
```bash
# Linter debt histogram (spot where complexity & copy-paste debt concentrates)
golangci-lint run ./...
# Stale or unnecessary dependencies
go mod tidy -diff
go list -m -f '{{if not .Indirect}}{{.Path}}{{end}}' all
# Oversized files (>600 non-test LOC) and god packages (>3,500 LOC)
```
Identify top copy-paste clones (`dupl`), oversized functions (`funlen` / `gocognit`), and direct `go.mod` dependencies that were left behind after a migration.
### Lens 6 — Go Language & Stdlib Modernization
```bash
# Preview Go 1.27 safe modernizations (any, min/max, slices, maps, clear, strings.Cut, range-over-int)
go fix -diff ./...
```
---
## Deliverable Format: The Technical Debt Ledger
Present findings in this exact structure so the user can approve batches cleanly:
1. **Executive Summary** — Total findings by category, estimated removable LOC, and top 3 highest-leverage cleanups.
2. **Batch A — Safe Deletions (`SAFE-DELETE`, zero behavior risk)** — Table of `File / Symbol | Lens | Why Dead | Est. LOC`.
3. **Batch B — Migration Ghosts & Doc/Env Drift (`CLEANUP`)** — Retired-era code/shims, orphaned KV/tables, and stale docs/env vars.
4. **Batch C — Test-Only Fossils & Duplication (`CONSOLIDATE`)** — Test-only exported APIs and convergent twins to merge.
5. **Batch D — Go Modernization & Complexity Hotspots (`MODERNIZE`)** — `go fix` wins and top complexity/god-file refactor candidates.
6. **Explicit Keep List** — Wire/on-chain backward-compatibility paths intentionally preserved (never accidentally deleted).