code-refactoring-small
Refactor overly large code units into smaller, more focused components. Use when code has grown too large or complex.
Best use case
code-refactoring-small is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Refactor overly large code units into smaller, more focused components. Use when code has grown too large or complex.
Teams using code-refactoring-small should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/code-refactoring-small/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How code-refactoring-small Compares
| Feature / Agent | code-refactoring-small | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Refactor overly large code units into smaller, more focused components. Use when code has grown too large or complex.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# Code Refactoring: Keep Code Small Refactor overly large code you just added or extended into smaller, more focused components. ## When to Use This Skill Use this skill when: - Functions or methods are too long (typically >50 lines) - Classes have too many responsibilities - Files have grown too large or handle multiple concerns - Code has deeply nested blocks - After implementing a feature and noticing bloat ## Critical Rule: Refactor As You Go **When adding new logic to an existing function, ALWAYS check whether the function is already long.** If it is, extract a new method/function for the new logic rather than inlining it. Do NOT bloat existing functions further — refactoring is not a separate step to do later; it must happen at the time of writing. This applies even when the new code is "just" 20-30 lines. Adding 30 lines to a 100-line function makes it a 130-line function that now needs refactoring. The correct approach is to never let it get that far. ## Instructions ### Step 1: Identify the Bloat Review your recent changes (committed or uncommitted) to find: - Functions or methods that are too long - Classes that have too many responsibilities - Files that have grown too large - Deeply nested code blocks - **New logic inlined into already-long functions** (this is the most common mistake — catch it early) ### Step 2: Clarify Scope (If Needed) If the bloat is not obvious, ask the user to clarify which specific code units they want refactored before proceeding. ### Step 3: Refactor Once the bloat is identified: - Extract logical sub-operations into separate functions/methods - Split large classes following Single Responsibility Principle - Move related functionality into separate modules/files - Reduce nesting levels by extracting guard clauses or helper functions - Ensure each unit does one thing well (UNIX Philosophy) - **Deduplicate repeated structures** (e.g. lookup tables defined in multiple places should become shared constants) ### Step 4: Verify After refactoring: - Run linters and tests if available - Verify the code still works as expected - Check that the solution is clearer and more maintainable - Ensure the refactoring improved readability ## Goal Break down large, complex code units into smaller, focused components that are: - Easier to understand - Easier to test - Easier to maintain Each function, class, or file should have a clear, single purpose.
Related Skills
code-refactoring-dry
Remove code duplication by extracting shared logic into reusable components. Use when the same logic appears in multiple places.
xlsx-to-csv
Convert XLSX spreadsheets (single or multi-sheet) to CSV files you can read and grep. Use whenever you need to process an .xlsx report from Xero, Cryptio, bank exports, or any tool that delivers spreadsheet output.
xero-mcp
Use the Xero MCP server — obtain/refresh OAuth2 bearer tokens, troubleshoot authentication, and pick up other operational notes for working with Xero MCP tools. Use when Xero MCP tools fail with authentication errors, when the bearer token has expired (tokens last ~30 min), before starting any Xero workflow, or for general guidance on Xero MCP usage.
xero-browser
General Xero browser automation notes. Use when automating any Xero page with agent-browser — covers non-standard UI patterns, waiting, and dropdown menus.
test-running
Run tests according to repository guidelines. Use after linting passes, before staging changes.
task-orchestration
Orchestrate the complete development workflow for implementing sub-tasks from a task list. Use for end-to-end feature implementation with quality controls.
task-implementation
Implement a single sub-task from a task list. Use when working on feature development with existing task lists.
task-generation
Generate a detailed task list from a PRP. Use after a PRP is created and ready for implementation planning.
subagent-authoring
Create subagent definitions for Claude Code and OpenCode that delegate to skills. Use when creating new subagents or refactoring existing ones to follow the delegation pattern.
slow-command-running
Pipe long running commands through tee(1) to allow watching output and repeated analyses without rerunning
skill-authoring
Create and maintain Claude Code skills following Anthropic best practices. Use when building new skills, refactoring existing ones, or ensuring skills follow official guidelines for structure, naming, progressive disclosure, and testing.
safe-rm
Safely delete files / directories without asking for permission