Getting started
@noctcore/harness runs under plain Node 22 or later (22.18 or later to load a TypeScript rule
registry). It has no runtime dependencies and makes no network call, so it adds nothing to your
supply chain beyond itself.
-
Install it as a devDependency. You can also skip this and run it with
npx, but a registry that imports the ready-made rules needs the package installed.Terminal window npm install --save-dev @noctcore/harness # or: pnpm add -D, bun add -d -
List your checks in
.noctcore/harness.json. Each check has aname, a free-formkindand thecommandto run. This one runs the tests and the repo’s lint-meta rules:.noctcore/harness.json {"schemaVersion": 1,"checks": [{ "name": "unit-tests", "kind": "test", "command": "node --test" },{ "name": "repo-rules", "kind": "lint-meta", "command": "npx harness lint-meta", "timeoutMs": 120000 }]} -
Run it.
Terminal window npx harness check→ unit-tests: node --test→ repo-rules: npx harness lint-meta✓ unit-tests (exit 0)✓ repo-rules (exit 0)Structure lock passed (2 checks).Every command is printed before it runs. The run exits
0when every check passed and1when any failed. -
Add a rule registry for the checks ESLint cannot reach: whole-repo contracts, workflow files, the lockfile. The registry exports
META_RULES:.noctcore/lint-meta/registry.mts import type { IMetaRule } from '@noctcore/harness';import {createGithubActionsSecretNoInstallRule,createGithubActionsSecurityNoCancelRule,} from '@noctcore/harness/rules';import { maxFileLines } from './rules/max-file-lines.mts';import { readmeHasLicense } from './rules/readme-has-license.mts';export const META_RULES: IMetaRule[] = [createGithubActionsSecretNoInstallRule(),createGithubActionsSecurityNoCancelRule(),readmeHasLicense,maxFileLines,];A rule of your own is an object with an
id, acategory, adescriptionand arun:.noctcore/lint-meta/rules/readme-has-license.mts import type { IMetaCtx, IMetaRule, IViolation } from '@noctcore/harness';export const readmeHasLicense: IMetaRule = {id: 'readme-has-license',category: 'config',ciCritical: true,description: 'The README has a License section.',run(ctx: IMetaCtx): IViolation[] {const readme = ctx.read('README.md');if (readme !== null && /^## License$/m.test(readme)) return [];return [{ file: 'README.md', rule: 'readme-has-license', message: 'Add a "## License" section.' }];},}; -
Run it in CI. Any CI that has Node works. In GitHub Actions:
.github/workflows/harness.yml name: harnesson: [push, pull_request]permissions:contents: readjobs:check:runs-on: ubuntu-24.04steps:- uses: actions/checkout@v7 # pin to a full commit SHA in your repo- uses: actions/setup-node@v7 # pin to a full commit SHA in your repowith:node-version: 22- run: npm ci- run: npx harness check
When a check fails
Section titled “When a check fails”The runner does not stop at the first failure. It runs every check, then prints each failed one with its command and the tail of its output, so one CI run shows the whole failure set:
→ unit-tests: node --test→ repo-rules: npx harness lint-meta✓ unit-tests (exit 0)✗ repo-rules (exit 1)
The Structure-Lock check failed: 1 project harness check did not pass. They MUST all pass before this work can be verified or merged. Re-run each one locally and fix every violation it reports:
--- `repo-rules` ---Command: npx harness lint-meta
Output:lint-meta: running 3 rules from /repo/.noctcore/lint-meta/registry.mts→ github-actions-secret-no-install→ github-actions-security-no-cancel→ readme-has-license
[ERROR] github-actions-secret-no-install (.github/workflows/release.yml): Job `publish` (line 5) reads `NPM_TOKEN` (line 12) and installs packages on line 9. Every package's lifecycle scripts run in that job, and what they leave behind runs in the step that holds the secret. Move the secret's step into a job of its own that checks out and runs no package install.- The manifest and the runner: every field, the timeouts,
--jsonand the exit codes. - Writing a lint-meta rule: the rule contract and
ctx. - Using the rules: the six ready-made rules and their options.
- Pinned tools: zizmor, actionlint and gitleaks at exactly their pinned version.
- Dockerfiles, migrations and images: hadolint, squawk and trivy, each pinned, with canaries that fail the day a tool stops judging.