shunsukehayashi/miyabi
Overview
This skill refactor-helper automates and guides safe, systematic code refactoring for TypeScript projects. It focuses on improving code quality, performance, and maintainability while preserving behavior. Use it to modernize legacy code, break up large functions, and apply common refactoring patterns reliably.
How this skill works
refactor-helper inspects code for common smells (long functions, duplicate logic, complex conditionals, god classes, dead code) and proposes small, focused changes such as extract-function, replace-conditionals-with-polymorphism, and simplifications. It enforces a workflow: identify smells, add or verify tests, perform incremental refactors, and run verification steps (tests, lint, typechecks). It also suggests tooling commands and concrete code examples tailored to TypeScript.
When to use it
- Modernizing legacy TypeScript code to newer syntax or patterns
- Breaking up large functions or classes to improve readability
- Removing dead code and unused dependencies safely
- Consolidating duplicated logic or simplifying complex conditionals
- Preparing code for performance or maintainability improvements
Best practices
- Make one small refactor per commit to keep changes reviewable
- Ensure tests exist and pass before starting any refactor
- Run tests, lint, and type checks after each incremental change
- Preserve external behavior — refactor structure, not logic
- Use automated tools (ts-prune, depcheck) to find dead code and unused deps
Example use cases
- Extracting validation and calculation helpers from a long order-processing function
- Replacing switch-based pricing logic with strategy classes to enable extension
- Simplifying nested user checks using optional chaining and array includes
- Removing unused exports and dependencies discovered by automated scans
- Adding focused unit tests before refactoring a critical module
FAQ
No — the goal is to keep behavior unchanged. Always add or run tests to verify behavior remains identical.
Which tools does this recommend for TypeScript?
Use npm test for unit tests, npm run lint and npm run typecheck for verification, and tools like ts-prune and depcheck to detect dead code and unused deps.
9 skills
This skill guides safe, incremental refactoring to improve structure, performance, and maintainability without changing behavior.
This skill helps you create well-structured Claude Skills for Miyabi projects by guiding setup, naming, and packaging workflows.
This skill generates comprehensive unit tests and coverage reports for TypeScript projects using Vitest, Playwright, and Testing Library.
This skill reduces context window bloat by progressively disclosing MCP tools and indexing hierarchically for efficient discovery.
This skill generates comprehensive documentation for code, README files, and API references to save time and improve clarity.
This skill converts git diffs into clear, conventional commit messages to speed up commits and maintain consistency.
This skill reviews TypeScript code for correctness, security, performance, and maintainability to improve PR quality and code health.
This skill helps you create and manage AI agent skills following best practices for multi-agent design and progressive disclosure.
This skill helps you build autonomous coding agents and workflows by integrating Claude Code, multi-session management, and CI/CD pipelines.