#!/bin/sh # Creates the files listed below and nothing else. Read it before you run it. set -eu [ ! -e 'CLAUDE.md' ] || { echo "CLAUDE.md already exists; nothing was written." >&2; exit 1; } [ ! -e '.claude/settings.json' ] || { echo ".claude/settings.json already exists; nothing was written." >&2; exit 1; } [ ! -e '.claude/hooks/protect-migrations.mjs' ] || { echo ".claude/hooks/protect-migrations.mjs already exists; nothing was written." >&2; exit 1; } [ ! -e '.claude/skills/pre-commit-check/SKILL.md' ] || { echo ".claude/skills/pre-commit-check/SKILL.md already exists; nothing was written." >&2; exit 1; } mkdir -p '.' cat > 'CLAUDE.md' <<'GROUNDWORK_EOF' # Bookings demo A tiny room-booking library in plain Node (ES modules). No dependencies. ## Commands - Run tests: `npm test` ## Rules - Business logic goes in `src/`, with a test in `test/` for every behaviour change. - Files already in `migrations/` are applied. Never edit them; add the next numbered file. - Don't add dependencies without asking. GROUNDWORK_EOF mkdir -p '.claude' cat > '.claude/settings.json' <<'GROUNDWORK_EOF' { "permissions": { "deny": ["Read(./.env)"] }, "hooks": { "PreToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-migrations.mjs" } ] } ] } } GROUNDWORK_EOF mkdir -p '.claude/hooks' cat > '.claude/hooks/protect-migrations.mjs' <<'GROUNDWORK_EOF' // Blocks edits to migration files that already exist. New migration files are allowed. import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; const input = JSON.parse(readFileSync(0, "utf8")); const file = input.tool_input?.file_path ?? ""; const inMigrations = path.basename(path.dirname(file)) === "migrations"; if (inMigrations && existsSync(file)) { console.error(`Blocked: ${path.basename(file)} is already applied. Add a new numbered migration instead.`); process.exit(2); } GROUNDWORK_EOF mkdir -p '.claude/skills/pre-commit-check' cat > '.claude/skills/pre-commit-check/SKILL.md' <<'GROUNDWORK_EOF' --- name: pre-commit-check description: Check uncommitted changes before committing. Use when asked to check, review or commit work in this project. --- 1. Run `git status --short` and `git diff` to see what changed. 2. Run `npm test`. If it fails, stop and report the failure. 3. Report each item as ok or problem, with the file name: - every behaviour change in `src/` has a test - no existing file in `migrations/` was edited - no secret or `.env` file is about to be committed 4. Do not commit and do not edit files. GROUNDWORK_EOF echo "Created 4 files."