Skip to content

feat: adopt cross-repo tooling (migration safety, hooks, config schema, verify-all) - #141

Merged
PAMulligan merged 11 commits into
mainfrom
feature/tooling-adoption
Sep 9, 2026
Merged

PAMulligan merged 11 commits into
mainfrom
feature/tooling-adoption

Conversation

@PAMulligan

Copy link
Copy Markdown
Contributor

Summary

Adopts tooling patterns from sibling repos (Aurelius, Bridleway, Maecenas, FantasyPlanner, optia-backend) that close gaps Nerva's own config and docs already promised but nothing enforced.

  • Migration safety (from Bridleway): check-destructive-migrations.js scans migration SQL for DROP/TRUNCATE/unbounded DELETE with a per-file allowlist marker; generate-migration.sh runs it before applying. Generated projects get schema-drift.ts (Drizzle schema vs production DB, lenient PR gate and strict daily mode) plus schema-drift.yml and schema-applied.yml workflows that degrade gracefully without the PROD_DATABASE_URL secret.
  • Claude Code hooks (from FantasyPlanner, Aurelius, Flavian): .claude/settings.json wires a secret guard and a prod-DB guard (PreToolUse, blocking) and coverage, migration-safety and quality-gate reminders (PostToolUse).
  • Shared script lib (from Aurelius): scripts/lib replaces the duplicated color/log blocks; scripts now read tdd.coverageThreshold, security.audit.*, testing.loadTest* and database.blockDestructiveMigrations from pipeline.config.json, which were previously inert.
  • Config schema + validator: strict JSON Schema for pipeline.config.json and an ajv validator with phase-graph cycle/reachability checks.
  • Framework integrity: check-doc-counts.sh (fixes the plugin/script count drift in CLAUDE.md and README), check-prerequisites.sh, and verify-all.sh backing new /verify-all and /ci commands.
  • Script tests: 264 Vitest tests under scripts/__tests__, run by a new script-tests CI job and extended pre-commit hook.
  • Cloudflare template hardening (from optia-backend): production disables workers_dev/preview_urls, stamps COMMIT_SHA, gets deploy:staging/deploy:production, refuses a bare deploy.
  • Fix: generated projects ship a pnpm-workspace.yaml allowing esbuild/workerd install scripts (onlyBuiltDependencies for pnpm 10, allowBuilds for pnpm 11+) and pin packageManager. Without it, project generation fails under pnpm 12 with ERR_PNPM_IGNORED_BUILDS outside the repo checkout.

Docs: scripts/README.md, docs/api-development/migration-safety.md, docs/onboarding/hooks.md.

Test plan

  • pnpm test: 264 tests, 8 files pass
  • scripts/verify-all.sh: all applicable checks pass on the framework repo
  • templates/snippets: pnpm typecheck passes under cloudflare, node and lambda tsconfigs
  • Generated --cloudflare and --node projects (on pnpm 12): install, pnpm typecheck, pnpm test, pnpm db:check-destructive pass; pnpm run deploy is refused
  • --lambda --dry-run keeps deploy.yml alongside the two schema workflows
  • CI script-tests and generated-projects jobs green on this PR
  • Not exercised: drift check against a live PostgreSQL; hooks inside a live Claude Code session; the schema workflows in a real Actions run

🤖 Generated with Claude Code

@github-actions github-actions Bot added area: scripts Automation scripts area: templates Starter templates area: pipeline Build pipeline area: ci-cd CI/CD workflows area: docs Documentation labels Sep 9, 2026
Comment on lines +21 to +28
const stdout = execFileSync(cmd, args, {
encoding: "utf-8",
cwd,
timeout,
input,
env: { ...process.env, NO_COLOR: "1", ...env },
stdio: ["pipe", "pipe", "pipe"],
});
Paul Mulligan and others added 11 commits September 9, 2026 16:39
Introduce scripts/lib (common.sh, colors.sh, pipeline-config.js) so scripts
share one set of log helpers, project-root resolution, and a reader for
.claude/pipeline.config.json, plus a Vitest harness under scripts/__tests__
and the pnpm test/verify/validate scripts. Adapted from the Aurelius
scripts/lib pattern.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eline.config.json

Drop the duplicated color and log definitions from every script. run-tests.sh
now enforces tdd.coverageThreshold via the json-summary reporter,
security-scan.sh honors security.audit.level/failOnVulnerability/checkLockfile,
load-test.sh defaults VUs, duration and k6 thresholds from testing.*, and
check-types.sh reports 'any' usage when qualityGate.noAnyTypes is set.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
check-destructive-migrations.js scans migration SQL for DROP/TRUNCATE/unbounded
DELETE after stripping comments, with a per-file allowlist marker, and
generate-migration.sh runs it before applying when
database.blockDestructiveMigrations is on. schema-drift.ts compares the Drizzle
schema against a production database in lenient (PR gate) or strict (daily)
mode; schema-drift.yml and schema-applied.yml ship as generated-project
workflows. Adapted from the Bridleway migration-safety scripts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…uality reminders

PreToolUse: secret-guard blocks staging .env/.dev.vars/key files and forced
adds; prod-db-guard blocks drizzle-kit push and DROP/TRUNCATE against
production. PostToolUse: coverage-check, migration-safety-reminder and
quality-gate-reminder. Hooks read the stdin JSON contract, fail open on
malformed input, and are covered by scripts/__tests__/hooks.test.js.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Strict draft 2020-12 schema for every section of pipeline.config.json, and
validate-pipeline-config.js (ajv) with structural checks the schema cannot
express: phase dependency targets, cycles, reachability, defaultTarget in
targets, and coverage-threshold consistency. The config now points $schema at
the project schema.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Reports required software, optional tools, Claude Code plugins and project
state as [PASS]/[FAIL]/[SKIP]/[INFO] lines with a summary block and --json.
The claude CLI and plugins never block readiness.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
check-doc-counts.sh fails when Markdown claims about agent, skill, script or
command counts disagree with disk. verify-all.sh runs every local check with
--json/--ci/--skip/--include and skips checks whose subject is absent; it backs
the new /verify-all and /ci slash commands.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…pts, install migration checks

Generated Cloudflare projects disable workers_dev and preview URLs in
production, stamp COMMIT_SHA on deploy, get deploy:staging/deploy:production
scripts, and refuse a bare deploy. Every project now ships a
pnpm-workspace.yaml allowing esbuild (and workerd) install scripts under pnpm
10 through 12, pins packageManager, and receives the destructive-DDL check,
schema-drift script, and both schema workflows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add a script-tests job (pnpm test, schema validation, doc counts) and extend
the structural job to hooks and JS scripts. The husky pre-commit hook now also
checks JS syntax, settings.json, the config schema, and doc counts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Add scripts/README.md, describe the hooks and /verify-all and /ci in
CLAUDE.md, and correct the plugin and script counts that had drifted.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Drop the PROJECT_ROOT variable left unused after the shared-lib refactor,
add shell directives to the sourced lib files, guard the cd in verify-all,
and annotate the hook lib variable consumed by sourcing hooks.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PAMulligan
PAMulligan force-pushed the feature/tooling-adoption branch from e17847d to 68abf49 Compare September 9, 2026 20:40
@PAMulligan
PAMulligan merged commit 3265a5d into main Sep 9, 2026
15 checks passed
@PAMulligan PAMulligan mentioned this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci-cd CI/CD workflows area: docs Documentation area: pipeline Build pipeline area: scripts Automation scripts area: templates Starter templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants