Skip to content

Commit fc3f80c

Browse files
committed
docs(git-hooks): skip manual hook run when git hook is already installed
Update the Committer agent and run-pre-commit/run-pre-push-checks skills to check whether the corresponding git hook is installed before invoking the pre-commit.sh / pre-push.sh script manually. When the hook is installed, git fires it automatically on commit/push, so a prior manual run would execute every check twice. Agents now use: [[ -x "$(git rev-parse --git-path hooks)/pre-commit" ]] to detect the installed hook and skip the redundant manual invocation.
1 parent 3987eba commit fc3f80c

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

.github/agents/committer.agent.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,22 @@ Treat every commit request as a review-and-verify workflow, not as a blind reque
3737
5. Check for obvious repository-policy violations in the diff (for example missing required spec
3838
progress updates, missing documented rationale where required, or similar policy blockers).
3939
If found, stop and return to the Implementer/Reviewer before committing.
40-
6. Run `./contrib/dev-tools/git/hooks/pre-commit.sh` when feasible. For AI execution, use
41-
`--format=json` first and retry with `--format=text --verbosity=verbose` if needed. If it fails:
42-
- **You may fix**: formatting, linting, spell-check, import organization, and similar
43-
metadata-only issues that are direct artifacts of the commit scope.
44-
- **You must not fix**: build failures, test failures, logic errors, or runtime issues.
45-
These are implementation defects; stop and return them to the **Implementer** to resolve.
40+
6. **Check if the pre-commit git hook is already installed** before running checks manually:
41+
42+
```bash
43+
[[ -x "$(git rev-parse --git-path hooks)/pre-commit" ]] && echo "installed" || echo "not installed"
44+
```
45+
46+
- **If installed**: do NOT run the script manually — `git commit -S` will trigger it
47+
automatically. Running it first would execute every check twice.
48+
- **If not installed**: run `./contrib/dev-tools/git/hooks/pre-commit.sh` manually.
49+
For AI execution, use `--format=json` first and retry with
50+
`--format=text --verbosity=verbose` if needed. If it fails:
51+
- **You may fix**: formatting, linting, spell-check, import organization, and similar
52+
metadata-only issues that are direct artifacts of the commit scope.
53+
- **You must not fix**: build failures, test failures, logic errors, or runtime issues.
54+
These are implementation defects; stop and return them to the **Implementer** to resolve.
55+
4656
7. Propose a precise Conventional Commit message.
4757
8. Create the commit with `git commit -S` only after the scope is clear and blockers are resolved.
4858
9. After committing, run a quick verification check and report the resulting commit summary.

.github/skills/dev/git-workflow/run-pre-commit-checks/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ automatically on every `git commit`. Install it once after cloning:
2020
After installation the hook fires automatically; you do not need to invoke the script
2121
manually before each commit.
2222

23+
> **For AI agents**: before invoking the script manually, check whether the hook is installed:
24+
>
25+
> ```bash
26+
> [[ -x "$(git rev-parse --git-path hooks)/pre-commit" ]] && echo "installed" || echo "not installed"
27+
> ```
28+
>
29+
> If installed, skip the manual run — `git commit` will trigger it automatically.
30+
> Running both would execute every check twice.
31+
2332
## Automated Checks
2433
2534
> **⏱️ Expected runtime: ~1 minute** on a modern developer machine with warm caches.

.github/skills/dev/git-workflow/run-pre-push-checks/SKILL.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ automatically on every `git push`. Install it once after cloning:
2020
After installation the hook fires automatically; you do not need to invoke the script
2121
manually before each push.
2222

23+
> **For AI agents**: before invoking the script manually, check whether the hook is installed:
24+
>
25+
> ```bash
26+
> [[ -x "$(git rev-parse --git-path hooks)/pre-push" ]] && echo "installed" || echo "not installed"
27+
> ```
28+
>
29+
> If installed, skip the manual run — `git push` will trigger it automatically.
30+
> Running both would execute every check twice.
31+
2332
## Automated Checks
2433
2534
> **⏱️ Expected runtime: ~15 minutes** on a modern developer machine with warm caches.

0 commit comments

Comments
 (0)