code-refactoring
Guides systematic code refactoring to improve code quality, maintainability, and design. Identifies code smells, applies refactoring patterns, ensures test coverage, and follows safe refactoring practices. Produces cleaner, more maintainable code while preserving functionality. Use when improving code quality, eliminating technical debt, preparing for feature additions, addressing code smells, or when users mention refactoring, code cleanup, improving design, reducing complexity, or modernizing legacy code.
What this skill does
# Code Refactoring ## Overview This skill guides systematic code refactoring to improve code quality, maintainability, and design while preserving functionality. Follow the safe refactoring workflow with comprehensive test coverage and incremental changes. ## Refactoring Workflow ## Step 1: Analyze Code and Identify Issues Examine the codebase to identify code smells and quality issues: - Long methods (>20-30 lines) or large classes (>300-500 lines) - Duplicated code blocks or similar logic in multiple places - Unclear or misleading names for variables, methods, or classes - Complex conditional logic or deeply nested structures - Poor separation of concerns or tight coupling between components **For detailed code smell catalog**: See [code-smells.md](references/code-smells.md) ### Step 2: Verify Test Coverage Before refactoring ANY code: 1. Check existing test coverage for the code to be refactored 2. If tests are missing or inadequate, write tests FIRST 3. Run all tests to establish baseline (all should pass) 4. Never proceed without adequate test coverage **For test coverage strategies**: See [testing-strategies.md](references/testing-strategies.md) ### Step 3: Choose Refactoring Technique Select the appropriate refactoring pattern based on the issue: - **Extract Method/Function**: Break down long methods into smaller, focused ones - **Extract Class**: Split large classes with multiple responsibilities - **Rename**: Improve clarity with better names - **Move Method/Field**: Relocate functionality to more appropriate classes - **Replace Conditional with Polymorphism**: Simplify complex conditionals - **Introduce Parameter Object**: Group related parameters - **Inline Method/Variable**: Remove unnecessary indirection **For complete pattern catalog**: See [refactoring-patterns.md](references/refactoring-patterns.md) ### Step 4: Apply Refactoring Incrementally Make ONE small change at a time: 1. Apply a single refactoring technique 2. Run all tests immediately after the change 3. If tests pass, commit the change 4. If tests fail, revert and try a different approach 5. Repeat for each refactoring needed **Critical Rules:** - Never change behavior while refactoring - Never refactor and add features simultaneously - Use IDE automated refactoring tools when available - Keep each refactoring commit small and focused **For detailed process guidance**: See [refactoring-process.md](references/refactoring-process.md) ### Step 5: Verify and Document After completing refactorings: 1. Run full test suite to ensure all tests pass 2. Check that code quality metrics improved 3. Review code to confirm readability enhanced 4. Document significant architectural changes if needed 5. Create clear commit messages describing refactorings ## Common Refactoring Scenarios **Scenario-specific guidance** is available for: - Legacy code modernization - Preparing code for new features - Performance optimization through refactoring - Reducing technical debt systematically - Extracting reusable components See [common-refactoring-scenarios.md](references/common-refactoring-scenarios.md) for detailed examples and approaches. ## Best Practices and Quality Guidelines Follow established principles for high-quality refactoring: - Apply SOLID principles (Single Responsibility, Open/Closed, etc.) - Reduce coupling between components - Increase cohesion within components - Eliminate duplication (DRY principle) - Maintain consistent coding standards **For comprehensive best practices**: See [refactoring-best-practices.md](references/refactoring-best-practices.md) ## Tools and Automation Modern IDEs and tools can automate many refactorings safely: - IDE refactoring features (IntelliJ, VS Code, Visual Studio) - Static analysis tools for code smell detection - Test coverage tools - Automated code formatting and linting **For tool recommendations and usage**: See [tools-and-automation.md](references/tools-and-automation.md) ## Output Format When presenting refactoring recommendations: 1. Identify the code smell or quality issue 2. Explain why it's problematic 3. Propose specific refactoring approach 4. Show before/after code examples 5. List tests to verify behavior preservation **For detailed output templates**: See [output-format.md](references/output-format.md)
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.