phpcbf
Skill0 starsChanged 24 days agoMITView on GitHub
Run the phpcbf autofix pass of a PHP coding-standards campaign on a Dockerized, Makefile-driven project (Drupal or PSR-12): one phpcbf run over the whole custom tree, unblock every "FAILED TO FIX" file (section banners, commented-out code, one sniff at a time), php -l, and produce commit 1 with the phpcs tooling. Ends by proposing /clear then /php-standards for the next pass. Use when the user asks for the phpcbf / autofix pass, mentions "FAILED TO FIX" or phpcbf discarding fixes, or when the php-standards orchestrator routes here. IMPORTANT: all commands MUST go through Makefile targets; phpcbf's exit code and its "A TOTAL OF N ERRORS WERE FIXED" footer prove nothing — only a phpcs re-run does.
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- d11Skill
- drupal-build-foundationsSkill
- drupal-build-intakeSkill
- drupal-buildSkill
- drupal-build-unitSkill
- drupal-rgaaSkill
- drupal-scaffoldSkill
- gulp-to-viteSkill
- jquery-4-migrationSkill
- lando-to-dockerSkill
- phpcsSkill
- php-deprecations-auditSkill
- php-docker-upgradeSkill
- php-standardsSkill
- phpstanSkill
- sass-migratorSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
No subagents, ever: Never call the Agent or Workflow tool during this pass: not per module, not per sniff, not in parallel, not one …
- Very specific: line 63
Follow references/phpcbf-unblocking.md: hand-edit the blockers (section banners, commented-out PHP), re-run phpcbf on that file, then one …
- Very specific: line 109
Update the notes file (pass: none, the phpcs count left), then stop and print, without starting the next pass:
- Very specific: line 121
No hand fix of a phpcs violation that phpcbf could not compute: that is the phpcs pass and commit 2.
- Distinctive: line 124
Do not reformat contrib, vendor, core, or generated assets.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
phpcbf pass → commit 1
Part of the php-standards campaign; that skill owns the setup, the
questions, the state file and the MR. This one only writes commit 1: what
phpcbf wrote, the minimal edits that let it write, and the phpcs tooling.
No subagents, ever. Never call the Agent or Workflow tool during this
pass: not per module, not per sniff, not in parallel, not one sequential
helper, not "to save context". Each subagent reloads the system prompt,
every tool definition and the files, then its diff is re-read to verify
it, so the cost multiplies. Do every fix yourself in this conversation;
slower is fine. When the context grows, the answer is /clear + resume,
never delegation.
Start
cat .git/php-standards.md 2>/dev/null
ls phpcs.xml- No
phpcs.xml: the toolchain is not set up. Stop and invokephp-standards(its Steps 1–3 run first, then come back here). - No notes file (standalone use,
phpcs.xmlalready there): ask only the ticket id, and create.git/php-standards.mdin the format of thephp-standardsskill, withphpstan: ?andci: ?. - Set
pass: phpcbfin the notes file. If## Baselinehas no phpcs line, take it now:make phpcs c='--report=summary' | tail -5.
Everything goes through the Makefile, arguments through c='…'. The
severity is in phpcs.xml; do not add -n.
1. One run on the whole tree
make phpcbf | grep -E 'FAILED TO FIX|A TOTAL OF'Never gate on phpcbf's exit code: it is non-zero on successful runs.
A FAILED TO FIX line means phpcbf wrote nothing at all for that
file — every fix it computed was discarded — while the footer still prints an
encouraging A TOTAL OF N ERRORS WERE FIXED. Trusting that footer is how 1375
violations hide behind a file that looks done.
2. Unblock every FAILED TO FIX file
Follow references/phpcbf-unblocking.md: hand-edit the blockers (section
banners, commented-out PHP), re-run phpcbf on that file, then one sniff at a
time if it still does not converge. Repeat the whole-tree run until no
FAILED TO FIX line is left.
Each hand edit is a non-mechanical hunk inside a mechanical commit: note it (file + what was removed) for the commit body.
3. Check
make phpcs c='--report=summary' | tail -5 # what is left for the phpcs pass
make shell
for f in $(git diff --name-only --diff-filter=ACM | grep -E '\.(php|module|inc|install|theme|profile)$'); do php -l "$f" | grep -v '^No syntax errors'; done
exit
make crphp -l is not optional: a parse error in a .module file takes the site
down. git diff --stat only; read a hunk only for the hand-edited files.
4. Commit 1
Stage explicitly, never git add -A: the custom tree, phpcs.xml, the
Makefile, composer.json/composer.lock (drupal/coder), .gitignore.
git add web/modules/custom web/themes/custom phpcs.xml Makefile composer.json composer.lock .gitignore
git diff --cached --stat | tail -3Message (follow the repo's format if it has one; keep the word phpcbf):
style(qa: #<ticket>): apply phpcbf autofixes
phpcs: <before> -> <after> (<standard>, <severity>)
Not mechanical:
- web/modules/custom/foo/foo.module: section banners removed (blocked phpcbf)phpcbf found nothing and the tooling already existed: no commit, say so.
End: propose /clear
Update the notes file (pass: none, the phpcs count left), then stop and
print, without starting the next pass:
phpcbf pass done — commit <sha>: <before> → <after> violations, <n> files unblocked by hand.
Next: the phpcs pass. Run /clear, then /php-standards (the state is in .git/php-standards.md and the commits).Continue in this conversation only if the user declines the clear.
Non-goals
- No hand fix of a phpcs violation that phpcbf could not compute: that is the
phpcspass and commit 2. - No
// phpcs:ignore, no loosening ofphpcs.xmlto get a file through. - Do not reformat contrib, vendor, core, or generated assets.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

