set-up-hooks
Set up recommended git hooks in the current repository. Strips Claude and Copilot co-author lines from commit messages, and runs the repo's tests before each commit when it has any. Use only when the user explicitly asks to set up hooks.
- License 许可
- MIT
- 最近更新
- 2026-11-02
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- set-up-hooks
- license
- MIT
- description
- Set up recommended git hooks in the current repository. Strips Claude and Copilot co-author lines from commit messages, and runs the repo's tests before each commit when it has any. Use only when the user explicitly asks to set up hooks.
- compatibility
- Claude Code, GitHub Copilot CLI
- disable-model-invocation
- true
03 SKILL.md 正文
Set up hooks
Run this skill by hand from the repository, once per clone. It writes hooks into the hooks directory that git uses in this clone. It never changes core.hooksPath, so other repositories and other machines are unaffected.
Steps
-
Find the hooks directory. Run
git rev-parse --git-path hooks. Stop and report if the command fails.- Done when you have the path.
-
Check for existing hooks. Look at
commit-msgandpre-commitin that directory. A file whose second line is# set-up-hooksis ours and may be replaced. Any other existing file: stop and ask the user before replacing it.- Done when neither file belongs to someone else.
-
Choose the test command for
pre-commit. Use the first match below, and ask the user if more than one applies:package.jsonwith atestscript:npm test, orpnpm testoryarn testwhenpnpm-lock.yamloryarn.lockexists.go.mod:go test ./...Cargo.toml:cargo test*.slnor*.csproj:dotnet testpyproject.toml,pytest.ini, or atests/directory:pytest- a
testtarget inMakefile:make test
If nothing matches, ask the user for the command, or skip
pre-commitif the repo has no tests.- Done when you have a command, or the user has chosen to skip it.
-
Write the hooks. Create the hooks directory if it is missing. Write
commit-msgfrom the template below. Writepre-commitonly when you have a test command. Make each file you write executable.- Done when the files exist and are executable.
-
Verify and report. Run
sh -non each file you wrote. Report the hook paths, the test command, and thatcore.hooksPathis unchanged. Tell the user the hooks apply to this clone only, so the skill must be run in each clone. Do not usegit commit --no-verifyto get past a hook unless the user asks.
Templates
commit-msg:
#!/bin/sh
# set-up-hooks
set -eu
msg=$1
tmp="$msg.tmp"
grep -viE '^Co-authored-by:.*(claude|copilot|@anthropic\.com)' "$msg" > "$tmp" &&
mv "$tmp" "$msg"
pre-commit, only with a test command:
#!/bin/sh
# set-up-hooks
set -eu
<test command>
04 同仓库更多 Skills
sopra-steria-brand
Apply Sopra Steria brand styling to a presentation, document, web page, diagram, or other artifact when the user explicitly wants Sopra Steria branding or refers to Sopra Steria brand rules, colors, typography, logo usage, or corporate visual identity. Do not use for generic design polish or unrelated branding work.
skill-creator
Create, review, and improve skills in this repository for GitHub Copilot CLI and Claude Code. Use when drafting a new skill, revising an existing skill under plugins/my-plugin/skills/, tightening trigger boundaries, or making a skill leaner and more portable.
set-up-workflow
Set up how this repo's issues and tickets are handled. Runs setup-matt-pocock-skills, then records the spec and ticket workflow under "Issue tracker" in AGENTS.md. Use only when the user explicitly asks to set up the workflow.
set-up-my-plugin
Copy the minimalist-engineering principles into the user-level instruction files for Claude Code and Copilot CLI.
set-up-github
Set up a GitHub repository for trunk-based development. Squash-only merges with the PR title as the commit title, head branches deleted on merge, and a pull request required for the default branch. When the repo has CI, also requires named checks to pass and the branch to be up to date before merge. Use only when the user explicitly asks to set up GitHub.
minimalist-engineering
Keep code minimal and avoid over-engineering.