@benchcutlogic/repo-checks
v0.2.2
Published
Typed repository contract, boundary, token, web SEO, and prose checks via the bench-check CLI.
Downloads
1,514
Maintainers
Readme
@benchcutlogic/repo-checks
Static checks for a repository's docs, agent instructions, lockfiles, Effect boundaries, Svelte theme tokens, Storybook catalog, built website output, and prose. Run them with the bench-check CLI or call them from code.
Install
npm install --save-dev @benchcutlogic/repo-checksRequirements
- Node.js 20.19 or later. The package is ESM; CommonJS callers can
require()it on Node versions that supportrequire(esm)(20.19+, 22.12+). gitonPATH(optional). Inside a git work tree the checks read the filesgit ls-filesreports, so git-ignored paths are skipped. Without git, or outside a work tree, they walk the directory.bashonPATHfor thesnippetspart of thewebcheck, which runsbash -non shell code blocks.
CLI
npx bench-check run
npx bench-check doc-paths --root .
npx bench-check agent-contracts --json
npx bench-check web --build-dir build
npx bench-check prose --strict
npx bench-check --versionrun runs the checks listed in checks in bench-check.json, or the core checks below when there is no config file. Any check name runs that check alone.
| Option | Meaning |
| ------------------- | -------------------------------------------------------------------------- |
| --root <dir> | Repository root to check. Defaults to the current directory. |
| --json | Print the full RunSummary as JSON instead of text. |
| --strict | Report warnings (AGENTS.md size warning, prose phrase warnings) as errors. |
| --build-dir <dir> | Built site directory for web. Overrides web.buildDir. |
| --version, -v | Print the installed package version. |
| --help, -h | Print usage. |
Exit codes: 0 when no check reports an error, 1 when at least one does, 2 for a usage or configuration error (unknown command, missing root, invalid bench-check.json).
Checks
Core checks (run by run when no config file selects others):
| Check | What it reports |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| doc-paths | Relative markdown links and backticked file paths in docs that do not exist on disk. |
| agent-contracts | .agents/skills/*/SKILL.md frontmatter, parity between the AGENTS.md skills table and .agents/skills/, unknown ast-grep rule IDs, Effect v3 API names in an Effect v4 repo, and missing scripts or paths under a "Repo facts" heading. |
| agents-budget | AGENTS.md above the byte budget, and a missing or mismatched CLAUDE.md or .claude/skills. |
| lockfile-registry | pnpm-lock.yaml or package-lock.json entries that point at localhost, loopback, private LAN, *.ts.net, .local, .lan or .internal hosts. |
| unique-error-tags | Schema.TaggedError or Data.TaggedError tags declared twice, and the same inline pgEnum tuple declared in two files. |
| effect-boundaries | Platform imports inside configured pure packages, and Effect.run* calls outside configured runtime entry points. |
| svelte-tokens | Raw Tailwind palette classes, bg-white/bg-black/text-white/text-black, hex colors in .svelte files, 50vw/100vw, and bg-destructive* paired with text-foreground. |
| storybook-catalog | Stories missing from a catalog file and catalog entries with no story, or duplicate story names in one directory when there is no catalog. |
Opt-in checks (list them in checks or run them by name):
| Check | What it reports |
| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| web | In a built site, or a live site when web.baseUrl is set: sitemap shape and https locations, favicon.ico bytes, <text> in favicon.svg, title and description length, https og:image and canonical URLs, JSON-LD shape, and shell snippets that fail bash -n. |
| prose | Frontmatter title, description and tag limits, code fences without a language, configured banned terms, and stock filler phrases (warnings unless --strict or prose.slopMode is error). |
A line containing bench-check-ignore: svelte-tokens is skipped by svelte-tokens.
Configuration
Put an optional bench-check.json at the repository root. Every key is optional; omitted keys keep the defaults shown here.
{
"checks": ["doc-paths", "agents-budget", "lockfile-registry", "web"],
"files": {
"exclude": ["vendor/**"],
"respectGitignore": true
},
"docPaths": {
"files": [
"AGENTS.md",
"CLAUDE.md",
"README.md",
"CONTRIBUTING.md",
".agents/skills/*/SKILL.md"
],
"ignorePaths": []
},
"agentContracts": { "knownRuleIds": [] },
"agentsBudget": { "warnBytes": 18000, "maxBytes": 20000 },
"effectBoundaries": {
"purePackages": ["packages/core"],
"forbiddenImports": [
"cloudflare:",
"alchemy",
"better-auth",
"node:fs",
"node:http",
"node:https",
"apps/"
]
},
"svelteTokens": {
"globs": ["**/*.svelte", "apps/*/src/**/*.css", "packages/ui/src/**/*.svelte"],
"ignores": ["**/*.stories.svelte", "**/app.css", "**/tokens.css", "**/theme.css"]
},
"storybook": { "catalogFile": ".storybook/catalog.json" },
"web": {
"buildDir": "build",
"checks": ["sitemap", "favicon", "meta-jsonld", "snippets"],
"unpublishedPackages": [],
"titleMax": 60,
"descriptionMax": 160
},
"prose": {
"globs": ["docs/**/*.md"],
"allowedTags": ["engineering", "release"],
"bannedTerms": [{ "pattern": "\\bOldName\\b", "reason": "Renamed to NewName." }],
"slopMode": "warn"
}
}Notes on the less obvious keys:
files.excluderemoves matching paths from every check, including the fixed paths some checks read directly (AGENTS.md,CLAUDE.md,.agents/skills,.claude/skillsand lockfiles). Excluding a directory, with or without/**, excludes everything in it. An excluded skill is not checked, but a skills-table entry that names it still counts as existing. Inputs a check reads to know what to check, such aspackage.json,sgpack.json,ast-grep/rules, a configured Storybook catalog and built web output, are always read.files.respectGitignore: falsereads git-ignored files too.agentContracts.knownRuleIdsadds rule IDs to the ones the check already accepts: the IDs shipped by@benchcutlogic/sgpack-packs, theidof every rule inast-grep/rules/*.yml, and the keys ofoverridesinsgpack.json.agentContracts.effectV4forces the Effect v4 check on or off instead of readingeffectversions frompackage.jsonfiles.effectBoundaries.allowedRuntimeEntrieslists globs whereEffect.run*is allowed. The default allowsruntime.ts,client-runtime.ts,worker.ts,cli.ts,main.ts,hooks.server.ts, tests, andscripts/.storybook.catalogFileis a JSON array of story paths,{ "stories": [...] },{ "visualEntries": [...], "excluded": [...] }, or a TS/JS file that names the story files. Without it, the check looks for.storybook/catalog.json,storybook-catalog.jsonandstories-catalog.json.web.buildDirdefaults to the first ofapps/web/build,buildanddistthat exists.web.baseUrlchecks a live site over HTTP instead of a build directory.web.snippetFileslists the markdown files whose shell blocks are checked.web.unpublishedPackagesnames packages that must not appear innpx <name>snippets.
API
@benchcutlogic/repo-checks
import { formatSummaryText, runChecks } from '@benchcutlogic/repo-checks';
const summary = await runChecks({ root: process.cwd(), checks: ['doc-paths', 'agents-budget'] });
console.log(formatSummaryText(summary));
process.exitCode = summary.passed ? 0 : 1;runChecks(options) resolves to a RunSummary with results, a flat findings list, errorCount, warningCount and passed. Options:
root(required): repository root.checks: check names to run. Defaults tochecksfrom the config.config: aResolvedBenchCheckConfig. Defaults toloadConfig(root).strict,buildDir: same as the CLI flags.fetchFn: a fetch-like function forweb.baseUrlrequests, for tests or custom HTTP clients.
The package also exports loadConfig, DEFAULT_CONFIG, CORE_CHECKS, ALL_CHECKS, runSingleCheck, one function per check (checkDocPaths, checkWeb, and so on), and the types BenchCheckConfig, ResolvedBenchCheckConfig, CheckName, Finding, CheckResult, RunSummary and FetchLike.
@benchcutlogic/repo-checks/cli
import { runCli } from '@benchcutlogic/repo-checks/cli';
const code = await runCli(['doc-paths', '--root', '.', '--json'], {
stdout: (text) => console.log(text),
stderr: (text) => console.error(text)
});
process.exitCode = code;runCli(argv, io?) runs the CLI in process and resolves to its exit code. Importing this module does not start the CLI. It also exports parseCliArgs and packageVersion.
License
Apache-2.0. See LICENSE.
