Agent skill
refactoring-assistant
Assists with code refactoring by detecting code smells, suggesting improvements, and providing refactoring patterns. Activates when writing/editing code, explicitly requested refactoring, or when code quality issues are detected. Maintains awareness of core principles while providing detailed patterns and examples.
Install this agent skill to your Project
npx add-skill https://github.com/fubira/claude-code-settings/tree/main/skills/refactoring-assistant
SKILL.md
Refactoring Assistant Skill
Detect code smells and assist refactoring during development. Proactively suggest improvements without waiting for explicit requests.
Activation Triggers
- Threshold violations detected during code editing (automatic)
- "refactor", "code smell" (manual)
Code Smell Thresholds
| Code Smell | Threshold | Action |
|---|---|---|
| Long Method | > 50 lines | Extract functions |
| Duplicate Code | 3+ occurrences | Extract to shared function/constant |
| Deep Nesting | > 3 levels | Early return, extract conditions |
| Long Parameter List | > 5 params | Structured params (TS: RORO, Go: struct) |
| Large Module | > 300 lines | Split into smaller modules |
| Complex Conditional | > 3 conditions | Extract to named function/variable |
Workflow
- Detect: Read code, match against thresholds. Prioritize by severity (security > readability > style)
- Analyze: Check tech-stack rules (
patterns/typescript-react.md,patterns/go.md). Consider context (one-off vs recurring, business justification for complexity) - Suggest: Show location (file:line), present before/after with trade-offs. Execute after user approval (partial approval OK)
- Implement: Make small incremental changes. Run tests/linter to verify. Record new patterns via knowledge-manager
Guardrails
- Do not refactor without test coverage (add tests first)
- Do not change behavior (refactoring ≠ feature change)
- Prefer incremental improvement over large-scale rewrites
Supporting Files
rules/code-smells.md: Detection criteria and pattern detailspatterns/typescript-react.md: TS/React-specific patternspatterns/go.md: Go-specific patterns
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
code-reviewer
Assists with code review by analyzing code changes for quality, best practices, security, and potential issues. Activates after implementing code features, bug fixes, or refactorings. Provides structured feedback with critical issues, suggestions, and positive highlights.
context-compactor
Analyzes and compacts context-affecting documents (project memory, CLAUDE.md, skill files) to reduce token usage and compaction frequency. Manual trigger only. Always requires user approval before making changes.
test-executor
Executes tests, analyzes test results, checks test coverage, and provides comprehensive testing status overview. Primarily for Go projects. Activates after implementing/modifying code to verify correctness, or when explicitly requested to assess test suite health.
knowledge-manager
Manages a structured knowledge base of patterns, troubleshooting guides, best practices, and workflows. Activates when discovering reusable insights, solving technical problems, or establishing new standards. Records knowledge in categorized files for future reference without bloating global CLAUDE.md.
release-assistant
Automates and ensures reliable release workflows with automatic version bump based on commit history, mandatory lint/build/test execution before release, and safe tag creation and push.
git-commit-assistant
Assists with careful Git commits in any repository. Activates when committing changes, checking .gitignore, or generating commit messages. Ensures proper file exclusion (credentials, MCP configs, personal settings), identifies untracked files, and generates Conventional Commits messages with Japanese explanations.
Didn't find tool you were looking for?