AGENT SKILL

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
所属仓库
olillevik/dotfiles
最近更新
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

  1. Find the hooks directory. Run git rev-parse --git-path hooks. Stop and report if the command fails.

    • Done when you have the path.
  2. Check for existing hooks. Look at commit-msg and pre-commit in that directory. A file whose second line is # set-up-hooks is 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.
  3. Choose the test command for pre-commit. Use the first match below, and ask the user if more than one applies:

    • package.json with a test script: npm test, or pnpm test or yarn test when pnpm-lock.yaml or yarn.lock exists.
    • go.mod: go test ./...
    • Cargo.toml: cargo test
    • *.sln or *.csproj: dotnet test
    • pyproject.toml, pytest.ini, or a tests/ directory: pytest
    • a test target in Makefile: make test

    If nothing matches, ask the user for the command, or skip pre-commit if the repo has no tests.

    • Done when you have a command, or the user has chosen to skip it.
  4. Write the hooks. Create the hooks directory if it is missing. Write commit-msg from the template below. Write pre-commit only when you have a test command. Make each file you write executable.

    • Done when the files exist and are executable.
  5. Verify and report. Run sh -n on each file you wrote. Report the hook paths, the test command, and that core.hooksPath is unchanged. Tell the user the hooks apply to this clone only, so the skill must be run in each clone. Do not use git commit --no-verify to 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

olillevik
olillevik/dotfiles

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.

★ 0
olillevik
olillevik/dotfiles

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.

★ 0
olillevik
olillevik/dotfiles

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.

★ 0
olillevik
olillevik/dotfiles

set-up-my-plugin

Copy the minimalist-engineering principles into the user-level instruction files for Claude Code and Copilot CLI.

★ 0
olillevik
olillevik/dotfiles

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.

★ 0
olillevik
olillevik/dotfiles

minimalist-engineering

Keep code minimal and avoid over-engineering.

★ 0