
php-fixer
- GitHub stars
- 47
Install
/plugin install php-fixer@netteRun it inside Claude Code after adding the marketplace with /plugin marketplace add nette/claude-code.
Contents
Discovered from sourceSkills 4
DressCode
DressCode checks and fixes the style of PHP code and, in the same run, rewrites it for newer PHP versions and library APIs. It works on a lossless syntax tree, so the lines nothing touches stay byte for byte the same. The php-fixer hook already runs it on every PHP file you edit (the php-auto-fixer skill); this skill is about running it yourself and changing what it does.
The manual is at https://dresscode.run (see Documentation), but the installed tool describes itself more precisely, for exactly its version and this project's configuration (see Ask the Tool).
How It Thinks
- The configuration names decisions, never rules. Every key is a thing in the code and its value says how it is written:
braces: {position: {class: nextLine}},spacing: {call: 'foo($a, $b)'},hygiene: {is_null: forbidden}. A decision has a path (braces.position.class), and that path is what a finding is reported under, whatexplainexplains and what a suppression names. The rules behind the decisions are never named. - It has no style of its own. Without a configuration file or
--use <standard>it refuses to run. The look of the code comes from one standard:perCs(PER Coding Style 3.1, four spaces),psr12,nette(PER Coding Style with tabs, the layout of the Nette libraries and much of the hygiene),symfonyorlaravel(the preset laravel of Laravel Pint). - Sets say what is wanted beyond the looks, and there are exactly six:
modernizations,deprecations,cleanup,correctness,types,compilerOptimizations. A set goes intouseafter the standard (use: [nette, modernizations]) and decides nothing about the layout. A decision the project cannot use yet (its PHP is too old, it needs types, the library is missing) waits silently. No standard usesmodernizationsordeprecations. - Two PHP versions. DressCode itself needs PHP 8.4 or newer. The version the code is written for is the lowest one
require.phpincomposer.jsonallows, and no fix writes syntax that version lacks. The header lineTarget PHP 8.2 from composer.jsonsays which one applies. - A risky fix may change what the code does. It is never made without consent; DressCode reports it together with what would decide it.
- The configuration is searched from the working directory upwards, not from the checked files. Run DressCode from the project root, or name the file with
--config.
Running It
Use the project's vendor/bin/dresscode when there is one: only that copy sees the project's PHPStan and rule packages. Otherwise use the global one, dresscode on the PATH or php "<composer global config home>/vendor/bin/dresscode". Run it as php vendor/bin/dresscode … from the directory holding dresscode.neon. When DressCode is not installed, tell the user; installing it is their decision, and the user can run the install-php-fixer skill for it.
| command | what it does |
|---|---|
check [paths] | reports violations, writes nothing |
check --diff [paths] | shows what fix would change, writes nothing |
fix [paths] | fixes what it can and reports the rest |
config [--file <path>] | the decisions as the run resolves them, in the shape of the file, each with the layer that set it and why it takes no effect where it does not |
explain [path] | what a decision or a section is for, its values, its value here and in the five standards; every decision the configuration makes without a path |
catalogue | every decision there is, those the configuration makes marked *, with the names of other tools each covers |
init | measures the project's code and writes dresscode.neon |
baseline [paths] | writes the violations a fix leaves into the baseline file |
migrate config [file] | translates a PHP CS Fixer, PHP_CodeSniffer or Laravel Pint configuration, without a file the one the project runs; what was not carried over is said in a block closing the file, the run ending with exit code 0 all the same, --dry-run prints the file instead of writing it, --format json gives the result as data |
migrate suppressions [paths] | rewrites phpcs: suppression comments to dresscode:; --dry-run shows the diff instead, --format json gives the result as data |
Without paths, a command takes paths of the configuration; a directory containing configured paths is narrowed to them.
Exit codes: 0 clean; 1 violations remain (also a file that does not parse, a refused baseline, or more warnings than --max-warnings), which is a finding, not a failure of the tool; 2 a file failed (a rule threw, rules did not converge, the file changed during the fix); 3 a mistake on the command line or in the configuration (unknown key or decision, no configuration); 4 an upgrade waits for a step outside DressCode, Composer or a human. Judge a run by its exit code, never by filtering its output.
Switches for one run, none of which touches the configuration file:
--set <path>=<value>sets a decision, the value in NEON:--set hygiene.is_null=forbidden,--set file.lineLength=100.--use <name>adds a preset (a standard or a set) or a plugin over the configuration, or names the standard where there is no configuration:--use psr12,--use modernizations.--severity <name>=<warning|error>says how the violations of a decision, a section, a preset or a rule count:--severity file.longLines=warning.--only <name>narrows the run to a decision, a section or a preset, without changing any value: what it rewrites still comes out in the project's style, and it never brings back a decision the project left atkeep.typesis both a section and a set, so it is writtentypes.*for the section ordresscode/typesfor the set; the bare name is refused.--fix-risky[=<name>]allows risky fixes, all of them or those of one decision, section or preset.--no-cacheprocesses every file,--format jsongives a document to parse.
Ask the Tool
dresscode explain <path>: what a decision wants, the values it takes, its value here with the layer that set it, and its page. Ask it before you change a decision or argue with a violation.explain <section>(explain blankLines,explain upgrading) lists every decision of a section.dresscode check --diff --set <path>=<value> --only <path> <file>: what a decision would do to a file, also one the project does not make.dresscode config: the truth about the configuration. After every change of it, run this and check that the decision shows the expected value;config --file <path>includes the overrides of that file. A decision that takes no effect says why (no effect: php,no effect: types).dresscode catalogue: the path of a decision you know as a rule of PHP CS Fixer or PHP_CodeSniffer (single_quoteisliterals.quotes).dresscode <command> --help: the switches of the installed version.
Documentation
Each decision of the core has a page at https://dresscode.run/decisions/{path} (https://dresscode.run/decisions/braces.position.class), with examples of the code each value wants. Read it when explain is not enough, or when DressCode is not installed. A decision of a package has its page where the package says, which explain prints.
Other pages of https://dresscode.run worth knowing:
decisions/: every decision, by sectionpresets-reference: whatperCs,psr12,nette,symfony,laraveland the six sets decideconfiguration,cli,suppressing: the configuration file, the command line, suppressions and the baselineupgrading-php,upgrading-libraries,types,namespaces: the upgrades, the types from PHPStan and the resolution of namestroubleshooting: why a run is clean when it should not be, and what the messages mean
What Needs the User's Consent
fixover more than the files of your task.checkis always safe. A project-wide fix belongs in a commit of its own from a clean working tree; offer it, do not run it unasked.- Accepting risky fixes: an entry in
fixRisky, or--fix-risky. - Setting a decision to
keep, silencing a finding in the code, or writing a baseline. Never silence or baseline violations your own change introduced; fix them. - Raising
require.phpincomposer.json, which turns on the decisions of a newer PHP across the project. - Installing anything: DressCode, PHPStan, a rule package.
After a fix run through the shell, read again every file it reported as rewritten before editing it: the hook only reports its own runs, and an edit built on the old content fails or undoes the fix. fix --format agent over the files of your task tells you instead what it changed in each, as a diff, and what is left, as the hook does.
fix --ask-risky, which asks about each risky fix, needs an interactive terminal; you cannot run it, so suggest it to the user.
Reading the Report
src/Cart.php
error 8:47 Expected a line break after the opening brace. braces.position.function
Then also, on line 9: Expected the statement indented by 3 tabs, 2 tabs found. indentation.unit
risky 9:10 The `in_array()` call must pass `$strict = true`. mistakes.strictArgument
Risky because a strict search no longer finds a value of another type.
warning 17:10 A plain string must be written with single quotes. literals.quotes
1 risky fix waits, the type is unknown: set `typeAnalysis: phpstan`. See https://dresscode.run/types#enable
FOUND 28 violations, 9 of them following from others, 2 warnings, a fix leaves 1 in 12 of 214 files
- Each violation gives the line and column, what the code should look like, and on the right the path of the decision it breaks. That path is all you need to change the decision, explain it or silence it.
- The summary says how many violations a fix leaves; only those need you or the user.
- An indented
Then also:under a violation is what only fixing it brings about; it is settled together with it. fixlists each file it changed withrewrittenand below it what the fixed text still violates, with positions in the fixed file.riskymarks a fix waiting for consent, withRisky because …under it. One the types ornameResolutionwould decide counts as a warning; one only a person can decide counts as an error.warningmarks a decision thatseveritymakes only warn (file.longLinesinperCsandpsr12); warnings do not change the exit code unless--max-warningsis exceeded.
A risky fix waiting for consent is counted above the summary by what would decide it:
- "the type is unknown: set
typeAnalysis: phpstan": the types PHPStan knows would decide the fix. ProposetypeAnalysis: phpstanto the user (see the configuration reference); it needsphpstan/phpstaninstalled beside DressCode, which is again the user's decision. When the line says "check them withfix --ask-risky" instead, the types are on and do not tell, or PHPStan is missing. - "a name may reach a function of the namespace": an unqualified
is_null()in a namespace could be a function of that namespace.nameResolution: certain, with thenamespaceslists of what the project declares, removes the doubt;dresscode initmeasures the lists. Propose it. - "changes what the code does": only the user can decide. Show the effect with
dresscode check --fix-risky --diff, which writes nothing, and with their consent runfix --fix-risky=<path>, add the decision tofixRisky, or mark a place that must stay as it is withdresscode:ignore.
Violations a Fix Leaves
Some violations need a person: a class name in the wrong case (its users would have to change too), a line too long to break. Fix them by hand. Where the decision is wrong at that one place, silence that occurrence by its path and say why after --:
$isEmpty = $value == null; // dresscode:ignore expressions.comparison.loose -- null and '' both mean no value here
- At the end of a line it covers that line; on a line of its own, the whole construct starting on the next line (a statement, a member, a single array item or argument).
- A section or a structure covers every decision under it (
dresscode:ignore upgrading). Several paths are separated by commas. Without a path it silences everything; avoid that. // dresscode:disable <path>…// dresscode:enablecovers a block,// dresscode:ignoreFilea file,keepin an override a path of the project.- A silenced violation is not fixed either.
- A path that names no decision silences nothing, and the run says so. The comments
phpcs:ignoreand the like, with the rule names of PHP_CodeSniffer, are understood too, anddresscode migrate suppressionsrewrites them to paths.
Baseline
A baseline lets a project adopt a decision its code does not meet yet: the recorded violations stay quiet and every new one is reported. It holds only what a fix leaves, so the order is fixed:
dresscode fix;baselinerefuses (exit1) while a fix would still change something.dresscode baselinewritesdresscode-baseline.neonbeside the configuration.baseline: dresscode-baseline.neonin the configuration makes it apply.
OK 312 violations in the baseline in 214 files means the violations are there, only recorded. A warning that entries of the baseline no longer match a violation means some got fixed; run fix and generate the baseline again. Regenerating it to swallow violations of new code defeats it.
Configuration
A minimal dresscode.neon in the project root:
use:
- nette
- modernizations
paths:
- src
- tests
What else goes there, with the layering of presets, overrides and the command line, is in the configuration reference. The mistakes to avoid:
- Every name is camelCase: keys, sections, decisions, presets and the words of values (
lineLength,nextLine,perCs), except a decision named after a PHP function, class or method (hygiene.is_null,upgrading.classes.Override,mistakes.__serialize). - The keys of the former models are errors now:
presets,extends,groups,plugins,ruleswith rule names,types,indent,lineLength,lineEnding,warnOnly, the sectionscleanupandcorrectness, and a rule name as a key. The standard, the sets and the plugins go touse, the types totypeAnalysis, the style to its decisions (indentation.unit,file.lineLength,file.lineEnding), warnings toseverity; the former sections arehygieneandmistakes, while the setscleanupandcorrectnesskeep their names.rulesremains only for a rule class of the project itself. - A rule name of another tool (
no_unused_imports) is no key;cataloguegives its decision, anddresscode migrate configtranslates a whole foreign configuration. - Values: a presence is
required,forbiddenoroptional; a shape is its example in single quotes (spacing: {call: 'foo($a, $b)'}, unquoted NEON would read it as an entity); a list of words or shapes is a tolerance, each passing and the first written (multiline: {edges: {array: [apart, attached]}});yesandnoonly for a parameter (upgrading.packages: yes). A word on a group applies to every key under it that takes it (multiline: {trailingComma: required}). keepleaves a thing alone: on a decision it stops enforcing it, on a section or a structure every decision under it. There is nofalseoroff.- A decision taking a list (
mistakes.debugOutputFunctions) replaces the list below it, its default included, unless the list holds..., which stands for the list below ([..., dump]); a map (upgrading.api.replacedClasses) merges by name,name: keepwithdraws an entry, and!after the key (replacedClasses!:) replaces the maps below. netteis two things: the standard inuse, and the section of the decisions of the packagedresscode/upgrade-nette(nette: {linkArguments: required}). A decision of a package always lives under the section its plugin names, and the plugin loads only whereusenames its package (use: [nette, upgrade-nette]), or indresscode upgrade.- A part of the project that needs different values gets an entry in
overrides, not a decision turned off everywhere. - An existing configuration is the project's: change it only as asked, never write a new one over it.
A project without a configuration: ask the user which standard to follow, or run dresscode init, which measures the indentation, the quotes and the shape of conditions from the code and writes the file (the standard a fix would change the fewest files under unless --use names another, for a project formatted by Laravel Pint the standard of its Pint preset). --dry-run prints it instead, and --format json takes the recommended answers and gives the proposal as data, the lines of dresscode.neon answering what it would ask among it. It never overwrites an existing configuration.
Upgrading PHP and Libraries
With the set modernizations, DressCode rewrites code for what the target PHP version brought (str_contains(), ?->, match, array_any(), the pipe operator…); with deprecations, it rewrites what PHP or a library deprecated, the libraries described by upgrade packages such as dresscode/upgrade-nette. The procedure, the risky parts and the library packages are in the upgrading guide; read it before such a task.
CI and Git Hooks
- CI runs
dresscode check, notfix. On GitHub Actions the output turns into annotations by itself; elsewhere--format checkstyleor--format json. WithtypeAnalysis: phpstan, run the check in CI with--no-cache. - A pre-commit hook passes the staged files:
dresscode check --format lines --skip-excluded <files>.linesprints nothing when clean and one line per finding otherwise (path:line:col: severity: message [decision]), and--skip-excludedkeepsexcludePathsworking for files named on the command line.git show :<file> | dresscode check --stdin <file>checks the staged content instead of the working tree.
When Something Is Off
- "No
dresscode.neonordresscode.phpfound": run it from the project root or pass--config; if the project really has none, see Configuration. - "No paths given and none configured": name the paths, or set
paths. - Clean when it should not be: the summary says the violations are in the baseline; the file is excluded (by default
vendor,node_modules,temp,tmp,logand everything starting with a dot, plusexcludePaths); the decision takes no effect, anddresscode configsays why after it (keep,no effect: php,no effect: types, a missing package) or does not list it because nothing decides it;severitymakes the decision only warn (configsaysonly warns), which keeps the exit code at0; a suppression comment covers it; or the cache skipped the file, for example afterphpstan.neonor a class other files use changed, so run with--no-cache. - "Decision … needs PHP >=8.3 and the target is >=8.2; skipped": the target comes from
composer.json; settargets: {php: '8.3'}only when the code is written for another version or the header says it could not read one. - "Key … is unknown": a typo, a foreign name or a key of the former model; the message suggests the right one where it knows it.
- "Decision … needs the types of the code" (exit
3): a decision the project wrote needstypeAnalysis: phpstanand PHPStan installed beside DressCode. - "The command line: Unknown preset
literals.quotes": a decision is set with--set path=value;--rule,--groupanddresscode rulesno longer exist. - "Package … brings the plugin …, which loads only where
usenames the package or the plugin; skipped": add the package tousewhen its rules are wanted; its upgrading data apply without it. - "Name
typesis both a section of decisions and the presetdresscode/types": in--only,fixRiskyorseverity, writetypes.*for the section ordresscode/typesfor the set. - "Key … does not take
adopted; writerequiredorkeep": a value of the former vocabulary (adopted,replaced,warningas a value); the message names the words the decision takes. - "The file changed while it was being fixed" (exit
2): something else saved it; runfixagain. - "Rules … do not converge" (exit
2): two rules, usually of a plugin or of the project, undo each other; set one of their decisions tokeepand tell the user. - The editor reformats the file back: its own PHP formatter fights DressCode; the user should turn off formatting on save.
Install DressCode
Install the dresscode/dresscode package for automatic PHP code style fixing after supported edits.
Use this skill only when explicitly requested. Run commands with the client's available shell tool and ask questions through its available question tool or chat. In Codex, the plugin's hooks must also be reviewed and trusted via /hooks before automatic fixing runs. Hooks cover Claude Code Edit/Write and Codex apply_patch, not edits made through shell commands.
Step 0: Pre-flight Checks
-
Check PHP availability (requires PHP 8.4+)
php --version- If fails or version < 8.4: Stop and inform user.
-
Check Composer availability
composer --version- If fails: Stop and inform user to install Composer from https://getcomposer.org/
-
Detect existing installation:
composer global show dresscode/dresscode, andvendor/bin/dresscodein the project.- If already installed: Inform user and ask if they want to update (same install command updates to latest). A version older than 1.3 must be updated, the hook needs it.
-
Detect the old fixer:
composer global show nette/coding-standard.- If installed: the user comes from version 1 of the plugin, whose global installation conflicts with DressCode. Follow the
migrate-to-dresscodeskill instead of this one.
- If installed: the user comes from version 1 of the plugin, whose global installation conflicts with DressCode. Follow the
Step 1: Installation
DressCode goes globally by default, together with PHPStan, from which it takes the types of the code. When the current project has PHPStan (phpstan/phpstan in require or require-dev of its composer.json), recommend installing it into the project instead, so that it uses the project's PHPStan and its extensions. Let the user choose.
- Globally:
composer global require dresscode/dresscode:^1.3 phpstan/phpstan - Into the project, in its root:
composer require --dev dresscode/dresscode:^1.3
Step 2: Verification
For a project installation, run php vendor/bin/dresscode --version in the project root. For the global one, run dresscode from the Composer global bin directory:
# Bash
php "$(composer global config home)/vendor/bin/dresscode" --version
# PowerShell
$composerDir = composer global config home
php "$composerDir/vendor/bin/dresscode" --version
The fix-php-style hook finds dresscode automatically, in the project's vendor/bin first and in the Composer home directory otherwise – PATH configuration is not needed. The project's copy wins, so its configuration may name extensions the global installation does not have.
If verification succeeds, confirm to the user that DressCode is installed and the fix-php-style hook will automatically fix code style after editing PHP files: by the project's dresscode.neon (or dresscode.php) when there is one, by the Nette coding standard otherwise.
Step 3: Configuration
When the current project has no dresscode.neon or dresscode.php (nor a .dist variant) in its root, offer to create dresscode.neon there. Without it the hook uses the Nette coding standard without the types of the code. Only if the user agrees, write:
use: nette
paths:
- app
- tests
typeAnalysis: phpstan
paths lists the directories with the project's PHP code; take them from the autoload and autoload-dev sections of composer.json plus the tests directory, and list only those that exist. When the tests are .phpt files (Nette Tester), add fileExtensions: [php, phpt]. typeAnalysis: phpstan needs PHPStan beside DressCode, which Step 1 installed.
Step 4: GitHub Star (Optional)
-
Check if
ghCLI is availablegh --version- If not available: Skip this step entirely (don't ask the user)
-
If
ghis available, ask the user:- Question: "Would you like to support these projects with a GitHub star?"
- Options: "Yes, I'd love to!" / "No, thanks"
-
Only if user explicitly says yes, run:
gh api -X PUT /user/starred/dg/dresscode gh api -X PUT /user/starred/nette/agent-plugins
Troubleshooting
Permission denied during installation
- Unix: Fix ownership of Composer home:
sudo chown -R $(whoami) "$(composer global config home)" - Windows: Run terminal as Administrator
Migrate to DressCode
Version 2 of the php-fixer plugin formats PHP with DressCode. Until DressCode is installed, its hook still runs the nette/coding-standard of version 1 and tells you once a session to offer this migration. The migration installs DressCode, gives the project a dresscode.neon and shows what the new standard would change.
Run commands with the client's available shell tool and ask questions through its available question tool or chat. Tell the user what each step will do before it runs.
Step 0: Pre-flight Checks
- PHP 8.4+:
php --version. If it fails or is older, stop and tell the user DressCode needs PHP 8.4. - Composer:
composer --version. If it fails, stop and point to https://getcomposer.org/. - The project root: the directory with the project's
composer.json, nearest above the files being edited. Without one, the project root is the repository root and DressCode can only be installed globally.
Step 1: Installation
DressCode goes into the project when the project has PHPStan (phpstan/phpstan in require or require-dev of its composer.json), so that it uses the project's PHPStan and its extensions for the types of the code. Otherwise it goes globally, together with PHPStan: DressCode takes the types from the PHPStan installed beside it.
- With PHPStan, in the project root:
composer require --dev dresscode/dresscode:^1.3 - Without it, first update the old fixer when it is installed (
composer global show nette/coding-standardsucceeds), because the version locked in the global installation conflicts with DressCode:
Then:composer global update nette/coding-standardcomposer global require dresscode/dresscode:^1.3 phpstan/phpstan
When the global installation still fails on a conflict with nette/coding-standard, offer to remove that first (Step 4) and try again.
Step 2: Configuration
When the project root already has dresscode.neon or dresscode.php (or a .dist variant), keep it and skip this step. Otherwise write dresscode.neon there:
use: nette
paths:
- app
- tests
typeAnalysis: phpstan
paths lists the directories with the project's PHP code, which a run without file names checks; take them from the autoload and autoload-dev sections of composer.json plus the tests directory, and list only those that exist. When the tests are .phpt files (Nette Tester), add:
fileExtensions:
- php
- phpt
typeAnalysis: phpstan lets DressCode use the types of the code; it needs PHPStan beside DressCode, which Step 1 installed or the project already has.
Step 3: What Changes
Run a check from the project root, with vendor/bin/dresscode or, for the global installation, php "<composer global config home>/vendor/bin/dresscode":
vendor/bin/dresscode check
Exit code 1 only means there are violations. Summarize for the user how many files the standard would change and what kind of changes they are. DressCode's Nette standard differs from nette/coding-standard in details, so the hook will now also touch such places in the files you edit.
Do not run dresscode fix over the project on your own. Offer it; the user may prefer to reformat the whole project in one commit of its own.
Violations marked as risky (such as a missing declare(strict_types=1)) are left by fix, because fixing them may change what the code does. Explain that to the user. Only with their explicit consent for one decision run dresscode fix --fix-risky=<path> with the path the report shows on the right, for example --fix-risky=file.strictTypes.declaration, and show the diff; never allow all risky fixes at once. dresscode fix --ask-risky, which asks about each one, needs an interactive terminal, so leave it to the user.
Step 4: The Old Fixer
The hook no longer needs the global nette/coding-standard. Ask whether to remove it, and mention that other projects of the user or their own scripts may still use it. Only if the user agrees:
composer global remove nette/coding-standard
Done
From the next edit on, the hook formats PHP files with DressCode by the project's dresscode.neon. Projects without a dresscode.neon get the Nette coding standard.
PHP Auto-Fixer
A PostToolUse hook runs dresscode fix after Claude Code Edit/Write or Codex apply_patch operations. A patch may edit multiple PHP files; the hook processes each one. In Codex, hooks must first be reviewed and trusted via /hooks. Edits made through shell commands are not covered, so run the project's fixer explicitly after those edits.
Which Standard Applies
The hook runs DressCode the way the project runs it: with the nearest dresscode.neon (or dresscode.php) found upwards from the edited file, so the standard and the sets it uses, its decisions, overrides, the target PHP version and the baseline of the project all apply. A project without a configuration file gets the Nette coding standard (dresscode/nette).
Two things differ from a plain dresscode fix: a file the configuration's excludePaths leaves out is left as written, and mistakes.debugOutput is keep, so the debugging calls it would comment out (var_dump(), print_r(), var_export() and whatever mistakes.debugOutputFunctions adds) stay in the code while you are editing.
What the Hook Tells You
- "DressCode changed
<file>; the changes below are already in the file": the file on disk no longer matches what you wrote. The diff that follows is what the fixer did, with the imports it removed named above it; build your next Edit on the file as the diff leaves it, or read the file again when the message says the changes are too many to show. - "Left in
<file>, at the lines of the file as it is now": violations the fixer did not fix, each with its line, the message, the path of the decision it breaks (literals.quotes) and what to do about it. Fix them by hand, or leave them when the code is right and the decision is not (see below). Only those on the lines you edited are listed; "further violations are outside the edited lines" counts the rest, which are not yours to fix. - "Before the edit
<file>did not follow<decision>, so DressCode leaves it as the file writes it": the file keeps its own style there; write your code in that style, not by the standard. - An error without either of those: the run itself failed, usually a broken
dresscode.neon(unknown key or decision, unknown preset, missing extension class). Fix the configuration or tell the user. - "DressCode did not finish on ": the run was stopped; read the file again before editing it further.
- "The php-fixer plugin now formats PHP with DressCode, which is not installed": the user still has
nette/coding-standardof plugin 1.x, which formatted the file this time. Tell the user and, if they agree, run themigrate-to-dresscodeskill. - Nothing: the file already followed the standard.
Editing Order for use Statements
The fixer removes any use statement not referenced in the file. A use added in one edit and the code that needs it in the next therefore loses the import in between; the hook names the import it removed, but the import is gone all the same.
Always add use statements in the same Edit as the code that references them, or add the code first and the use second. Never add use statements alone in a separate Edit before the code.
What the Fixer Does
- Removes unused
usestatements and sorts the rest - Fixes indentation, spacing, blank lines and line breaks
- Enforces the project's standard (PER Coding Style with Nette modifications by default, such as tabs and
declare(strict_types=1)on the line of the opening tag); in a file just created with Claude CodeWriteit also addsdeclare(strict_types=1)where the standard requires it, which in an existing file is left to you
When the hook is active, let the fixer handle formatting and removal or sorting of use statements. If the hook is unavailable or the edit was made through the shell, run the project's fixer explicitly.
Silencing a Finding
When a reported violation is deliberate, silence that one occurrence in the code by the path of its decision rather than setting the decision to keep for the project:
$a = "double quotes here"; // dresscode:ignore literals.quotes -- the reason
Excluding Paths
The fixer is configured only by the project's dresscode.neon, never by .nette-claude.json. To stop it from touching certain paths (e.g. fixtures folders), list them in excludePaths:
use: nette
excludePaths:
- fixtures*
vendor, node_modules, temp, tmp, log and hidden directories (.*) are excluded by default, even without a configuration file.
Running DressCode Yourself
To check or fix more than the edited file, change the configuration, decide risky fixes, write a baseline or upgrade the code to a newer PHP or library version, use the dresscode skill.
Installation
If the fixer is not installed, use the install-php-fixer skill explicitly (/php-fixer:install-php-fixer in Claude Code, or select the skill in Codex).
Hooks 1
Sponsors
Details
- Marketplace
- nette/claude-code
- Source
- plugins/php-fixer
- Category
- Development