Agent skill

tech-debt-reducer

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.

Stars 1
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/giulio-leone/vscode-agent-skills/tree/main/skills/tech-debt-reducer

Metadata

Additional technical details for this skill

author
coachone
version
1.0

SKILL.md

๐Ÿ”ง Tech Debt Reducer

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

Quick Reference

Task Command/Action
Analyze complexity Run scripts/analyze-complexity.ts
Find unused code Run scripts/find-unused.ts
Detect code smells Run scripts/detect-smells.ts
Generate debt report Run scripts/debt-report.ts
Prioritize debt items Follow "Prioritization Matrix" section

Core Methodology

Phase 1: Assessment (ALWAYS FIRST)

Before any refactoring, assess the current state:

markdown
## ๐Ÿ“Š 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:

Category Description Examples
Architecture Structural issues Circular deps, wrong abstractions
Code Quality Maintainability issues Long functions, duplicate code
Performance Speed/memory issues N+1 queries, memory leaks
Security Vulnerability issues Outdated deps, exposed secrets
Testing Coverage gaps Missing tests, flaky tests
Documentation Knowledge gaps Missing 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

Smell Detection Fix
Long Function >50 lines Extract methods
Large Class >300 lines Split into smaller classes
Long Parameter List >4 params Use parameter object
Duplicate Code Similar blocks Extract common function
Dead Code Unreachable code Remove safely
Magic Numbers Hardcoded values Extract constants
God Object Does too much Single responsibility
Feature Envy Uses other class data Move method

TypeScript-Specific Smells

Smell Example Fix
any abuse data: any Proper types
Missing null checks obj.prop Optional chaining ?.
Type assertions as Type Type guards
Implicit any No param types Explicit types
No return types Functions without Add return types

Performance Optimization

Quick Wins

typescript
// โŒ 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

typescript
// โŒ 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

bash
# Find unused dependencies
npx depcheck

# Analyze bundle size
npx webpack-bundle-analyzer

# Check for duplicates
npm dedupe

Output Template

After completing debt reduction work:

markdown
## ๐Ÿ”ง 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

Expand your agent's capabilities with these related and highly-rated skills.

giulio-leone/vscode-agent-skills

advanced-debugging

State-of-the-art debugging agent with hypothesis-driven analysis, automatic code instrumentation, git worktree isolation, and browser automation. Use when debugging errors, stack traces, unexpected behavior, performance issues, failed tests, race conditions, or hard-to-reproduce bugs.

1 0
Explore
giulio-leone/vscode-agent-skills

skill-generator

Meta-skill for creating, refining, and managing Agent Skills. Use when needing to create new skills, improve existing skills, analyze skill performance, or teach the agent new capabilities. Enables self-improvement and knowledge capture.

1 0
Explore
giulio-leone/vscode-agent-skills

oneplan

OnePlan is a GitHub-native, context-driven engineering workflow using Milestones (tracks), Issues (spec/plan), and Sub-issues (phases/tasks). Use for complex features/bugfixes that need structured planning, resumable execution, parallel tasks, and team coordination.

1 0
Explore
sickn33/antigravity-awesome-skills

obsidian-clipper-template-creator

Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.

28,421 4,766
Explore
sickn33/antigravity-awesome-skills

claude-code-expert

Especialista profundo em Claude Code - CLI da Anthropic. Maximiza produtividade com atalhos, hooks, MCPs, configuracoes avancadas, workflows, CLAUDE.md, memoria, sub-agentes, permissoes e integracao com ecossistemas.

28,421 4,766
Explore
sickn33/antigravity-awesome-skills

lex

Centralized 'Truth Engine' for cross-jurisdictional legal context (US, EU, CA) and contract scaffolding.

28,421 4,766
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results