Scripts

May 31, 2026 · View on GitHub

Scripts are grouped by purpose. Run from repo root with pnpm <script> unless noted.

Folder structure

FolderPurpose
lib/Shared utilities for rule parsing and structure (used by generate, rule-structure, validate). Do not run directly.
validation/Pre-commit checks (run by lefthook on staged files).
generate/Generate artifacts from rule MDX (skills, hints, support notes, verification split).
guide-structure/Validate typed guide section order and guide-template rules.
rule-structure/Validate, fix, normalize, score, and review inline-link opportunities in rule MDX.
validate/Validate sources (URLs) and package dependency consistency.
audit/MCP audit tools.

Root: setup-qmd.sh — QMD setup/embed (run via pnpm qmd:setup / pnpm qmd:embed).


Core (CI / lefthook)

These run in CI or on commit; keep them.

CommandWhat it doesUsed by
pnpm validate:rule-structureValidates rule section order and final ## Verification heading.CI, lefthook (on rule MDX changes)
pnpm validate:guide-structureValidates guide section order by type (how-to or insight).CI, guide authoring
pnpm validate:guidesEnforces guide publish-readiness checks (cover image, links, reading level, metadata).CI, guide authoring
pnpm score:rulesScores rules (≥50 to pass); fails commit if changed rules are below threshold.Lefthook (on rule MDX changes)
pnpm generate:skillsRegenerates skills/ from rule MDX.Lefthook (on rule MDX changes)
pnpm generate:readmeRegenerates the README checklist and generated catalog from rule MDX.Lefthook (on rule MDX changes)
pnpm validate:evidenceValidates source quality metadata on rules.CI, rule authoring

Rule authoring

For writing or editing rules in packages/content/rules/en/.

CommandWhat it does
pnpm validate:rule-structureCheck structure; use --report for category drift.
pnpm report:v2-gapsSame as validate:rule-structure --report (conditional V2 gaps).
pnpm score:rulesScore rules; --failing, --json, --min 60, or pass file paths.
pnpm fix:rule-structureAuto-fix section order/headings (--write).
pnpm normalize:rule-structureNormalize verification heading and trailing sections (--write).
pnpm expand:related-rulesExpand relatedRules frontmatter (--write).
pnpm backfill:inline-linksBackfill sparse rule bodies with light-touch inline links (--category, --write).
pnpm report:rule-linksReview inline-link density, warnings, and candidate internal/external links (--category, --json).
pnpm inject:rule-linksDeprecated alias for pnpm report:rule-links; read-only and no longer edits files.

See AGENTS.md and docs/rule-structure.md for full workflows.


Guide authoring

For writing or editing guides in packages/content/guides/en/.

CommandWhat it does
pnpm validate:guide-structureCheck required section order for how-to and insight guides.
pnpm validate:guidesEnforce publish-readiness: required frontmatter, cover image, links, minimum depth, and readability.
pnpm test:guide-structureRun guide structure and guide validation tests.

See docs/guides-authoring.md and docs/guide-template.mdx.


Generate (from rules)

Regenerate derived content. Run after changing rules or when updating hints/support data.

CommandWhat it does
pnpm generate:skillsRegenerate skills/ (SKILL.md + references) from rule MDX.
pnpm generate:readmeRegenerate the root README checklist and the generated catalog copy.
pnpm generate:exceptions-hintsDry-run suggestions for missing ## Exceptions sections.
pnpm generate:support-notesDry-run support-note suggestions from browser data.
pnpm generate:verification-splitDry-run ## Verification automated/manual split suggestions.
pnpm backfill:sourcesNormalize source ids, roles, and authorities on rule MDX.
pnpm backfill:evidenceAlias for pnpm backfill:sources while the old command name is still referenced.

Validate

CommandWhat it does
pnpm validate:sourcesValidate external URLs in rule frontmatter (sources, resources).
pnpm validate:evidenceValidate source metadata: minimum sources, source roles, primary sources, and category-specific source quality.
pnpm validate:packagesCheck package dependency consistency across the monorepo.

Audit

CommandWhat it does
pnpm mcp:auditMCP quality pipeline (unit tests + optional security scan). See docs/mcp-quality.md.
pnpm mcp:audit:securityRun mcp-security-auditor on packages/mcp/src.
pnpm mcp:evaluateRun deterministic MCP quality evals for retrieval, review accuracy, tool contracts, and improvement impact.
pnpm mcp:impact -- --init <dir>Create an A/B benchmark workspace for testing whether MCP access improves agent code fixes.
pnpm mcp:impact -- --score <dir>Score no-MCP vs MCP benchmark outputs.
pnpm mcp:impact -- --self-testVerify the impact benchmark scorer with built-in fixed fixtures.
pnpm skills:auditScore generated skills against agent-skill patterns and report high-value missing rule candidates.

Validation (pre-commit)

Lefthook runs these automatically; you can run individual checkers manually if needed.

ScriptPurpose
scripts/validation/check-as-casts.jsTypeScript as cast validation.
scripts/validation/check-barrel-files.jsBarrel file (re-export) rules.
scripts/validation/check-console-logs.jsDisallow stray console.log in app code.
scripts/validation/check-directory-structure.jsEnforce directory layout.
scripts/validation/check-file-complexity.jsFile complexity limits.
scripts/validation/check-jsdoc.jsJSDoc rules.
scripts/validation/check-relative-imports.tsEnforce path aliases in apps/web (no deep relative imports).

Tests

CommandWhat it does
pnpm test:rule-structureRun rule-structure lib and scoring tests.