ai-toolkit-rules
Mandatory engineering, security, testing, git, performance, quality, and response rules.…
Refactors code for quality and maintainability. Triggers: refactor, clean up, restructure, improve code, modernize.
$ npx -y skills add softspark/ai-toolkit --skill refactor --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/refactorContext preview
The summary Claude sees to decide when to auto-load this skill.
Refactors code for quality and maintainability. Triggers: refactor, clean up, restructure, improve code, modernize.
name: refactor description: "Refactors code for quality and maintainability. Triggers: refactor, clean up, restructure, improve code, modernize." user-invocable: true effort: high argument-hint: "[target and goal]" agent: code-reviewer context: fork allowed-tools: Read, Edit, Grep, Glob, Bash
$ARGUMENTS
Plan and execute code refactoring.
/refactor [target] [--pattern=<pattern>]
1. **Analyzes** target code 2. **Identifies** refactoring opportunities 3. **Plans** refactoring steps 4. **Executes** with user approval
| Pattern | Description | |---------|-------------| | `extract-function` | Extract code block to function | | `extract-component` | Extract UI component | | `rename` | Rename symbol across codebase | | `move` | Move code to better location | | `inline` | Inline unnecessary abstraction | | `simplify` | Simplify complex logic |
## Refactoring Plan: [Target] ### Current State - **Location**: [file:line] - **Issues**: [what's wrong] ### Proposed Changes 1. [Change 1] 2. [Change 2] ### Impact Analysis - **Files affected**: [count] - **Risk level**: [Low/Medium/High] ### Test Coverage - [x] Unit tests exist - [ ] Integration tests needed ### Rollback
git revert [commit]
Before executing:
| Excuse | Why It's Wrong | |--------|----------------| | "It works, don't touch it" | Working code that's hard to maintain slows every future change | | "We'll refactor it later" | Later never comes — refactor when the pain is fresh and context is loaded | | "It's too risky to change" | That's exactly why it needs refactoring — risk compounds with complexity | | "Just one more hack won't hurt" | Each hack makes the next one easier to justify — break the cycle now | | "We need to rewrite from scratch" | Incremental refactoring is safer and delivers value continuously |
This command analyzes and plans first. Execution requires explicit approval.
After refactoring, update documentation:
| Change Type | Update | |-------------|--------| | API changes | API documentation | | Architecture | architecture note if significant | | Patterns | Best practices docs | | Breaking changes | Migration guide |
Run the bundled script to find refactoring opportunities:
python3 ${CLAUDE_SKILL_DIR}/scripts/refactor-scan.py src/If the scan reports >5 smells across multiple files, use Agent Teams:
Create an agent team for refactoring: - Teammate 1 (code-reviewer): "Plan the refactoring strategy for [identified smells]. Document what to change and why." Use Opus. READ-ONLY. - Teammate 2 (backend-specialist): "Implement the refactoring changes identified by the reviewer." Use Opus. Teammate 1 completes first, then Teammate 2 acts on the plan.
AI coding toolkit with machine-enforced safety, 116 skills, 44 agents, lifecycle hooks, persona presets, opt-in plugin packs, and benchmark tooling.
Repo: softspark/ai-toolkit
Mandatory engineering, security, testing, git, performance, quality, and response rules.…
Searches past coding sessions for observations, decisions, context. Triggers: mem-search,…
Accessibility validator: WCAG 2.1 AA, EN 301 549, EAA. Triggers: a11y, accessibility, WCAG,…
Creates new specialized agents with frontmatter, tools, delegation. Triggers: new agent,…
Analyzes code quality, complexity, patterns across codebase. Triggers: quality report,…
API design: naming, versioning, pagination, idempotency, OpenAPI, error contracts and safe…