git-workflow calls itself a router but named two of the six domains it routes to; the other four appeared nowhere in the file. All six are now named, with a routing table in the always-loaded body. git-submodules lost the foreach shell-variable semantics -- only the bare names survived, though $sm_path and $displaypath differ solely by which directory you are in. The table is back. Its relocated commands had also dropped the rtk git prefix its own SKILL.md mandates; 24 of them are re-prefixed. The wider rtk inconsistency across the plugin stays with #113. Also restores git-commits' body and footers output fields, git-branches' tag/ branch detection commands, git-worktrees' git config --worktree, pc-run's ambiguity fallback, git-remotes' git-history boundary, and git-history's pickaxe triggers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EJJrm5YmacbwMdzZpXcoti
62 lines
3.9 KiB
Markdown
62 lines
3.9 KiB
Markdown
---
|
|
name: pc-run
|
|
description: >
|
|
Use when the user wants to run pre-commit hooks, wire them into git, bump hook
|
|
revs, maintain the cache, or diagnose why a hook fails or never fires. Not
|
|
creating or editing the pre-commit config -> `pc-author`.
|
|
|
|
compatibility: Requires pre-commit installed and available on PATH.
|
|
|
|
metadata:
|
|
category: devtools
|
|
source_keys:
|
|
- context7-pre-commit-com
|
|
- pre-commit-com
|
|
|
|
allowed-tools: Bash Read
|
|
---
|
|
|
|
## Gotchas
|
|
|
|
- The `SKIP` env var takes exact hook `id` values, comma-separated with no spaces: `SKIP=check-yaml,gitleaks git commit -m "msg"`. A space after a comma silently skips nothing instead of erroring.
|
|
- Never bypass a failing hook with `git commit --no-verify` (or `-n`). Hooks are the automated QA gate, so a bypassed commit pushes the failure downstream where it costs more — diagnose it instead.
|
|
- `- files were modified by this hook` is not a bug. A fixer hook rewrote a staged file, so the staged snapshot is stale and the commit is blocked on purpose. Re-stage and re-run the same commit: `git add -u && git commit`. Do NOT reach for `pre-commit install -f` here — it overwrites `.git/hooks/` and has nothing to do with re-staging.
|
|
|
|
## Gate — `pre-commit clean`
|
|
|
|
Confirm with the user before running `pre-commit clean`, on every path that reaches it — including when it turns up as the fix for a stale or broken environment. It wipes the whole cache at `~/.cache/pre-commit`, which is machine-wide and shared by every repo on the box, forcing every hook environment to be re-downloaded.
|
|
|
|
> "This will wipe the entire pre-commit cache. All hook environments will be re-downloaded on next run. Proceed?"
|
|
|
|
`pre-commit gc` drops only unused environments and needs no confirmation — prefer it when the goal is just to reclaim disk.
|
|
|
|
## Route
|
|
|
|
Determine intent from the user's request, then execute the matching operation. Where the matching row names a `references/` file, read that one file and no other — each flow file is self-contained.
|
|
|
|
| User intent | Operation |
|
|
|---|---|
|
|
| "run", "check", "verify", "test hooks" | `pre-commit run --all-files` (default) |
|
|
| "staged", "simulate commit" | `pre-commit run` (staged files only) |
|
|
| "CI", "changed files only", "diff range" | `pre-commit run --from-ref <base> --to-ref <head>` — prefer this over `--all-files` on large repos |
|
|
| "install", "set up hooks", "wire into git" | `pre-commit install` — read `references/install.md` |
|
|
| "pre-create environments", "warm cache" | `pre-commit install-hooks` — builds every hook environment without running a hook |
|
|
| "remove hooks", "uninstall", "tear down" | `pre-commit uninstall` — removes pre-commit from `.git/hooks/` |
|
|
| "autoupdate", "update versions", "bump revs" | `pre-commit autoupdate` — read `references/autoupdate.md` |
|
|
| "gc", "garbage collect" | `pre-commit gc` — drops unused cached environments only, safe at any time |
|
|
| "clean", "wipe cache", "rebuild from scratch" | `pre-commit clean` — read `references/clean.md` |
|
|
| "hooks aren't running", "hook never fires", "why did a hook fail", a hook failure whose cause is unclear | Diagnose — read `references/failure-patterns.md` |
|
|
|
|
If the intent is ambiguous, default to `pre-commit run --all-files` — do not stop to ask, and do
|
|
not fall through to a narrower row on a guess.
|
|
|
|
## Run
|
|
|
|
Default to `pre-commit run --all-files`; never silently narrow to staged files. Run `pre-commit run` (staged only) or `pre-commit run <hook-id>` (one named hook) when the user asks for it.
|
|
|
|
When hooks fail:
|
|
|
|
1. Name the hook and the specific cause. Be concrete — "gitleaks blocked `config.json` (high-entropy string on line 12)", not "gitleaks failed".
|
|
2. Suggest one concrete next step. Common causes and their concrete fixes are in `references/failure-patterns.md` — read it whenever the output does not already name the fix.
|
|
3. Do not auto-fix code files, and do not edit `.pre-commit-config.yaml` — those belong to the user or to `pc-author`.
|