新增基线检查项
adding-a-check
向本仓库添加新的基线检查项。当 new check 被请求、描述或隐含时使用——包括「为 X 添加检查」「基线应强制要求 X」「我们应在项目中验证 X」等情形。在编写任何代码之前,先确定该检查面向哪些运行器(runner)以及是否自动修复。
- License 许可
- MIT
- 最近更新
- 2026-11-06
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- adding-a-check
- description
- Add a new baseline check to this repository. Use whenever a new check is requested, described, or implied — including "add a check for X", "the baseline should enforce X", or "we should verify X in projects". Establishes which runner(s) the check targets and whether it auto-fixes before any code is written.
03 SKILL.md 正文
Adding a check
This repository ships two runners from one policy (see CLAUDE.md): the Composer package in
src/ and the npm package in js/. A new check therefore has two decisions attached to it that
cannot be inferred from the request, and getting either wrong means rewriting the check.
Ask first — always, before writing any code
Ask all three questions in a single AskUserQuestion call. Do not guess, and do not start with an
implementation "to be adjusted later": the runner choice changes where the policy values live and
whether a fixture is per-engine, the profile choice changes which projects ever run the check, and
the autofix choice changes the base class the check extends.
1. Which runner(s)?
- Both — the standard lives in every project. Ask whether the values are identical or differ
per ecosystem; if they differ, they go into
policy/policy.jsonunder a split keyed by who the value applies to —shared,composer,laravel/php/wordpress,js(seeci.requiredJobs,ciLint.required,claude.allow, and CLAUDE.md §4b) — and the fixtures are written per engine. - PHP only — anything composer-, artisan-, Rector-, PHPStan-, Spatie-Health- or DDEV-shaped.
- JS only — anything that has no meaning in a Laravel project, or whose PHP counterpart would
assert the opposite (
usesReleaseItis the precedent).
Recommend an answer with a reason rather than presenting a bare choice — most checks have an obvious home, and the question exists for the ones that do not.
2. Which PHP profiles? (skip for JS-only checks)
The PHP runner checks three kinds of project: laravel (artisan), and — through the standalone
vendor/bin/baseline — php (any composer project) and wordpress (a theme or plugin).
- Laravel only — the default:
AbstractCheck::profiles()returns[Profile::Laravel]. Anything touching artisan,config/*.php, the schedule, Laravel packages or rector-laravel. - Every PHP profile — override
profiles()to returnProfile::cases(). Tooling that means the same in any composer project (composer scripts, PHPStan, plain Rector sets, DDEV, editor/CI files). - A subset (e.g.
[Profile::WordPress]) — standards that only exist in that kind of project.
A check that runs outside Laravel must not use Laravel helpers (base_path(), str(), config(),
facades …) — use $this->path() and plain PHP. tests/StandaloneFrameworkFreeTest.php enforces
this. When the values differ between profiles, branch on $this->profile() and keep the values in
policy/ under per-profile keys. Fixtures declare the profiles they run under with an optional
"profiles" list (default ["laravel"]).
3. Autofix?
- Yes — extend
AbstractFixableCheck(PHP) /FixableCheck(TS) and implementfix();check()is the dry run, so detection and repair can never drift apart. The README entry must be marked ? —ReadmeFixableChecksTestenforces this in both directions. - No — extend
AbstractCheck(PHP) /Check(TS) and implementcheck(). The README entry must not carry ?.
Push back on autofix when the repair needs a human decision — a conflict between two declared
values, anything that installs a package, or anything that would silently rewrite a file the
developer curated. nodeVersion refusing to resolve an engines.node / .nvmrc disagreement is
the precedent: it detects, comments, and stops.
Then follow CLAUDE.md
CLAUDE.md holds the actual mechanics — class placement, registry registration, the README format
enforced by tests, the shared-fixture format, and the rule that any constant a check compares
against belongs in policy/, not in the class. Follow it rather than restating it here.
Two things that are easy to miss:
tests/CheckCommandTest.phphard-codes the total registered check count.- Adding a check on one side only is fine, but the fixture must declare its
enginesaccordingly, and a fixture directory name must be the kebab-case of the check name.
Verify both sides
A policy change can break the runner you did not touch:
composer test && composer analyse && composer format
npm run ci-lint && npm run build && npm test
04 同仓库更多 Skills
composer 与 npm 依赖更新
updating-dependencies
更新项目的 composer 和 npm 依赖,审查变更日志(changelog)对其在本项目中的影响,并报告因语义化版本(semver)而被阻止的主版本升级。当被要求更新或升级依赖、执行每月依赖更新,或由 `updatesDependencies` 周期性基线检查触发时使用。
Trivy 漏洞忽略项管理
ignoring-trivy-findings
在 .trivyignore.yaml 中添加、续期或删减条目——或因修复版本仍处于 npm 安装冷却期内而短期忽略,或因升级受项目约束阻碍而长期忽略。当 Trivy `security` CI 任务因某个漏洞而失败、被要求忽略或抑制某条 Trivy 发现,或审查现有 Trivy 忽略项时使用。
项目版本发布
creating-a-release
使用 release-it 为本项目创建、打标签并发布新版本。当用户要求创建、切分、打标签或发布版本,或提升项目版本时使用。
Composer 与 npm 依赖更新
updating-dependencies
更新项目的 composer 和 npm 依赖,审查变更日志(changelog)对本项目的可能影响,并报告因语义化版本(semver)约束而被阻挡的主版本升级。当用户要求更新或升级依赖、执行每月依赖更新,或由 `updatesDependencies` 周期性基线检查触发时使用。
Trivy 漏洞忽略项管理
ignoring-trivy-findings
在 .trivyignore.yaml 中添加、续期或清理条目——要么因修复版本仍处于 npm 安装冷却期内而短期忽略,要么因升级受项目约束阻挡而长期忽略。当 Trivy `security` CI 任务因某个漏洞失败、被要求忽略或抑制某项 Trivy 发现,或审查现有 Trivy 忽略项时使用。
Laravel 项目版本发布
creating-a-release
使用 release-it 为本 Laravel 项目创建、打标签并发布新版本。当用户要求创建、切分、打标签或发布版本,或提升项目版本时使用。