plugins/php-fixer/skills/php-auto-fixer/SKILL.md
CRITICAL: Read BEFORE writing or modifying any PHP file. A PostToolUse hook automatically runs nette/coding-standard (ECS) on every PHP file after each Edit or Write. The fixer removes unused `use` statements - so never add `use` statements in a separate edit before the code that references them. Always include `use` imports in the same edit as the referencing code, or add the code first then `use` statements. This skill should be used whenever creating new PHP files, editing existing PHP code, adding methods, refactoring, or fixing bugs in PHP - even for small one-line changes.
npx skillsauth add nette/claude-code php-auto-fixerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A PostToolUse hook runs ecs fix on every PHP file after each Edit or Write operation. The file is automatically reformatted and cleaned up - no manual formatting needed.
use StatementsThe fixer removes any use statement not referenced in the file. This creates a timing trap between consecutive edits:
use App\Model\Foo;Foo is not used anywhere → removes the use statementFoo → fails because the use is goneAlways add use statements in the same Edit as the code that references them. Alternatively, add the code first, then add the use statement in a follow-up edit.
Never add use statements alone in a separate Edit - they will be removed before the next edit adds the referencing code.
Single edit with both use and code (preferred):
use App\Model\UserRepository;
public function getUsers(UserRepository $repo): array
{
return $repo->findAll();
}
Code first, use second (also safe):
UserRepositoryuse App\Model\UserRepository; - now it's referenced, fixer keeps ituse first, code second (broken):
use App\Model\UserRepository; - fixer removes this immediatelyUserRepository undefinedWhen adding code that references several new classes, include all their use statements in the same edit. Do not split use statements and code across separate edits.
use statementsuse statements alphabeticallyDo not manually fix formatting - the fixer handles it automatically after every edit.
use statements manually - the fixer handles unused importsuse statements manually - the fixer sorts themThe hook exits with an error when ECS cannot auto-fix all issues. Common causes:
If the fixer is not installed, run /php-fixer:install-php-fixer.
development
Install nette/coding-standard globally for PHP code style checking
tools
Invoke when fetching web pages from localhost, debugging PHP errors, or interpreting Tracy output (BlueScreen, Tracy Bar, dump). Read BEFORE running curl or Chrome to any local development PHP URL – with Tracy >= 2.12 and a detected agent, Tracy mirrors BlueScreen, Tracy Bar and dumps as markdown into the JS console for easy machine reading. For Chrome MCP, call list_console_messages() to read Tracy output. Essential when: 500 error, blank page, PHP exception, slow page, N+1 queries, or inspecting variables with dump().
tools
Provides Nette Utils helper classes. Use when working with Arrays, Strings, Image, Finder, FileSystem, Json, Validators, DateTime, Html element builder, Random, Callback, Type, or SmartObject from nette/utils. Do NOT use for Nette Schema, Nette Forms, Nette Database, Latte filters, or DI configuration.
development
Use this skill whenever writing, modifying, or running .phpt test files with Nette Tester. Invoke for any task involving Tester\Assert methods (Assert::same, Assert::match, Assert::exception, etc.), test bootstrap setup, vendor/bin/tester commands, or debugging failing test output (.expected/.actual files). Also use when the user needs to write tests for a Nette project and asks about test structure, the test() function, testException(), or assertion methods. This skill is specifically for Nette Tester – do not use for PHPUnit, Pest, Jest, Vitest, or other testing frameworks, and do not use for general PHP testing without Nette context.