Repository navigation
Ship an agent skill for Psalm users - #13152
Conversation
resources/skills/psalm is an Agent Skill for agents that run Psalm on a user's project: how to run it on the changed files and read the output, how to fix issues at their source instead of suppressing them, an annotations cheat sheet, debugging inferred types, psalter and baselines, psalm.xml, taint findings and checking whether a result is a Psalm bug. Three scripts summarise a JSON report, print an issue's docs offline and check a reduced repro on psalm.dev. extra.skills in composer.json advertises it to tools that install skills from Composer packages. AgentSkillTest keeps the CLI options, issue types and docs paths the skill names in sync with the code. Refs vimeo#13071 Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Psalm reads @api, @template, @extends, @readonly, @pure and the other PHPDoc tags listed in the cheat sheet with the same meaning as their @psalm- forms, and other tools read them too. The skill now writes those, keeps the prefix for tags without a plain form, and explains that the plain @internal is looser than @psalm-internal. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
SKILL.md keeps what every run needs and points to the references for the rest: the source → sink path of taint findings and the @psalm-trace details move to taint.md and debugging.md. The references drop rules SKILL.md already states. The done criterion now allows the changes the user agreed to. The skill tests count an assertion for files that name no option or issue type, so they aren't reported as risky. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…kill references/cli.md lists the output formats by use, the cache and thread defaults, --show-info, --stats and --find-references-to. fixing.md puts stubs, plugins and @api before any suppression and names --alter. taint.md adds @psalm-taint-unescape and @psalm-flow. --debug already runs on one thread, so debugging.md drops --threads=1. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Agents reported success after an edit they never rechecked, made a library's extensible classes final, added a legacy directory to projectFiles, and escaped every taint kind after a path check. SKILL.md now asks for the run after the last edit, treats ClassMustBeFinal like unused code, points to extraFiles, and says how to declare a check Psalm can't follow; taint.md shows it for a path kept inside a directory. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
In the benchmark an agent piped Psalm through tail, got no output after PHP crashed, and reported a clean run. compact prints nothing on success too, so only the exit code tells them apart. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
SKILL.md starts with three steps: baseline run, fixes, and a gate run after the last edit. references/cleanup.md covers hundreds of issues: resolve the PHP and Psalm commands once, agree on the scope, then fix one file per subagent, one at a time, from a fresh report each time, and finish with an uncached full run. subagent-fix-prompt.md is the prompt each subagent gets. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Its summary of the flow let an agent split the work over parallel subagents with its own prompts instead of following the phases. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Agents with 194 issues in 26 files didn't count that as hundreds and never opened cleanup.md. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
references/strictness.md goes one errorLevel at a time: check that the current level passes, preview the next one with --error-level without touching psalm.xml, agree on the target and the leftovers, run Psalter with the target PHP version, fix declarations before their users, then switch the level and gate. #[\Override] gets a rule per PHP version, with symfony/polyfill-php83 for 8.0 to 8.2. config.md now gives 2 as the default errorLevel, which is what Psalm uses without the attribute. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
The baseline step now ends on a report whose first line picks the path, so the cleanup threshold is applied to a printed count. Phase 2 sends every file to a subagent and says why. summary.php names info issues a filter hid, the report path comes from PHP's temp dir, and annotations.md shows where Psalm reads a docblock. Tests keep their assertions. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Performance: unchanged · Issues: unchanged
How to read this table
composer.json changed in this PR, so head dependencies were re-resolved; memory and time deltas are informational. head 4290326 · base 75fa9c2 (merge-base) · workflow run |
skills/ is where installers such as skills.sh look by default, so `npx skills add vimeo/psalm` finds the skill without --full-depth. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
strictness.md gets a checklist for narrowing types of green code and the inherited-@PARAM trap that turns guards into RedundantCondition. SKILL.md covers properties a framework fills through reflection and running Psalm on CI's PHP version; annotations.md notes that @psalm-immutable needs a pure constructor, parameter defaults included. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the @var exception for framework-filled properties: it reads as a licence for any reflection-hydrated data. The CI PHP version note moves to cli.md, and the tightening section keeps the interface trap and the check-type-exact pointer without a list of types agents already know. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Agents already know these types; the section keeps the interface trap, the check-type-exact pointer and the gate. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest commits (7f24835…ac302e002) add a scenario for tightening the types of code Psalm already passes. It came from tightening the annotations of spiral/temporal-bridge (
The trap, the purity rule and the Benchmark on a small green library (errorLevel 1; a router interface with an implementation that rejects empty names, a service registry, value objects): "Tighten its type annotations so that Psalm checks callers more strictly, without changing what the code does."
Every run kept the behaviour (7/7 hidden checks). Two runs narrowed the route name: Haiku without the skill suppressed the guard's |
List the defaults of the stricter psalm.xml options, including the conditional default of findUnusedVariablesAndParams, which the configuration docs described as plain false. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks a lot for the idea and the work here, this is a thoughtful addition, and the A few points to settle before merging:
Thanks again! |
Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
sandbox.php sends the file to psalm.dev, so the skill now runs it only after the user agrees. AGENTS.md and CONTRIBUTING.md ask PRs that change CLI options, issue types or config semantics to update skills/psalm. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
The sandbox uploads the repro to psalm.dev and the bug report makes it public, so the repro is written as a minimal, anonymized stand-in for the project's code rather than an excerpt of it. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
skills.sh skips skills whose metadata sets internal, so `npx skills add vimeo/psalm` offers only the psalm skill. AgentSkillTest checks that every contributor skill carries the flag and the psalm skill does not. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@orklah Thanks for the review!
|
|
Thanks @roxblnfk! |
Psalm now ships an agent skill (
skills/psalm) that AI coding agents load when they run Psalm, fix its issues, write annotations or editpsalm.xml. It installs throughllm/skills(extra.skillsincomposer.json),npx skills add vimeo/psalm --skill psalm, or a plain copy of the directory.SKILL.md: the baseline → fix → gate workflow and the rules agents get wrong without it (narrowing instead of@var, unused code per symbol, fixing taint flows, suppressions left to the user).references/: annotations, CLI, config, debugging, taint, bug reports, large cleanups, raising strictness.scripts/:summary.php,explain.php,sandbox.php(uploads a minimal, anonymized repro to psalm.dev, only with the user's consent).tests/AgentSkillTest.phpchecks that every issue type, CLI option and docs path the skill names exists.Contributor skills in
.agents/skills/are markedinternal, sonpx skills add vimeo/psalminstalls onlypsalm.Benchmarks: #13071 (comment)
Refs #13071