refactoring-advisor

Analyze PHP/CakePHP code to identify refactoring opportunities with concrete file changes.

2|Updated Oct 19, 2025
One-click install
npx skills add https://github.com/masanao-ohba/claude-manifests --skill refactoring-advisor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring-advisor
Source: https://github.com/masanao-ohba/claude-manifests/tree/main/skills/php-cakephp/refactoring-advisor
Command: npx skills add https://github.com/masanao-ohba/claude-manifests --skill refactoring-advisor

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill identifies code smells, architectural weaknesses, and CakePHP-specific refactoring opportunities to improve maintainability, performance, and testability in PHP applications.

Core Features & Use Cases

  • Code smell detection: long methods, oversized classes, duplication, and cross-cutting concerns in controllers, models, and services.
  • Design-pattern guidance: Repository, Service, Factory, and Behavior extraction with concrete before/after examples.
  • Performance optimization: resolve N+1 queries, enable eager loading, implement caching, and modularize code for testability.

Quick Start

To use this skill, provide a CakePHP code snippet or describe observed symptoms; the skill will return a targeted refactoring plan with file structure changes and example code.

Frequently Asked Questions about refactoring-advisor

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

FAQPage Schema
How do I refactor long methods and large classes in CakePHP controllers?

To refactor long methods and large classes in CakePHP controllers, extract logic into dedicated services, behaviors, or repositories. This process breaks down oversized controllers into modular, testable components with clear separation of concerns and concrete implementation steps.

What is the best way to resolve N+1 queries and optimize PHP performance?

The best way to resolve N+1 queries and optimize PHP performance is to enable eager loading and implement targeted caching. Refactoring data access into repositories modularizes the code, significantly reducing redundant database calls and improving overall application speed.

How do I apply design patterns to fix code smells in PHP applications?

To fix code smells in PHP applications, apply design patterns like Repository, Service, Factory, and Behavior extraction. These patterns resolve duplication and complex dependencies by replacing tangled logic with structured, maintainable code snippets and concrete architectural changes.

Can I improve testability by extracting services and repositories from CakePHP models?

Yes, you can improve testability by extracting services and repositories from CakePHP models. Moving cross-cutting concerns and business logic out of models into isolated service classes reduces complex dependencies, making your PHP codebase significantly easier to unit test.

When do I need to restructure file structure for CakePHP refactoring?

You need to restructure file structure for CakePHP refactoring when facing duplicated logic or complex dependencies across controllers and models. Targeted refactoring plans provide concrete file structure changes and example code snippets to modularize code for immediate execution and better maintainability.

Does this refactoring approach work for both controllers and models in CakePHP?

Yes, this refactoring approach works for controllers, models, services, and repositories across typical CakePHP projects. It identifies architectural weaknesses and code smells throughout the entire PHP application structure to provide actionable guidance for improving maintainability and performance.