Programación

Refactor con tests que protejan el comportamiento

Mejora el diseño sin romper nada.

Resultado esperado
Plan de refactor con tests antes de tocar código.
Herramientas compatibles
ChatGPT, Claude, Copilot, Any AI
Dificultad
Avanzado
Tiempo ahorrado estimado
3 h

Personaliza tu prompt

Rellena los campos para adaptarlo a tu situación.

Vista previa

Act as a staff engineer. I want to refactor this code. Reply in English.

Stack: {{stack}}
What the code does today: {{behavior}}
Why I want to refactor: {{reason}}
Code:
"""
{{code}}
"""

Do this in order:
1. Restate the current behavior so we're aligned
2. Write the characterization tests I should add first (before refactoring) — real assertions, not TODOs
3. Propose 2 refactor paths (small vs. bigger) with trade-offs
4. Pick one and give the step-by-step commits
5. After the refactor, what new tests to add
6. Risks to watch in production the first week

El contenido del prompt está en inglés. Usa la variable de idioma para elegir el idioma de la respuesta de la IA.

Consejos de uso

  • Merge the characterization tests separately BEFORE the refactor commit.

Errores a evitar

  • Refactoring and 'improving' at the same time — you can't tell what broke.