truecourse-hooks
GitHub管理 TrueCourse pre-commit 钩子,支持安装、状态查询、卸载及配置策略。用于在代码提交前拦截违规,需确保基线文件存在并告知用户性能影响。
Trigger Scenarios
Install
npx skills add truecourse-ai/truecourse --skill truecourse-hooks -g -y
SKILL.md
Frontmatter
{
"name": "truecourse-hooks",
"triggers": [
"install the pre-commit hook",
"set up truecourse hooks",
"enable truecourse hook",
"check hook status",
"remove pre-commit hook",
"change what the hook blocks",
"edit hook config"
],
"description": "Install, configure, or remove the TrueCourse pre-commit hook",
"user_invocable": true
}
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 latesttruecourseversion. - 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 needstruecourse analyzeto have run at least once. Onmain, they should also commit the resultingLATEST.jsonso the hook works in fresh clones andgit worktree addcheckouts without a per-checkout cold-start. If no baseline exists yet, suggest/truecourse-analyzefirst. hooks.yamlis the single source of truth. Installation creates<repo>/.truecourse/hooks.yamlwith 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.jsonbaseline (run analyze onmainand commit the file so it propagates to clones and worktrees); policy lives in.truecourse/hooks.yamlwhich 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, blockscriticalandhighby 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 onmain, also remind them to commit.truecourse/LATEST.jsonso 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-fixto apply fix suggestions to those violations. - If they want to ship anyway, remind them of
git commit --no-verify(standard git bypass).
Version History
- 656fd57 Current 2026-07-24 22:39


