@mark1russell7/conventions
This package is one check in CI for the conventions that the docs of a repository tell in prose. Each rule is a small module with an id, a reason, a fix and the rows of the invariants audit that it comes from. A repository turns a rule off or changes a rule only with a reason in its package.json. Thus each exception is visible in the diff.
Use
Install the package:
pnpm add -D @mark1russell7/conventions
Add the script "check:conventions": "conventions check" to the root package.json. The shared CI of the template starts check:conventions after lint (CI.md).
pnpm exec conventions check
pnpm exec conventions fix
pnpm exec conventions --list
Each break shows the file, the line, the rule and the fix. In GitHub Actions, the check also writes an annotation on the line of each break. It also writes a table of the rules to the summary of the run (GITHUB_STEP_SUMMARY). The exit code is 1 when a rule has a break. A break of a new rule before its day failsFrom is a warning. The check shows it with the status warn and a ::warning annotation, and the exit code stays 0.
conventions fix writes the fixes that the rules know, and checks again. It continues until no fix applies. Each fix is an exact change of a file, and the fix writes it only when the file did not change after the check. These breaks have a fix:
runner-budget: the minute of a schedule, a max-parallel of a matrix, and a concurrency group at the top of a workflow. A new run of a pull request stops the old run. A run of another event waits for the old run.
runner-peak: the jobs that the workflows of a repository hold at one time in a busy minute, against the share of the repository. The rule is off until the option share is set.
main-runs-finish: a cancel-in-progress: true or a concurrency group that ends with ${{ github.ref }}, in a workflow that starts on push, workflow_call or workflow_run. The rule does not examine the group of a workflow that starts only on workflow_run. The fix writes ${{ github.event_name == 'pull_request' }} and ${{ github.event_name == 'pull_request' && github.ref || github.sha }}.
push-main-only: a workflow that starts on push and on pull_request, with no limit of push to the default branch or with no workflow_dispatch. The fix adds branches and workflow_dispatch, and keeps the comments and each other trigger. It keeps a tag run when the workflow reads the tag. It does not edit release.yml, and a person chooses the change for branches-ignore or for another named branch.
pipe-fails: a step with a pipe and no pipefail. The fix adds defaults: { run: { shell: bash } } to the workflow. It does not write over another shell.
gate-after-cancel: a summary job of a gate with always() in its condition. The fix writes if: ${{ !cancelled() }}. A condition with other parts needs a person.
security-gate: a repository with the gate ci.yml (a pull request trigger) and no security gate: no job Security OK, no step with the action security-scan. The fix writes .github/workflows/security.yml as the stamp writes it, with the action pinned to a commit and the minute of the repository and the file. It needs a person when security.yml is there and is not a gate, or when no remote origin gives the minute. It skips a private repository, which has no paid Actions minutes. It also skips a repository with no event file of GitHub Actions, because only that file gives the visibility: a local fix writes no security.yml.
security-one-job: a job that uses the shared workflow reusable-security.yml, with or without its summary job Security OK. The fix writes one job Security OK that runs the action security-scan, with the same inputs and time limit. With no summary job, the new job gets the id security-ok. The pin is the first commit of the template with the action, and Renovate moves it. Another summary job, a second job that needs the scans, another job security-ok or an input of more than one line needs a person.
tests-required: the option passWithNoTests in a config or a script, in a package with test files. A package with no tests needs a person, who removes its test script.
typed-files: a config file at the root of a package (vitest.config.ts). The fix adds *.config.ts and rootDir: "." to the tsconfig.test.json of the package, when that file has no comments.
trust-policy: the settings trustPolicy, trustPolicyIgnoreAfter and trustPolicyExclude of pnpm-workspace.yaml. The fix makes the file when the repository has none.
security-overrides: the line of a shared override in overrides of pnpm-workspace.yaml, with a comment that names its advisories. The fix also removes a line whose parent is not in the lockfile. After the fix, start pnpm install and commit the lockfile.
main-check: a compare of process.argv[1] with the path of the script. The fix writes import.meta.main when each Node version of engines.node has it (^22.18, >=24.2). Else it writes a compare of the two real paths, and it adds the imports. It removes the imports that only the old compare used.
gate-trigger: a path filter on the pull request trigger of a gate. The fix removes the filter and adds a job changes with the same patterns. Each other job needs it and has an if on its match. A summary job <Name> OK with the action gate-summary needs each job. A job with its own if, and each job that needs such a job, can be skipped (allow-skip). Some workflows need a person, because the fix cannot convert them with certainty. Examples are a trigger in the flow form, an if of more than one line, and a job changes that already exists.
summary-job: a gate workflow (ci.yml, security.yml) with a pull request trigger and no summary job. The fix adds a job <Name> OK with the action gate-summary after the last job. It needs each job. A job with its own if, and each job that needs such a job, can be skipped. A job that already has the id of the summary job needs a person. The fix leaves a caller of reusable-security.yml to security-one-job.
The text output marks each break that has a fix. In the JSON output, such a break has fixable: true. The release train starts conventions fix in its update pull requests. Thus a break that a script can fix does not block a repository.
Rules
The rules come from the invariants audit of 2026-10-26 (strategy item s38). The audit read the rule documents of 7 repositories. Each rule here is a convention that 3 or more repositories tell, and that a script examines exactly. The column "From" gives the repository and the id of each audit row.