# Refactoring Workflow

You are about to refactor code using the **Refactor Workflow**.

This workflow orchestrates 3 specialized agents:
1. **Architect** - Designs the refactoring approach
2. **Developer** - Implements the refactoring
3. **Reviewer** - Validates the changes

## Instructions

1. **Understand the refactoring goal** - Why refactor?
2. **Use the orchestrator MCP** to get workflow information:
   - Use `get_workflow_info` tool with workflowName: "refactor"
3. **Execute each workflow step manually**:

   ### Step 1: Design (Architect Agent)
   - Use `get_agent_info` for "architect"
   - Analyze current code structure
   - Design the refactoring approach
   - Identify risks and mitigation strategies
   - Create ADR if significant architectural change

   ### Step 2: Refactor (Developer Agent)
   - Use `get_agent_info` for "developer"
   - Implement the refactoring incrementally
   - Maintain test coverage throughout
   - Follow clean code principles
   - NO inline comments - make code self-documenting

   ### Step 3: Review (Reviewer Agent)
   - Use `get_agent_info` for "reviewer"
   - Validate improvements
   - Check test coverage maintained
   - Verify no behavior changes
   - Approve or request changes

## Required Information

Before starting, gather:
- **What to refactor** - Which code/module?
- **Why refactor** - What's the problem?
- **Goal** - What improvement are we seeking?
- **Constraints** - Any limitations?

## Common Refactoring Goals

- **Improve readability** - Make code self-documenting
- **Reduce complexity** - Simplify logic
- **Remove duplication** - Apply DRY principle
- **Improve structure** - Better separation of concerns
- **Enhance testability** - Make easier to test
- **Performance** - Optimize critical paths

## Important Notes

- **Tests must pass** - Before and after refactoring
- **Incremental changes** - Small, safe steps
- **No behavior changes** - Same inputs → same outputs
- **Maintain coverage** - Don't lose test coverage
- **Document WHY** - If architectural decision, create ADR

Now, ask the user what they want to refactor!
