ai-toolkit-rules
Mandatory engineering, security, testing, git, performance, quality, and response rules. Claude MUST load this skill for every…
Refactors code for quality and maintainability. Triggers: refactor, clean up, restructure, improve code, modernize.
Claude Code
$ npx -y skills add softspark/ai-toolkit --skill refactor --agent claude-code
Codex
$ npx skills add softspark/ai-toolkit --skill refactor -a codex -y
Cursor
$ npx skills add softspark/ai-toolkit --skill refactor -a cursor -y
Gemini CLI
$ npx skills add softspark/ai-toolkit --skill refactor -a gemini-cli -y
GitHub Copilot
$ npx skills add softspark/ai-toolkit --skill refactor -a github-copilot -y
OpenCode
$ npx skills add softspark/ai-toolkit --skill refactor -a opencode -y
Windsurf
$ npx skills add softspark/ai-toolkit --skill refactor -a windsurf -y
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: Keep each teammate's configured model and effort unless the user selected an override. - Teammate 1 (code-reviewer): "Plan the refactoring strategy for [identified smells]. Document what to change and why." READ-ONLY. - Teammate 2 (backend-specialist): "Implement the refactoring changes identified by the reviewer." 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.
Mandatory engineering, security, testing, git, performance, quality, and response rules. Claude MUST load this skill for every…
Searches past coding sessions for observations, decisions, context. Triggers: mem-search, recall session, past work, prior…
Accessibility validator: WCAG 2.1 AA, EN 301 549, EAA. Triggers: a11y, accessibility, WCAG, EAA, ARIA, contrast, keyboard, screen…
Creates new specialized agents with frontmatter, tools, delegation. Triggers: new agent, create agent, agent scaffold,…
Analyzes code quality, complexity, patterns across codebase. Triggers: quality report, hotspot scan, code analysis, architecture…
API design: naming, versioning, pagination, idempotency, OpenAPI, error contracts and safe retries. Triggers: API design, REST,…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.