Agent skill
refactoring-codebase
Guidelines for maintaining a clean codebase through limits and abstraction. Use when a file or component becomes difficult to read.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/refactoring-codebase-itsmealee-tourly2
SKILL.md
Refactoring and Code Cleanup
When to use this skill
- A component file exceeds 200 lines.
- The same logic is repeated in 3 or more places.
- Props are becoming too many/complex.
Rules
- The "Boy Scout Rule": Always leave the code slightly cleaner than you found it.
- Sub-components: Split large components into smaller files in a local
components/subfolder. - Custom Hooks: Extract stateful logic (complex forms, complex filters) into hooks.
Workflow
- Identify a "Messy" component.
- Extract presentational parts into atomic components.
- Extract logic into Services or Hooks.
- Verify that the visual UI has NOT changed.
Instructions
- No Pre-optimization: Refactor logic only when it's actually reused or the file is unmanageable.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?