rector

Enforces dry-run-only Rector refactoring conventions for Laravel projects via Docker.

Updated Aug 25, 2017
One-click install
npx skills add https://github.com/loki495/dotfiles --skill rector-loki495
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rector
Source: https://github.com/loki495/dotfiles/tree/main/ai/skills/rector
Command: npx skills add https://github.com/loki495/dotfiles --skill rector-loki495

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rector can silently rewrite PHP code across an entire Laravel codebase, and auto-applying its output without review risks breaking changes. This Skill enforces a safe workflow: always dry-run first, review the diff, and only apply after explicit confirmation. ## Core Features & Use Cases - Dry-run enforcement: Mandates running rector process --dry-run before any changes, with pre-commit hook integration that blocks commits when dry-run finds diffs. - Docker-based execution: Standardized commands for running Rector inside project containers, with support for composer script shortcuts. - Reference configuration: Provides the stocker project's rector.php as a template covering PHP 8.3 upgrades, code quality, dead code removal, and name importing. - Use Case: Before modernizing a Laravel app's PHP syntax, run the dry-run, show the diff to the team lead, and apply only the approved changes. ## Quick Start Ask the AI to run a Rector dry-run on the Laravel project inside its Docker container and show the proposed diff before applying anything.

Frequently Asked Questions about rector

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

FAQPage Schema
How do I run Rector safely on a Laravel project?▼

Always start with `docker exec <container> ./vendor/bin/rector process --dry-run` to preview changes without modifying files. Review the diff with the team, then run without `--dry-run` only after explicit confirmation.

What Rector sets should I use for Laravel PHP upgrades?▼

Use `LevelSetList::UP_TO_PHP_83` for safe syntax modernization, plus `SetList::CODE_QUALITY` and `SetList::DEAD_CODE`. Enable `importNames()` with `importShortClasses(false)` to reduce noise from single-segment class names.

Can I run Rector on OpenCart projects?▼

No, Rector should not run on OpenCart paths because it does not understand the registry-based dependency injection pattern and produces incorrect refactors. Only run it if the project's `.claude/project.md` explicitly opts in.

Why does the pre-commit hook block my commit after Rector?▼

The hook runs a Rector dry-run and blocks the commit when it finds pending changes. Review the reported diff, apply the changes deliberately with a confirmed non-dry-run execution, then re-commit.

Should I enable Rector STRICT_MODE on my project?▼

Avoid `SetList::STRICT_MODE` unless the project already passes PHPStan level 9 or higher, since it introduces breaking changes. Only add it when explicitly requested by the team.