Skip to content

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.

  1. 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
  2. List your checks in .noctcore/harness.json. Each check has a name, a free-form kind and the command to 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 }
    ]
    }
  3. 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 0 when every check passed and 1 when any failed.

  4. 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, a category, a description and a run:

    .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.' }];
    },
    };
  5. Run it in CI. Any CI that has Node works. In GitHub Actions:

    .github/workflows/harness.yml
    name: harness
    on: [push, pull_request]
    permissions:
    contents: read
    jobs:
    check:
    runs-on: ubuntu-24.04
    steps:
    - 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 repo
    with:
    node-version: 22
    - run: npm ci
    - run: npx harness check

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.