From hatch3r
Internal code quality improvement workflow that restructures code and simplifies modules without changing external behavior. Use when refactoring to improve maintainability.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hatch3r:hatch3r-refactorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
> **Note:** Commands below use `npm` as an example. Substitute with your project's package manager (`yarn`, `pnpm`, `bun`) or build tool when your project uses a different package manager.
Note: Commands below use
npmas an example. Substitute with your project's package manager (yarn,pnpm,bun) or build tool when your project uses a different package manager.
Task Progress:
- [ ] Step 0: Detect ambiguity (P8 B1)
- [ ] Step 1: Read the issue, specs, and existing tests
- [ ] Step 2: Produce a refactor plan
- [ ] Step 3: Implement with behavioral preservation
- [ ] Step 4: Verify all tests pass, add regression tests
- [ ] Step 5: Open PR
Before any work, scan the invocation for unresolved questions in scope, intent, acceptance criteria, target environment, or irreversibility. If any are found, ask the user via the platform-native question tool per agents/shared/user-question-protocol.md. Do not proceed under silent assumption. Default path, not an exception. Triggers for THIS skill: refactor scope (one module vs cross-cutting), behavioral invariants to preserve, public API surface (preserved vs changed), test rewrite policy (preserve vs replace), and acceptable performance delta.
Fan-out scales with task size; token cost never justifies serializing independent work (rules/hatch3r-fan-out-discipline.md P8 B2; agents/shared/efficiency-patterns.md). Emit sub_agents_spawned: { count, rationale } in your output.
similar-implementation researcher output, read the reference implementations and their extracted conventions. The refactored code should align with these established codebase patterns.requirements-elicitation answers, use them to understand explicit user decisions on behavioral invariants and scope.Before changing code, output:
similar-implementation output), with divergences noted. If no reference was provided, note "using existing codebase conventions."${HATCH3R:VERIFY_GATE_ALL}
Resolved to the project's language-aware gate at sync time (fallback when detection is unknown: npm run lint && npm run typecheck && npm run test).
Use the project's PR template. Include:
Note: When this skill is invoked via the orchestration pipeline (board-pickup or workflow commands), skip this section — the orchestrator handles agent delegation in Phases 3 and 4.
You MUST spawn these agents via the Task tool (subagent_type: "generalPurpose") at the appropriate points:
hatch3r-researcher — MUST spawn before implementation with modes current-state, refactoring-strategy, migration-path. For Tier 2+ tasks (per hatch3r-deep-context), also include similar-implementation (refactors benefit most from convention alignment — ensures the refactored code follows established patterns) and requirements-elicitation. Skip only for trivially simple refactors (risk:low AND priority:p3).hatch3r-reviewer — MUST spawn after implementation for code review, verifying behavioral preservation.hatch3r-logical-refactor — use when the refactor changes internal logic flow while preserving external behaviorhatch3r-visual-refactor — use when the refactor targets UI/styling changes without altering functionalitynpx claudepluginhub hatch3r/hatch3r --plugin hatch3rRestructures existing code safely without changing external behavior. Uses context, design, architecture, and testing guardrails in a characterization-first workflow.
Orchestrates behavior-preserving refactors: confirm tests green, restructure in small steps, keep tests green, review, and gated commit. Use when structure should improve but behavior must not change.
Safely refactors code test-first: verifies/writes tests, one structural change at a time, preserves behavior. Use for 'refactor this', 'clean this up', reorganization.