General · apply by default
/refactor
Improve structure while preserving behavior
Use for structural change with preserved behavior; migrate changes a version or public compatibility boundary and cleanup removes verified dead code.
Make it your own.
In Claude Code, use the slash command and add your context. In Codex, select refactor from the just-vibe skill picker, then send the same brief.
Version 0.11.0 also supports /jv refactor, /just-vibe refactor and /jv:refactor in Claude. See shortcut setup and context examples.
/just-vibe:refactor Separate validation from persistence without changing the public API./just-vibe:refactor Extract a service without changing exception types or serialized output./just-vibe:refactor Assess a refactor when integration tests cannot run; identify unverified contracts.What the agent does
- Capture the current behavior as a baseline and identify public exports, serialization and error contracts.
- Transform one seam at a time, preserving call contracts, and compare behavior against the baseline and existing consumer checks after each step.
- For a multi-phase feature, fix, refactor or MVP, use the relevant phase contract in the composed-workflows guide. Keep simple work direct. Delegate only when authorized, and use the reviewed worker result and acceptance flow before dependent work. Offer the plan-review canvas only when browser feedback is useful or requested.
Inputs
- structural goal, target modules, and behavior/API constraints. Requires source and a baseline verification method.
Optional context: scope, references, constraints, successCriteria, environment, mode, budget.
Scope
- Reads
- Internal organization with preserved observable behavior; feature changes are separate.
- Writes
- Apply: only the requested local changes and relevant isolated verification. Inspect/plan requests remain inspection/planning. External actions require their exact action and target in session authorization.
- Mode
- Apply; structural goal, target modules, and behavior/API constraints. Requires source and a baseline verification method.
- Prerequisites
- Resolve the user brief and inspect the relevant project or supplied evidence. External capabilities are optional unless the selected action actually needs them.
Expected output
- Focused structural changes with their rationale, the compatibility surface, checks showing preserved behavior, and remaining debt.
How the work is checked
- Existing consumers continue to work; boundary/error behavior survives the reorganization.
When to stop or clarify
- If behavior is undocumented, characterize it before changing it. Do not fold a semantic fix into the refactor without naming the scope change.
Handling missing context
- Infer
- Resolve the named files, existing scripts, current task and earlier corrections from the conversation and repository.
- Assume
- Use the narrowest interpretation that completes a reversible local task; state a consequential assumption once.
- Ask
- Ask when competing targets or incompatible success conditions would change the result; continue independent inspection first.
Technical guidance
- Evidence
- Identify public contracts, state ownership, side effects and behavior-sensitive tests.
- Method
- Change structure in coherent steps while preserving observable semantics, including error and timing contracts.
- Pitfall
- Renaming a pure helper differs from moving async ownership or transaction boundaries; both cannot use the same evidence bar.
- Check
- Compare representative success/failure behavior before and after and inspect callers for changed ordering or identity semantics.
Situational decisions
When code appears unused but is registered dynamically: Trace registration and configuration before deleting or moving it.
The coding agent follows this workflow using its available tools. Installation does not grant service access or guarantee an outcome. Read the compatibility notes.