agentleFS
giulio-leonegiulio-leone/vscode-agent-skills/skills/tech-debt-reducer/SKILL.md

tech-debt-reducer

Skill1 starsChanged 11 months agoMITView on GitHub

Systematic technical debt reduction and code optimization agent. Use when refactoring code, reducing complexity, eliminating code smells, improving performance, cleaning up unused code, or modernizing legacy patterns. Handles dependency updates, architecture improvements, and codebase health metrics.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before any refactoring, assess the current state:

    line 29
  2. Distinctive:

    Use the Impact vs Effort matrix:

    line 66
  3. Distinctive:

    After completing debt reduction work:

    line 191
  4. Distinctive:

    Stop and reassess if:

    line 228

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

🔧 Tech Debt Reducer

Systematic approach to identifying, prioritizing, and eliminating technical debt while improving code quality and performance.

Quick Reference

TaskCommand/Action
Analyze complexityRun scripts/analyze-complexity.ts
Find unused codeRun scripts/find-unused.ts
Detect code smellsRun scripts/detect-smells.ts
Generate debt reportRun scripts/debt-report.ts
Prioritize debt itemsFollow "Prioritization Matrix" section

Core Methodology

Phase 1: Assessment (ALWAYS FIRST)

Before any refactoring, assess the current state:

## 📊 Tech Debt Assessment

### Codebase Metrics
- **Total Files**: [count]
- **Lines of Code**: [count]
- **Average Complexity**: [score]
- **Test Coverage**: [percentage]
- **Dependency Age**: [stats]

### Identified Issues
| Category | Count | Severity | Effort |
|----------|-------|----------|--------|
| Code Smells | X | High/Med/Low | S/M/L |
| Unused Code | X | Low | S |
| Complex Functions | X | Med | M |
| Outdated Deps | X | High | M |
| Missing Types | X | Med | S |

Phase 2: Categorization

Classify debt into categories:

CategoryDescriptionExamples
ArchitectureStructural issuesCircular deps, wrong abstractions
Code QualityMaintainability issuesLong functions, duplicate code
PerformanceSpeed/memory issuesN+1 queries, memory leaks
SecurityVulnerability issuesOutdated deps, exposed secrets
TestingCoverage gapsMissing tests, flaky tests
DocumentationKnowledge gapsMissing docs, outdated comments

Phase 3: Prioritization Matrix

Use the Impact vs Effort matrix:

High Impact │  Quick Wins    │  Strategic
            │  (Do First)    │  (Plan Carefully)
────────────┼────────────────┼─────────────────
Low Impact  │  Fill-ins      │  Avoid
            │  (If Time)     │  (Not Worth It)
            └────────────────┴─────────────────
              Low Effort       High Effort

Priority Formula: Score = (Impact × Risk) / Effort

Phase 4: Refactoring Patterns

See references/REFACTORING_PATTERNS.md for detailed patterns.

Safe Refactoring Workflow

1. ✅ Ensure tests exist (or write them first)
2. 📸 Create snapshot/checkpoint (git commit)
3. 🔧 Apply ONE refactoring at a time
4. 🧪 Run tests after each change
5. 📝 Commit with descriptive message
6. 🔄 Repeat

Code Smell Detection

Common Smells and Fixes

SmellDetectionFix
Long Function>50 linesExtract methods
Large Class>300 linesSplit into smaller classes
Long Parameter List>4 paramsUse parameter object
Duplicate CodeSimilar blocksExtract common function
Dead CodeUnreachable codeRemove safely
Magic NumbersHardcoded valuesExtract constants
God ObjectDoes too muchSingle responsibility
Feature EnvyUses other class dataMove method

TypeScript-Specific Smells

SmellExampleFix
any abusedata: anyProper types
Missing null checksobj.propOptional chaining ?.
Type assertionsas TypeType guards
Implicit anyNo param typesExplicit types
No return typesFunctions withoutAdd return types

Performance Optimization

Quick Wins

// ❌ Bad: Multiple re-renders
const items = data.filter(x => x.active).map(x => x.name);

// ✅ Good: Single pass with reduce
const items = data.reduce((acc, x) => {
  if (x.active) acc.push(x.name);
  return acc;
}, []);

// ❌ Bad: Creating functions in render
<Button onClick={() => handleClick(id)} />

// ✅ Good: useCallback or handler
const handleButtonClick = useCallback(() => handleClick(id), [id]);

// ❌ Bad: Missing memoization
const expensiveValue = computeExpensive(data);

// ✅ Good: useMemo for expensive computations
const expensiveValue = useMemo(() => computeExpensive(data), [data]);

Database Query Optimization

// ❌ Bad: N+1 Query
const users = await prisma.user.findMany();
for (const user of users) {
  const posts = await prisma.post.findMany({ where: { userId: user.id } });
}

// ✅ Good: Include related data
const users = await prisma.user.findMany({
  include: { posts: true }
});

// ✅ Better: Select only needed fields
const users = await prisma.user.findMany({
  select: { id: true, name: true, posts: { select: { title: true } } }
});

Dependency Management

Update Strategy

  1. Check outdated: npm outdated
  2. Review changelogs for breaking changes
  3. Update in order: patch → minor → major
  4. Test after each major update

Cleanup Unused Dependencies

# Find unused dependencies
npx depcheck

# Analyze bundle size
npx webpack-bundle-analyzer

# Check for duplicates
npm dedupe

Output Template

After completing debt reduction work:

## 🔧 Tech Debt Report

### 📊 Before/After Metrics
| Metric | Before | After | Change |
|--------|--------|-------|--------|
| Complexity | X | Y | -Z% |
| Lines of Code | X | Y | -Z% |
| Test Coverage | X% | Y% | +Z% |
| Bundle Size | X KB | Y KB | -Z% |

### ✅ Changes Made
1. [Description of change 1]
2. [Description of change 2]

### 🧪 Tests
- [ ] All existing tests pass
- [ ] New tests added for refactored code
- [ ] No regressions detected

### 📝 Follow-up Items
- [ ] Item that needs future attention

Safety Guidelines

  • ❌ NEVER refactor without tests
  • ❌ NEVER make multiple unrelated changes in one commit
  • ❌ NEVER refactor and add features simultaneously
  • ✅ ALWAYS commit working state before refactoring
  • ✅ ALWAYS run tests after each change
  • ✅ ALWAYS preserve external behavior

Escalation Criteria

Stop and reassess if:

  • Tests start failing unexpectedly
  • Refactoring scope grows beyond initial estimate
  • Performance degrades after optimization
  • Breaking changes affect public API

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.