Amo Refactor
Plan structural changes when boundaries, ownership, or coupling are the primary problem.
Shared Output Marker
Prefix the first output line inline with 🧱 [amo-refactor]. Do not put the marker in a separate paragraph.
Use When
- The user asks whether code should be refactored or how to refactor it.
- Module boundaries, component boundaries, state ownership, data flow, or architecture are unclear.
- Complexity or coupling makes the next change risky or hard to reason about.
Do Not Use
- The primary goal is new behavior; use
amo-feature.
- The primary goal is changing existing behavior; use
amo-improve.
- The primary goal is fixing broken behavior; use
amo-fix.
- A proposed refactor needs challenge; use
amo-best.
Best Standard
Select and state one before recommending a refactor:
- Target-state best: default for development-stage work when no explicit constraint is stated; prioritize correct boundaries, long-term maintainability, refactoring when needed, and not bending the design around legacy implementation.
- Constraint best: use when the user requires fast delivery, compatibility, minimal change, short-term delivery, or limited scope.
- Evolutionary best: use when the target boundary is right, but should be delivered in safe, staged steps.
- Lowest-risk best: use when production, data, security, auth/permission, payment, migration, or rollback risk dominates.
Workflow
- Identify the structural pressure: ownership, coupling, size, duplication, or unclear flow.
- Select the best standard and explain why.
- Inspect current boundaries, dependencies, and behavior-preservation constraints.
- Define the target boundary and responsibilities.
- Recommend one scoped refactor with tradeoffs and verification.
Key Rules
- Refactor only when structure is the problem, not because code merely looks imperfect.
- Ownership boundary before patch.
- Preserve behavior unless the user explicitly asks to change it.
- Do not add speculative compatibility paths, fallback branches, or legacy handling without evidence from the codebase or explicit user requirements.
- If implementation reveals a better approach, pause and explain before switching.
Output
Use the user's language for output labels and content.
🧱 [amo-refactor] Scenario: refactor / architecture boundary
Best standard:
Structural issue:
Target boundary:
Recommended approach:
Tradeoffs:
Impact scope:
Verification:
Next: use amo-best for second-pass pressure testing if needed
1---2name: amo-refactor3description: Use when the user asks how to refactor, split modules, clarify architecture, move ownership, reduce coupling, or fix unclear state, data-flow, or component boundaries before coding. Do not use for ordinary feature work, bug fixes, or second-pass solution challenges.4---56# Amo Refactor78Plan structural changes when boundaries, ownership, or coupling are the primary problem.910## Shared Output Marker1112Prefix the first output line inline with `🧱 [amo-refactor]`. Do not put the marker in a separate paragraph.1314## Use When1516- The user asks whether code should be refactored or how to refactor it.17- Module boundaries, component boundaries, state ownership, data flow, or architecture are unclear.18- Complexity or coupling makes the next change risky or hard to reason about.1920## Do Not Use2122- The primary goal is new behavior; use `amo-feature`.23- The primary goal is changing existing behavior; use `amo-improve`.24- The primary goal is fixing broken behavior; use `amo-fix`.25- A proposed refactor needs challenge; use `amo-best`.2627## Best Standard2829Select and state one before recommending a refactor:3031- **Target-state best**: default for development-stage work when no explicit constraint is stated; prioritize correct boundaries, long-term maintainability, refactoring when needed, and not bending the design around legacy implementation.32- **Constraint best**: use when the user requires fast delivery, compatibility, minimal change, short-term delivery, or limited scope.33- **Evolutionary best**: use when the target boundary is right, but should be delivered in safe, staged steps.34- **Lowest-risk best**: use when production, data, security, auth/permission, payment, migration, or rollback risk dominates.3536## Workflow37381. Identify the structural pressure: ownership, coupling, size, duplication, or unclear flow.392. Select the best standard and explain why.403. Inspect current boundaries, dependencies, and behavior-preservation constraints.414. Define the target boundary and responsibilities.425. Recommend one scoped refactor with tradeoffs and verification.4344## Key Rules4546- Refactor only when structure is the problem, not because code merely looks imperfect.47- Ownership boundary before patch.48- Preserve behavior unless the user explicitly asks to change it.49- Do not add speculative compatibility paths, fallback branches, or legacy handling without evidence from the codebase or explicit user requirements.50- If implementation reveals a better approach, pause and explain before switching.5152## Output5354Use the user's language for output labels and content.5556```text57🧱 [amo-refactor] Scenario: refactor / architecture boundary58Best standard:59Structural issue:60Target boundary:61Recommended approach:62Tradeoffs:63Impact scope:64Verification:65Next: use amo-best for second-pass pressure testing if needed66```