pre-commit
Skill1 starsChanged 3 days agoMITView on GitHub
Set up the xstyle pre-commit hook of a git repository in Tsukini's way - checks the style of what is committed with xstyle (only the staged lines by default), refuses the commit on a major / unforgivable issue, warns on minor ones, only warns when xstyle is not installed - every option asked first with several choices (scope, fail / warn levels, safe auto fixes, missing xstyle, output, languages / excludes / ignored rules, local or shared .githooks), the needed tools checked and installed on request (xstyle, cmake, clang++, libutils), an existing hook kept and chained, and a throwaway demo repository to try it. Use whenever the user wants a pre-commit hook, a git hook checking the style, to block commits with style errors, or to change / remove that hook.
- Pipes a download into a shell
12 other projects use a version of this.
Adopted by
Most recently taken up by
- GoogleCloudPlatform/cloud-solutionstheir own version, first seen Nov 1, 2026
- goulvenclech/dotclaudetheir own version, first seen Oct 13, 2026
- wellwelwel/pokutheir own version, first seen Oct 8, 2026
- mihai-dinculescu/tapotheir own version, first seen Oct 8, 2026
- benyoskovitz/claude-code-workflowtheir own version, first seen Sep 24, 2026
- RealDougEubanks/ClaudeMarketplacetheir own version, first seen Sep 10, 2026
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- wellwelwel/poku★ 1.2ksame name
- mihai-dinculescu/tapo★ 870same name
- GoogleCloudPlatform/cloud-solutions★ 140same name
- benyoskovitz/claude-code-workflow★ 8same name
- goulvenclech/dotclaude★ 5same name
- autowarefoundation/autoware-harness★ 4same name
- Cogni-AI-OU/cogni-ai-agent-skills★ 4same name
- alex-voloshin-dev/ai-skills★ 2same name
- flying-dice/pseudoscript★ 2same name
- Pradnyeshp/Claude-Skills★ 2same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository70 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ask-at-endSkill
- clarifySkill
- continue-workSkill
- exportSkill
- full-permissionSkill
- ideationSkill
- interactive-questionsSkill
- onboardSkill
- pauseSkill
- presentationSkill
- rtkSkill
- setup-contextSkill
- write-like-meSkill
- audit-bugsSkill
- audit-depsSkill
- audit-qualitySkill
- audit-securitySkill
- benchmarkSkill
- cmake-styleSkill
- cpp-classSkill
- cpp-commentsSkill
- cpp-projectSkill
- cpp-styleSkill
- better-explain-docSkill
- better-html-docSkill
- better-html-styleSkill
- better-protocol-docSkill
- docs-updateSkill
- explain-docSkill
- html-docSkill
- html-styleSkill
- protocol-docSkill
- readme-styleSkill
- reportSkill
- wiki-styleSkill
- ci-cdSkill
- git-commitSkill
- git-conventionsSkill
- legal-checkSkill
- legal-setupSkill
- licenseSkill
- libutils-exceptionSkill
- libutils-installSkill
- libutils-setupSkill
- libutilsSkill
- python-classSkill
- python-commentsSkill
- python-projectSkill
- python-styleSkill
- auditSkill
- cppSkill
- devSkill
- docSkill
- gitSkill
- legalSkill
- pythonSkill
- setup-projectSkill
- styleSkill
- setup-studioSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 12 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 42
Ask all of them, even when a default exists (only skip what the request already says).
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
xstyle pre-commit hook
SKILL_DIR = the directory of this file.
templates/pre-commit: the hook (bash, config block at the top, readable by the user).scripts/install_hook.sh install|remove|status [options](--help), alsocurl -fsSL https://raw.githubusercontent.com/TsukiNi22/ai-utils/main/setup.sh | bash -s -- hook [command] [options]run from the repository.scripts/demo_repo.sh [dir] [options]: throwaway repository (/tmp/xstyle-hook-demo) with one file per verdict andTRY.mdlisting the scenarios.
The hook runs locally at each git commit (before the commit exists), never on GitHub: the remote check is the
style job of ci-cd (templates/style.yml). Both are complementary (local = fast feedback, skippable; CI = enforced).
Behavior (defaults)
| Case | Result |
| xstyle not installed | warning xstyle not found, commit accepted (--missing warn) |
| unforgivable / major issue | issues listed, commit refused (--fail-on major) |
| minor issue only | issues listed + warning, commit accepted (--warn-on minor) |
| negligible only / clean | silent, commit accepted |
| mandatory rule (R34) | never counted: neither refuses nor warns; shown with the issues when xstyle prints them (--r34 / XSTYLE_R34=1 or --extra "--r34" hides it) |
| xstyle crashes | warning, commit accepted (never blocks on a tool error) |
Skip once: git commit --no-verify or XSTYLE_HOOK=0 git commit .... Fix: xstyle --fix --staged then git add -u. | |
Output: human (colors, source) in a terminal, --rtk automatically under Claude Code (CLAUDECODE) or XSTYLE_RTK=1. |
1. Check the context (in parallel)
git rev-parse --show-toplevel(not a repository: proposegit init), an existing hook (install_hook.sh status),git config core.hooksPath, a.pre-commit-config.yaml(framework pre-commit: propose alocalhookxstyle --staged --fail-on majorin it instead, ask).- Tools:
command -v xstyle(xstyle --version), else what building it needs:cmake,clang++, libutils (pkg-config --exists utilsor/usr/local/include/utils). - Languages of the repository (
git ls-files | sed 's/.*\.//' | sort | uniq -c | sort -rn | head) and the build / generated / vendored folders (build,_deps,third_party...) to propose in the questions.
2. Ask every option (AskUserQuestion, French, recommended first)
Ask all of them, even when a default exists (only skip what the request already says). Two calls of up to 4 questions:
Call 1
- Bloquer le commit à partir de (
--fail-on):major (Recommandé: major + unforgivable)·unforgivable seulement·minor (strict)·jamais (avertir seulement). - Avertir à partir de (
--warn-on):minor (Recommandé)·negligible (tout)·aucun avertissement. - Portée (
--scope):Lignes indexées seulement (Recommandé: n'impose pas de corriger le code existant)·Fichiers indexés entiers·Tout le projet (lent). - xstyle absent (
--missing):Avertir et laisser passer (Recommandé)·Refuser le commit·Ignorer en silence.
Call 2
- Corrections automatiques (
--fix):Non, seulement signaler (Recommandé)·Oui, les corrections sûres des fichiers entièrement indexés (ré-ajoutés au commit). - Installation (
--shared/--link):Locale à ce clone (.git/hooks, Recommandé)·Partagée et versionnée (.githooks + core.hooksPath, toute l'équipe)·Lien vers le template (suit les mises à jour des skills). - Filtres (multiSelect,
--extra):Exclure les dossiers générés (<the folders found>)·Seulement <top languages>·Ignorer des règles (lesquelles ?)·Aucun. - Sortie (
--output):Auto (Recommandé: lisible au terminal, compacte sous Claude Code)·Toujours lisible·Toujours compacte (--rtk). Then, when xstyle is missing (only if): Installer xstyle ?Oui, via my-universe (Recommandé)(curl -fsSL https://tsukini22.github.io/my-universe/install.sh | bash -sthensudo dnf|apt|pacman install xstyle(packages of my-universe, sources: TsukiNi22/xstyle; no curl:wget -qO-instead ofcurl -fsSL)) ·Non, le hook avertira seulement; libutils missing for the build: thelibutils-installskill (ask first), cmake / clang++ missing: give thednf/aptcommand (root throughSUDO_ASKPASS=~/.local/bin/sudo-askpass sudo -A, ask). Last: Dépôt de démonstration ?Oui, /tmp/xstyle-hook-demo pour essayer·Non.
3. Install
bash SKILL_DIR/scripts/install_hook.sh install --repo <root> --fail-on major --warn-on minor --scope staged \
--missing warn --fix none --output auto [--extra "-e build,_deps -l cpp,py -i CPP-AUTO"] [--shared | --link]- A hook already there (not xstyle's) is kept as
pre-commit.localand run first (--forcedrops it: ask). - A reinstall starts from the defaults + the given options (the config block is rewritten);
--linkkeeps the template as is (no option). --shared: commit.githooks/(withgit-conventions, only if the user asks for the commit) and tell the team commandgit config core.hooksPath .githooks.- Demo:
bash SKILL_DIR/scripts/demo_repo.sh /tmp/xstyle-hook-demo <same options>, then point to itsTRY.md.
4. Verify and report
install_hook.sh status --repo <root> (config shown), then one real run without committing:
git stash -k is never used; run the hook directly: .git/hooks/pre-commit; echo $? (it checks the staged lines; with
nothing staged it exits 0). Report: where the hook is, the chosen options, what is refused / warned, how to skip it,
how to change it (curl -fsSL https://raw.githubusercontent.com/TsukiNi22/ai-utils/main/setup.sh | bash -s -- hook --fail-on minor) or remove it (... | bash -s -- hook remove):
the commands given to the user always use the remote form (the user may not have the ai-utils repository locally),
with the download tool of the machine: curl -fsSL <url> | bash -s -- ..., else wget -qO- <url> | ..., else
python3 -c 'import sys, urllib.request; sys.stdout.buffer.write(urllib.request.urlopen(sys.argv[1]).read())' <url> | ...,
else the curl form (command -v curl wget python3); the scripts of this skill already print it that way.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

