TrueCourse Hooks
Install, configure, and manage the pre-commit hook that blocks new violations before they land in git.
Important
- Always invoke via
npx -y — without -y, npx will hang on the "Ok to proceed?" prompt whenever the user hasn't cached the latest truecourse version.
- The hook makes commits slower. Every commit runs
truecourse analyze --diff. On large repos that can be tens of seconds per commit. Make sure the user knows before you install.
- Baseline required. The hook diffs against
.truecourse/LATEST.json. The user needs truecourse analyze to have run at least once. On main, they should also commit the resulting LATEST.json so the hook works in fresh clones and git worktree add checkouts without a per-checkout cold-start. If no baseline exists yet, suggest /truecourse-analyze first.
hooks.yaml is the single source of truth. Installation creates <repo>/.truecourse/hooks.yaml with defaults; edit it to change policy. The file is meant to be committed so the whole team shares one hook config.
Instructions
1. Figure out what the user wants
- "install", "set up", "enable" → Install flow
- "status", "is the hook active", "what does it block" → Status flow
- "uninstall", "remove", "disable" → Uninstall flow
- "change what blocks", "make it stricter/looser", "add/remove severities", "enable LLM" → Configure flow
2. Install flow
- Tell the user the tradeoff upfront: commits will be slower; the hook needs a
.truecourse/LATEST.json baseline (run analyze on main and commit the file so it propagates to clones and worktrees); policy lives in .truecourse/hooks.yaml which they should also commit.
- Run:
npx -y truecourse hooks install
- Relay the output. Two files get created:
.git/hooks/pre-commit (the script git invokes)
.truecourse/hooks.yaml (starter policy, blocks critical and high by default, LLM off)
- If the user hasn't run a full analysis in this repo, suggest
/truecourse-analyze — without a baseline, the hook has nothing to diff against. After analyze on main, also remind them to commit .truecourse/LATEST.json so fresh worktrees/clones inherit it.
3. Status flow
Run:
npx -y truecourse hooks status
Relay the output. It reports whether the hook is installed, the config path, the block severities, and whether LLM is on.
4. Uninstall flow
Run:
npx -y truecourse hooks uninstall
Only removes the git hook script. hooks.yaml is preserved (it's team policy, not install state).
5. Configure flow
The config lives at <repo>/.truecourse/hooks.yaml. Use the Read and Edit tools — do not shell out through truecourse for edits.
Schema:
pre-commit:
block-on: [critical, high] # valid: info, low, medium, high, critical
llm: false # true = LLM rules on every commit (tokens per commit)
Common edits the user might ask for:
- Stricter ("block medium too"):
block-on: [critical, high, medium]
- Permissive ("only block criticals"):
block-on: [critical]
- Enable LLM ("run full checks on commit"): set
llm: true. Warn the user this spends tokens on every commit — confirm before flipping it.
After editing, run npx -y truecourse hooks status so they can verify the parsed values match their intent.
6. When the user hits a blocked commit
If a user comes to you saying "my commit got blocked" or similar:
- The hook's stdout already listed the blocking violations (file, line, title, severity).
- Offer to run
/truecourse-fix to apply fix suggestions to those violations.
- If they want to ship anyway, remind them of
git commit --no-verify (standard git bypass).
1---2name: truecourse-hooks3description: Install, configure, or remove the TrueCourse pre-commit hook4---56# TrueCourse Hooks78Install, configure, and manage the pre-commit hook that blocks new violations before they land in git.910## Important1112- **Always invoke via `npx -y`** — without `-y`, npx will hang on the "Ok to proceed?" prompt whenever the user hasn't cached the latest `truecourse` version.13- **The hook makes commits slower.** Every commit runs `truecourse analyze --diff`. On large repos that can be tens of seconds per commit. Make sure the user knows before you install.14- **Baseline required.** The hook diffs against `.truecourse/LATEST.json`. The user needs `truecourse analyze` to have run at least once. On `main`, they should also commit the resulting `LATEST.json` so the hook works in fresh clones and `git worktree add` checkouts without a per-checkout cold-start. If no baseline exists yet, suggest `/truecourse-analyze` first.15- **`hooks.yaml` is the single source of truth.** Installation creates `<repo>/.truecourse/hooks.yaml` with defaults; edit it to change policy. The file is meant to be committed so the whole team shares one hook config.1617## Instructions1819### 1. Figure out what the user wants2021- "install", "set up", "enable" → **Install flow**22- "status", "is the hook active", "what does it block" → **Status flow**23- "uninstall", "remove", "disable" → **Uninstall flow**24- "change what blocks", "make it stricter/looser", "add/remove severities", "enable LLM" → **Configure flow**2526### 2. Install flow27281. Tell the user the tradeoff upfront: commits will be slower; the hook needs a `.truecourse/LATEST.json` baseline (run analyze on `main` and commit the file so it propagates to clones and worktrees); policy lives in `.truecourse/hooks.yaml` which they should also commit.292. Run:30 ```31 npx -y truecourse hooks install32 ```333. Relay the output. Two files get created:34 - `.git/hooks/pre-commit` (the script git invokes)35 - `.truecourse/hooks.yaml` (starter policy, blocks `critical` and `high` by default, LLM off)364. If the user hasn't run a full analysis in this repo, suggest `/truecourse-analyze` — without a baseline, the hook has nothing to diff against. After analyze on `main`, also remind them to commit `.truecourse/LATEST.json` so fresh worktrees/clones inherit it.3738### 3. Status flow3940Run:41```42npx -y truecourse hooks status43```44Relay the output. It reports whether the hook is installed, the config path, the block severities, and whether LLM is on.4546### 4. Uninstall flow4748Run:49```50npx -y truecourse hooks uninstall51```52Only removes the git hook script. `hooks.yaml` is preserved (it's team policy, not install state).5354### 5. Configure flow5556The config lives at `<repo>/.truecourse/hooks.yaml`. Use the Read and Edit tools — do not shell out through `truecourse` for edits.5758Schema:59```yaml60pre-commit:61 block-on: [critical, high] # valid: info, low, medium, high, critical62 llm: false # true = LLM rules on every commit (tokens per commit)63```6465Common edits the user might ask for:66- **Stricter** ("block medium too"): `block-on: [critical, high, medium]`67- **Permissive** ("only block criticals"): `block-on: [critical]`68- **Enable LLM** ("run full checks on commit"): set `llm: true`. Warn the user this spends tokens on every commit — confirm before flipping it.6970After editing, run `npx -y truecourse hooks status` so they can verify the parsed values match their intent.7172### 6. When the user hits a blocked commit7374If a user comes to you saying "my commit got blocked" or similar:75- The hook's stdout already listed the blocking violations (file, line, title, severity).76- Offer to run `/truecourse-fix` to apply fix suggestions to those violations.77- If they want to ship anyway, remind them of `git commit --no-verify` (standard git bypass).