baseline
Skill4 starsChanged 4 months agoMITView on GitHub
Adopt PHPStan on a legacy codebase without fixing everything at once — generate a baseline, include phpstan-baseline.neon, keep new code error-free, and shrink the baseline over time while enforcing it in CI. Use when the user wants to adopt PHPStan on an existing legacy codebase that already has many type errors, without blocking on a full cleanup; the user wants to generate a PHPStan baseline to snapshot existing errors so a new level can pass without fixing everything first; the user wants to shrink the PHPStan baseline over time, or keep it from growing, as they pay down type debt. Keywords: phpstan, baseline, legacy, static-analysis, ci.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- JeffreyFerreiras/ai-skillstheir own version, first seen Nov 8, 2026
- meshtastic/Meshtastic-Androidtheir own version, first seen Oct 8, 2026
- skillberry-ai/cap-evolvetheir own version, first seen Jun 16, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- meshtastic/Meshtastic-Android★ 1.9ksame name
- skillberry-ai/cap-evolve★ 69same name
- JeffreyFerreiras/ai-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- strategy-bitrix-d7-incrementalSkill
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- validationSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- redisSkill
- transactionsSkill
- ci-github-actionsSkill
- deployment-strategiesSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 66
Do not generate a baseline for a new or already-green codebase.
- Very specific: line 68
Do not use a baseline to permanently silence a rule you never intend to fix.
- Very specific: line 84
Add includes: [phpstan-baseline.neon] to phpstan.neon, then commit both files so the frozen errors apply everywhere.
- Very specific: line 86
Run plain phpstan analyse in CI so new errors fail.
- Distinctive: line 91
When raising the analysis level, regenerate the baseline once to absorb the new level's pre-existing errors, then hold it steady until the …
- Very specific: line 93
Keep parameters.reportUnmatchedIgnoredErrors: true (the default) so PHPStan flags baseline entries that no longer match, prompting you to …
- Distinctive: line 95
Treat the baseline as debt to pay down: fix baselined errors in files you already touch, then regenerate so removed errors drop out and the …
- Distinctive: line 130
Not applicable — no I/O, auth, or untrusted input.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- generated: do not edit — source: knowledge/atoms/phpstan/baseline/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->PHPStan Baseline
When to use
- The user wants to adopt PHPStan on an existing legacy codebase that already has many type errors, without blocking on a full cleanup.
- The user wants to generate a PHPStan baseline to snapshot existing errors so a new level can pass without fixing everything first.
- The user wants to shrink the PHPStan baseline over time, or keep it from growing, as they pay down type debt.
When NOT to use
- Do not generate a baseline for a new or already-green codebase; fix the handful of errors directly instead of freezing them.
- Do not use a baseline to permanently silence a rule you never intend to fix; use a
scoped
ignoreErrorsentry for a deliberate, documented exception.
Core guidance
- Generate the baseline with generate-baseline — Create the baseline with
vendor/bin/phpstan analyse --generate-baseline, which writes aphpstan-baseline.neonlisting every current error. - Include the baseline from phpstan.neon — Add
includes: [phpstan-baseline.neon]to yourphpstan.neonso the baselined errors are ignored on every run and commit both files. - Enforce zero new errors in CI, never regenerate to hide them — In CI run
phpstan analyse(no--generate-baseline) so new errors fail the build; only regenerate the baseline in a deliberate, reviewed commit.
Quick recipe
- Set the target
levelinphpstan.neon, then runvendor/bin/phpstan analyse --generate-baselineto snapshot current errors. (verify: Aphpstan-baseline.neonfile is written listing the existing errors.) - Add
includes: [phpstan-baseline.neon]tophpstan.neon, then commit both files so the frozen errors apply everywhere. (verify: A freshvendor/bin/phpstan analysenow exits 0.) - Run plain
phpstan analysein CI so new errors fail; as you touch legacy files, fix their baselined errors and regenerate so the baseline only shrinks. (verify: CI fails on a newly introduced error and the baseline count trends downward.)
Best practices
- When raising the analysis level, regenerate the baseline once to absorb the new level's pre-existing errors, then hold it steady until the next planned bump
- Keep
parameters.reportUnmatchedIgnoredErrors: true(the default) so PHPStan flags baseline entries that no longer match, prompting you to regenerate and drop them - Treat the baseline as debt to pay down: fix baselined errors in files you already touch, then regenerate so removed errors drop out and the file only shrinks
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| Baselining everything to claim a high level | A huge baseline at max level means almost no real code is actually analysed at that<br>level; the badge is misleading and new code still slips through. | Raise the level in steps, fixing errors at each step, and keep the baseline small<br>so the reported level reflects real coverage. |
| Gitignoring the baseline file | If the baseline is untracked, CI has nothing to include, so either analysis fails<br>everywhere or each machine regenerates a different baseline and results diverge. | Commit phpstan-baseline.neon alongside phpstan.neon so every environment<br>freezes the same set of errors. |
| Regenerating the baseline to make CI green | Regenerating absorbs the new error into the baseline, so the very bug analysis<br>caught ships silently and the baseline grows instead of shrinking. | Fix the new error in the PR; reserve baseline regeneration for deliberate,<br>reviewed events like a level bump. |
See references/anti-patterns.md.
Common mistakes
- Baseline generated but never included — You run
--generate-baseline, commitphpstan-baseline.neon, but analysis still reports all the old errors. Fix: Addincludes: [phpstan-baseline.neon]tophpstan.neonand rerun the analysis. - Baseline entries drift when lines shift — Editing a baselined file shifts line numbers so a frozen error resurfaces or an unrelated one gets swallowed, producing confusing CI diffs. Fix: Regenerate the baseline after substantial edits to a legacy file, or fix that file's baselined errors while you are in it so the entries disappear cleanly.
- Baseline file causes constant merge conflicts — A single large
phpstan-baseline.neonconflicts on almost every branch because many PRs regenerate overlapping regions of it. Fix: Discourage per-PR regeneration (only regenerate on level bumps), or split the baseline per top-level directory via multiple included files to localize churn.
Version notes
- Baseline format and PHP 7.4 through 8.4 support (PHP >=7.4) —
--generate-baselinewrites a neon file by default; PHPStan can also emit PHP or JSON baselines via--generate-baseline=phpstan-baseline.php, and the feature works identically across PHP 7.4 through 8.4. - reportUnmatchedIgnoredErrors defaults on in PHPStan 2.x (PHP >=7.4) — In PHPStan 2.x
reportUnmatchedIgnoredErrorsdefaults to true, so baseline entries that no longer match cause a failure until you regenerate; older versions were more lenient about stale entries.
Security
- Not applicable — no I/O, auth, or untrusted input.
Testing
- Activation and decision behavior are verified in
eval/scenarios/phpstan/baseline.yaml.
Additional resources
- references/anti-patterns.md
- references/core.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Prerequisites: phpstan/getting-started
<!-- graph-fragment: graph/fragments/phpstan/baseline.yaml -->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.

