hdb:detect-debt
Examine a codebase through the eyes of a senior developer. Find code that doesn't understand the project, code that will rot, and code that provides false confidence. Produce a prioritized remediation plan.
Usage
/detect-debt [--diff] [path]
- No arguments: full scan of current working directory
--diff: analyze only uncommitted changes or current branch diff
path: analyze a specific directory
Instructions
When the user invokes /detect-debt:
Phase 1: Understand the Project
Before looking for problems, build a mental model of how this project works.
Read project structure — use Glob to map the directory tree. Identify: source directories, test directories, config files, build files (Cargo.toml, go.mod, requirements.txt, pyproject.toml, package.json).
Identify the language(s) — determine primary and secondary languages from file extensions and build config.
Read key files — read the main entry point, 2-3 core modules, and 2-3 test files. You need to understand:
- How does this project handle errors? (Result types, anyhow, custom errors, try/except style, Go error returns)
- How is the project structured? (Flat, layered, domain-driven, MVC)
- What naming conventions does it follow?
- What dependencies does it use for common tasks (HTTP, logging, serialization, database)?
- How are tests written? (Inline unit tests, separate test files, integration tests, mocks vs real dependencies)
Check for config — look for .tech-debt-detector.toml at the project root. If present, read it for exclusions, suppressions, and severity overrides.
Summarize your understanding — write a brief (5-10 line) summary of the project's conventions. This is your baseline for detecting violations.
Phase 2: Analyze
Run mechanical checks and read code with judgment. If tech-debt-detector CLI is available, run it first. Otherwise, work directly.
Run linters (if available and applicable):
- Rust:
cargo clippy --message-format=json 2>&1
- Python:
ruff check --output-format=json .
- Go:
golangci-lint run --out-format json ./...
- Note results but do not report linter findings directly — use them as signals for deeper analysis.
Run tech-debt-detector CLI (if installed):
tech-debt-detector --project . --format json
Or for diff mode:
tech-debt-detector --project . --diff --format json
If CLI is not available, analyze directly. Read source files and look through the three lenses:
Lens 1 — Code that doesn't understand the project:
- Does new/changed code follow the project's established error handling pattern?
- Does it respect module boundaries and architectural structure?
- Does it use the same libraries the project already uses for the same tasks?
- Does it follow the project's naming conventions?
- Does it call APIs that exist in the dependency versions specified?
Lens 2 — Code that will rot:
- Are errors being swallowed or caught-and-ignored?
- Are resources opened without cleanup?
- Is there duplicated logic that should use existing utilities?
- Is code more complex than the problem requires?
- Are there unbounded collections, missing timeouts, or absent cancellation?
Lens 3 — Code that provides false confidence:
- Do tests actually assert on behavior, or just exercise code?
- Are error paths tested, or only the happy path?
- Is input validation checking the things that matter?
- Are error messages specific enough to debug with?
For diff mode — focus analysis on changed files only, but compare against the project's established patterns from Phase 1. Flag changes that introduce inconsistency.
Phase 3: Report Findings and Remediation Plan
- Format each finding using this structure:
CATEGORY: Doesn't Understand the Project | Will Rot | False Confidence
SEVERITY: must-fix | should-fix | consider
URGENCY: high | moderate | low
FILE: path/to/file.rs:42-58
WHAT: One sentence describing the problem
WHY: Why this matters — what breaks, what debt it introduces, or what convention it violates
EVIDENCE: The specific code or pattern that triggered the finding
FIX: Concrete recommendation — what to change, with example code when appropriate
Determine urgency based on how central the affected code is:
- high — hot path, shared abstraction, or high fan-in module
- moderate — active but not central code
- low — isolated, rarely touched, leaf module
Order findings — sort by: must-fix first, then by urgency (high before low), then by category (doesn't understand > will rot > false confidence).
Present the remediation plan — group related findings that should be fixed together. For each group:
- Explain the root cause connecting the findings
- Provide a concrete fix with code examples
- Note any dependencies between fixes (e.g., "fix the error type first, then update the handlers")
Do NOT report:
- Findings that linters already surface well (formatting, unused variables) unless they indicate deeper issues
- Generic advice without pointing to specific code
- Style preferences that aren't established project conventions
- Complexity metrics without explaining why the complexity is problematic in this specific context
Phase 4: Follow-up
- Offer to fix — after presenting findings, offer to implement the fixes. If the user agrees, work through the remediation plan in order, committing each logical unit separately.
1---2name: hdb-detect-debt3description: Detect tech debt, AI slop, and code quality issues in a codebase and produce an actionable remediation plan4---56# hdb:detect-debt78Examine a codebase through the eyes of a senior developer. Find code that doesn't understand the project, code that will rot, and code that provides false confidence. Produce a prioritized remediation plan.910## Usage1112```13/detect-debt [--diff] [path]14```1516- No arguments: full scan of current working directory17- `--diff`: analyze only uncommitted changes or current branch diff18- `path`: analyze a specific directory1920## Instructions2122When the user invokes `/detect-debt`:2324### Phase 1: Understand the Project2526Before looking for problems, build a mental model of how this project works.27281. **Read project structure** — use Glob to map the directory tree. Identify: source directories, test directories, config files, build files (Cargo.toml, go.mod, requirements.txt, pyproject.toml, package.json).29302. **Identify the language(s)** — determine primary and secondary languages from file extensions and build config.31323. **Read key files** — read the main entry point, 2-3 core modules, and 2-3 test files. You need to understand:33 - How does this project handle errors? (Result types, anyhow, custom errors, try/except style, Go error returns)34 - How is the project structured? (Flat, layered, domain-driven, MVC)35 - What naming conventions does it follow?36 - What dependencies does it use for common tasks (HTTP, logging, serialization, database)?37 - How are tests written? (Inline unit tests, separate test files, integration tests, mocks vs real dependencies)38394. **Check for config** — look for `.tech-debt-detector.toml` at the project root. If present, read it for exclusions, suppressions, and severity overrides.40415. **Summarize your understanding** — write a brief (5-10 line) summary of the project's conventions. This is your baseline for detecting violations.4243### Phase 2: Analyze4445Run mechanical checks and read code with judgment. If `tech-debt-detector` CLI is available, run it first. Otherwise, work directly.46476. **Run linters** (if available and applicable):48 - Rust: `cargo clippy --message-format=json 2>&1`49 - Python: `ruff check --output-format=json .`50 - Go: `golangci-lint run --out-format json ./...`51 - Note results but do not report linter findings directly — use them as signals for deeper analysis.52537. **Run tech-debt-detector CLI** (if installed):54 ```bash55 tech-debt-detector --project . --format json56 ```57 Or for diff mode:58 ```bash59 tech-debt-detector --project . --diff --format json60 ```61628. **If CLI is not available, analyze directly.** Read source files and look through the three lenses:6364 **Lens 1 — Code that doesn't understand the project:**65 - Does new/changed code follow the project's established error handling pattern?66 - Does it respect module boundaries and architectural structure?67 - Does it use the same libraries the project already uses for the same tasks?68 - Does it follow the project's naming conventions?69 - Does it call APIs that exist in the dependency versions specified?7071 **Lens 2 — Code that will rot:**72 - Are errors being swallowed or caught-and-ignored?73 - Are resources opened without cleanup?74 - Is there duplicated logic that should use existing utilities?75 - Is code more complex than the problem requires?76 - Are there unbounded collections, missing timeouts, or absent cancellation?7778 **Lens 3 — Code that provides false confidence:**79 - Do tests actually assert on behavior, or just exercise code?80 - Are error paths tested, or only the happy path?81 - Is input validation checking the things that matter?82 - Are error messages specific enough to debug with?83849. **For diff mode** — focus analysis on changed files only, but compare against the project's established patterns from Phase 1. Flag changes that introduce inconsistency.8586### Phase 3: Report Findings and Remediation Plan878810. **Format each finding** using this structure:8990```91CATEGORY: Doesn't Understand the Project | Will Rot | False Confidence92SEVERITY: must-fix | should-fix | consider93URGENCY: high | moderate | low94FILE: path/to/file.rs:42-5895WHAT: One sentence describing the problem96WHY: Why this matters — what breaks, what debt it introduces, or what convention it violates97EVIDENCE: The specific code or pattern that triggered the finding98FIX: Concrete recommendation — what to change, with example code when appropriate99```100101Determine urgency based on how central the affected code is:102- **high** — hot path, shared abstraction, or high fan-in module103- **moderate** — active but not central code104- **low** — isolated, rarely touched, leaf module10510611. **Order findings** — sort by: must-fix first, then by urgency (high before low), then by category (doesn't understand > will rot > false confidence).10710812. **Present the remediation plan** — group related findings that should be fixed together. For each group:109 - Explain the root cause connecting the findings110 - Provide a concrete fix with code examples111 - Note any dependencies between fixes (e.g., "fix the error type first, then update the handlers")11211313. **Do NOT report:**114 - Findings that linters already surface well (formatting, unused variables) unless they indicate deeper issues115 - Generic advice without pointing to specific code116 - Style preferences that aren't established project conventions117 - Complexity metrics without explaining why the complexity is problematic in this specific context118119### Phase 4: Follow-up12012114. **Offer to fix** — after presenting findings, offer to implement the fixes. If the user agrees, work through the remediation plan in order, committing each logical unit separately.