Structured refactoring pipeline — analyze target code, propose changes with before/after examples, plan, execute with regression coverage. Use when improving existing code without changing behavior.
From zenflownpx claudepluginhub brewpirate/zen-flow --plugin zenflowThis skill uses the workspace's default tool permissions.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Enables AI agents to execute x402 payments with per-task budgets, spending controls, and non-custodial wallets via MCP tools. Use when agents pay for APIs, services, or other agents.
Structured approach to improving existing code without changing behavior. Analyzes the target, proposes the refactor with concrete before/after examples, creates a plan with regression test coverage, then executes.
Announce at start: "I'm using the zenflow:refactor skill to improve this code."
<HARD-GATE> Refactoring MUST NOT change **external** behavior — observable outputs, public API contracts consumed by code outside this repository.Internal API changes are allowed if all callers are updated in the same scope. Examples:
If external consumers exist (npm package, REST API, CLI flags), signature changes are NOT a refactor — use zenflow:idea instead. </HARD-GATE>
Determine what to refactor. The user may specify:
If vague ("refactor the auth module"), explore the code first:
For the identified target:
Present the refactor proposal to the user with:
Before/After examples — concrete code showing the transformation:
### Change 1: Extract shared validation logic
**Before** (duplicated in 3 files):
{code snippet from file A}
{code snippet from file B}
**After** (shared helper):
{proposed helper function}
{updated call site}
**Files affected:** fileA.ts, fileB.ts, fileC.ts, new: shared/validation.ts
Impact assessment:
Risk areas:
Ask: "Does this refactor plan look right? Any changes?"
Before making any changes:
This is non-negotiable. Refactoring without tests is just rearranging.
Two options based on scope:
Small refactor (1-3 files): Execute directly in this session.
Large refactor (4+ files): Invoke zenflow:plan to create a detailed plan, then zenflow:dispatch to execute.
After refactoring is complete:
When: Same logic in 2+ places, or a function does too many things. How: Pull the shared/excess logic into a named function. Update all call sites.
When: A function just wraps another call with no added value. How: Replace call sites with the direct call. Delete the wrapper.
When: Name doesn't match what the thing does. How: Rename with LSP (find all references), update tests, update docs.
When: A file has grown beyond one clear responsibility. How: Identify responsibility boundaries, create new files, move code, update imports.
When: Complex switch/if-else blocks that grow with each new case. How: Extract to discriminated union or strategy pattern.
When: Function has 3+ positional parameters (per project conventions). How: Replace with single options object, update all call sites.
Stop and reassess if:
Never: