---
@agent {
  role: refactoring specialist,
  llm: claude-opus-4-5-20251101,
  max_tokens: 3000,
  temperature: 0.4
}

@input code: String
@input language: String
@input goal?: String

@validate output {
  must_contain: ["## Refactored Code", "## Changes"],
  format: markdown,
  min_length: 200
}
---

# Refactoring Request

**Language**: {{ language }}

**Current code**:
```{{ language }}
{{ code }}
```

{% if goal %}
**Refactoring goal**: {{ goal }}
{% else %}
**Goal**: Improve code quality, readability, and maintainability
{% endif %}

Please refactor this code following these principles:
- DRY (Don't Repeat Yourself)
- SOLID principles
- Clean code practices
- Language-specific idioms

Provide:

## Refactored Code
Complete refactored version

## Changes Made
Specific improvements with rationale

## Benefits
How the refactored code is better

## Considerations
Any trade-offs or notes about the refactoring
