implementer:refactor

Refactor code iteratively with tests and PHPStan static analysis.

Updated Feb 24, 2026
One-click install
npx skills add https://github.com/atournayre/claude-personas --skill implementer-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implementer:refactor
Source: https://github.com/atournayre/claude-personas/tree/main/implementer/skills/refactor
Command: npx skills add https://github.com/atournayre/claude-personas --skill implementer-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill automates the process of refactoring code by integrating automated testing and static analysis, ensuring code quality and maintainability without manual oversight.

Core Features & Use Cases

  • Automated Refactoring Loop: Iteratively applies code transformations (method extraction, renaming, simplification) while running tests and PHPStan.
  • Test-Driven Refactoring: Ensures that all tests remain green throughout the refactoring process.
  • Use Case: Improve the design of a complex legacy function by extracting smaller, more manageable methods, ensuring that existing functionality remains intact and bug-free.

Quick Start

Use the implementer:refactor skill to refactor the file src/Service/UserService.php, focusing on simplifying conditional logic.

Frequently Asked Questions about implementer:refactor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate PHP code refactoring while keeping tests green?

Automated PHP code refactoring iteratively applies transformations like method extraction and condition simplification while running tests and PHPStan to ensure code integrity. This loop maintains green test status and acceptable static analysis error levels throughout the process.

What is the best way to simplify complex legacy PHP code safely?

Safely simplifying complex legacy PHP code involves an iterative refactoring loop that applies targeted transformations to specific files while continuously verifying functionality through automated testing and static analysis. This ensures existing logic remains intact without manual oversight.

Can I use PHPStan to maintain error levels during refactoring?

Yes, PHPStan is integrated directly into the refactoring loop to enforce acceptable error levels during code transformations. The automated process performs static analysis after each change to prevent new errors from being introduced.

How do I extract methods and rename variables without breaking existing functionality?

Extracting methods and renaming variables safely requires running automated tests after each transformation to verify existing functionality. The refactoring loop continuously checks test status to ensure all modifications remain green and bug-free.

Does automated refactoring work on specific files or entire directories?

Automated refactoring can target specific files or entire directories for code improvements. You can focus the transformations on a single complex service file or apply method extraction and condition simplification across a broader project scope.