Agent skill

refactor-clean

Structured refactoring with smell detection, severity classification, and before/after metrics. Use when code needs deep structural analysis — decomposing large classes, resolving SOLID violations, eliminating duplication across modules, or reducing cyclomatic complexity. Presents a prioritized plan for approval before making changes. Not for lightweight post-edit polish (the simplify agent handles that automatically).

Stars 10
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/philoserf/claude-code-setup/tree/main/skills/refactor-clean

SKILL.md

Refactor and Clean Code

Systematic methodology for analyzing and refactoring code to improve quality, maintainability, and performance. Focus on practical, incremental improvements — not over-engineering.

When to Use

  • Code has grown unwieldy (long functions, large classes, deep nesting)
  • Duplicate logic scattered across modules
  • Complexity makes the code hard to test or extend
  • User asks to "refactor", "clean up", "simplify", or "improve code quality"

When NOT to Use

  • Adding new features (build first, refactor after)
  • Pure formatting/style changes (use formatter instead)
  • Writing tests from scratch (use tdd-cycle skill)
  • Performance-only optimization with no structural issues

Workflow

1. Analyze

Read the target code and identify issues using the analysis rubric.

  • Map function/class boundaries and responsibilities
  • Flag code smells with specific locations and threshold violations
  • Note SOLID violations and performance smells
  • Classify each issue by severity (Critical / High / Medium / Low)

2. Prioritize

Rank issues using the impact-effort matrix:

Priority Description Action
P1 High impact, low effort Do first
P2 High impact, high effort Plan next
P3 Low impact, low effort Quick wins
P4 Low impact, high effort Skip

Present the prioritized list to the user before making changes.

3. Refactor

Apply changes incrementally — one concern at a time:

  • Extract methods/functions to reduce size and complexity
  • Decompose classes that violate single responsibility
  • Replace magic numbers with named constants
  • Eliminate duplication by extracting shared logic
  • Simplify conditionals and reduce nesting depth
  • Improve names to be descriptive and searchable
  • Remove dead code and unused variables

Principles to follow: DRY, YAGNI, composition over inheritance, consistent abstraction levels, no side effects.

4. Verify

Run existing tests after each incremental change. Check against the quality checklist.

  • Detect test runner: check for package.json scripts, Makefile targets, pytest, go test, cargo test
  • Run the suite and confirm all tests pass
  • If tests break, fix before continuing
  • If no tests exist, note this in the report but don't block the refactor

5. Report

Provide a before/after metrics comparison:

text
## Refactoring Summary

### Changes Made
- [list of changes with severity tags]

### Metrics
| Metric              | Before | After |
|---------------------|--------|-------|
| Max function length |        |       |
| Max complexity      |        |       |
| Duplicate blocks    |        |       |
| Responsibilities    |        |       |

### Remaining Issues
- [anything deferred with rationale]

Output Format

  1. Analysis — Issues found, classified by severity
  2. Plan — Prioritized changes (confirm with user before proceeding)
  3. Refactored Code — Incremental changes with clear explanations
  4. Metrics Report — Before/after comparison

Reference Files

Detailed analysis criteria and quality standards:

  • analysis-rubric.md — Code smell thresholds, SOLID indicators, severity classification, prioritization matrix
  • quality-checklist.md — Before/after metrics template, acceptance criteria, reporting guidelines

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

philoserf/claude-code-setup

pre-release

Validates a project is ready to tag and ship. Use when tagging a release, cutting a version, shipping a package, or asking "are we ready to release?" Checks repo hygiene, CI status, docs, version sync, and build verification. Optimized for Obsidian plugins with fallback detection for other project types.

10 0
Explore
philoserf/claude-code-setup

local-issues

Reviews a codebase for bugs, design issues, and code cleanliness problems with specific file paths and line numbers. Use when auditing code quality, finding bugs, doing a code review, finding problems, or reviewing a project for issues. Creates issue files in `.issues/` directory.

10 0
Explore
philoserf/claude-code-setup

skill-improve

Generates prioritized improvement recommendations for Claude Code skills. Use when improving skills, enhancing customizations, or wanting actionable feedback on how to make a skill better. Provides impact/effort prioritization with specific fix suggestions.

10 0
Explore
philoserf/claude-code-setup

release

Executes the final release workflow for Obsidian plugins after pre-release checks pass. Use when tagging a release, publishing a version, or shipping an Obsidian plugin. Bumps version via bun run script, creates git tag, pushes to trigger GitHub Actions, and updates GitHub release notes from CHANGELOG.md.

10 0
Explore
philoserf/claude-code-setup

skill-quality

Scores Claude Code skills (1-5) across 6 weighted quality dimensions aligned with official Anthropic docs. Use when evaluating skill quality, rating skills, scoring customizations, comparing skill effectiveness, or checking if a skill follows best practices. Produces per-dimension scores with evidence, weighted totals, quality tier classification, and actionable improvement recommendations.

10 0
Explore
philoserf/claude-code-setup

obsidian-cli

Interacts with Obsidian vaults using the Obsidian CLI to read, create, and manage notes, tasks, properties, tags, and more. Also supports plugin and theme development with commands to reload plugins, run JavaScript, capture errors, take screenshots, and inspect the DOM. Use when the user asks to interact with their Obsidian vault, manage notes, add to daily note, find notes about a topic, check tasks, append to a note, query the vault, list tags, list files, manage bookmarks, check sync status, view file history, use templates, query bases, run QuickAdd, perform vault operations from the command line, or develop and debug Obsidian plugins and themes.

10 0
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results