| name | refactor |
| description | Refactor code with zero behavioral changes, preserving async semantics and shard affinity. Use when the user asks to restructure, extract, rename, move, or clean up code without changing what it does. |
| argument-hint | ["refactor-description"] |
I am REFACTORING:
$ARGUMENTS
Goal: [clarity / modularity / performance / testability]
Constraint: NO behavioral changes. Existing tests must pass unchanged.
Ref: .dev-context/claude-context.md for build constraints, architecture, coding conventions, and the Hard Rules.
PRE-REFACTORING CHECKLIST
Before Starting
Refactoring Type (select one)
| Type | Description | Risk Level |
|---|
| Extract | Pull code into new function/class | Low |
| Inline | Collapse unnecessary abstraction | Low |
| Rename | Improve naming clarity | Low |
| Move | Relocate to better module | Medium |
| Restructure | Change internal organization | Medium |
| Async Refactor | Modify future chains | High |
SEASTAR-SPECIFIC CONCERNS
Async Boundary Preservation
Shard Affinity
Lifetime Management
Comment Hygiene (see claude-context.md)
REFACTORING PROCESS
Step 1: Document Current Behavior
For each function being refactored:
Function: [name]
Purpose: [what it does]
Inputs: [parameters and preconditions]
Outputs: [return value and postconditions]
Side Effects: [state changes, I/O]
Async Behavior: [future semantics, shard interactions]
Step 2: Plan the Changes
List each mechanical transformation.
Step 3: Execute with Verification
After each transformation:
OUTPUT FORMAT
Changes Summary
| File | Change Type | Description |
|---|
src/foo.cpp | Extract | Pull validate_input() into helper |
src/foo.hpp | Rename | process() -> process_request() |
Behavioral Equivalence Proof
Function: [name]
Before: [behavior description]
After: [identical behavior description]
Why Equivalent: [mechanical transformation / logic preserved because...]
Risk Assessment
Deferred Gates
Compilation and tests cannot run in this sandbox. Provide the developer:
make test-unit # all tests must pass UNCHANGED
./scripts/lint-seastar-async.sh # if any seastar::async sites were touched
Finish with /review before committing.