Agent skill
refactor
Usar al refactorizar código existente sin cambiar funcionalidad
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/refactor-eduardo-lezama-intranet-dashboard
SKILL.md
Cuándo usar esta skill
- Al mejorar estructura de código sin cambiar comportamiento
- Cuando se detecten code smells o duplicación
- Para aplicar patrones más limpios
Contexto necesario antes de empezar
- Leer el código a refactorizar completamente
- Identificar tests existentes (si los hay)
- Entender el comportamiento actual
- Definir qué se va a mejorar y qué NO se va a tocar
Pasos
1. Análisis
- Identificar el problema (duplicación, complejidad, naming, etc.)
- Verificar si hay tests que cubran el código
- Documentar comportamiento actual
2. Plan de refactor
- Listar cambios específicos a realizar
- Definir orden de cambios (de menor a mayor riesgo)
- Identificar puntos de verificación
3. Ejecutar refactor
- Hacer cambios incrementales
- Verificar después de cada cambio significativo
- Mantener commits pequeños y atómicos
4. Validación
ruff check .
ruff format --check .
python -c "from app import app"
pytest tests/ -v # si hay tests
5. Test manual
- Verificar que el comportamiento no ha cambiado
- Probar casos edge si aplica
<patrones_criticos> SIEMPRE:
- Leer tests antes de tocar código
- Verificar comportamiento antes y después
- Commits pequeños y descriptivos
- Mantener la API pública igual
NUNCA:
- Cambiar comportamiento durante refactor
- Eliminar código "muerto" sin confirmar
- Refactorizar y añadir features al mismo tiempo
- Ignorar tests que fallen
PREFERENTEMENTE:
- Extraer funciones/métodos pequeños
- Mejorar nombres para claridad
- Reducir anidación de código </patrones_criticos>
Refactors comunes en este proyecto
- Ordenar imports →
ruff check --fix . - Extraer lógica a cliente → Mover de
main.pya*_client.py - Eliminar duplicación → Crear función helper
- Mejorar error handling → Añadir logging consistente
Checklist de validación
- Comportamiento idéntico al original
-
ruff check .pasa - Tests pasan (si existen)
- La app arranca correctamente
- No se han tocado archivos fuera del scope
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?