fix: pass hook event name to speckit.git.commit so AI agents read config#2724
Open
mnriem wants to merge 2 commits into
Open
fix: pass hook event name to speckit.git.commit so AI agents read config#2724mnriem wants to merge 2 commits into
mnriem wants to merge 2 commits into
Conversation
The speckit.git.commit command template described script behavior in a 'Behavior' section that AI agents interpreted as instructions to follow without actually reading the config file. This caused agents to assume the default config (all events disabled) and fabricate 'disabled in configuration' messages even when the user had enabled auto-commit. Changes: - Rewrite speckit.git.commit.md with explicit step-by-step instructions that mandate reading .specify/extensions/git/git-config.yml before deciding whether to commit - Add 'Hook event: <event>' line to format_hook_message() output for both optional and mandatory hooks so agents know which event triggered the hook without guessing - Append event name to EXECUTE_COMMAND_INVOCATION so agents can pass it to the auto-commit script Fixes github#2279, fixes github#2702
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves extension hook messaging and the git auto-commit command template so AI agents reliably know which hook event triggered /speckit.git.commit and are prompted to read the live git extension config before deciding whether to commit.
Changes:
- Add the hook event name to hook messages and append it to the suggested command invocation so agents don’t have to infer context.
- Rewrite
speckit.git.commit’s command template into explicit, step-by-step instructions emphasizing reading.specify/extensions/git/git-config.yml. - Update Claude + general hook rendering tests to match the new message format.
Show a summary per file
| File | Description |
|---|---|
| tests/test_extensions.py | Updates hook message assertions to expect “Hook event: …” and invocations including the event name. |
| tests/integrations/test_integration_claude.py | Updates Claude hook rendering assertion for the new event-aware invocation format. |
| src/specify_cli/extensions.py | Extends format_hook_message() output to include the hook event and append it to the invocation. |
| extensions/git/commands/speckit.git.commit.md | Replaces the old “Behavior” section with prescriptive instructions to read config and execute commits correctly. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 3
…mat, add event to Executing line - Step 1: prefer explicit event name argument over context inference - Fix default commit message format to match script output: '[Spec Kit] Auto-commit <before|after> <command>' - Include event_name in the 'Executing:' line so agents see the full invocation immediately, not just on EXECUTE_COMMAND_INVOCATION
Comment on lines
2809
to
+2813
| lines.append(f"\n**Automatic Hook**: {extension}") | ||
| lines.append(f"Executing: `{display_invocation}`") | ||
| lines.append(f"Hook event: {event_name}") | ||
| lines.append(f"Executing: `{display_invocation} {event_name}`") | ||
| lines.append(f"EXECUTE_COMMAND: {command_text}") | ||
| lines.append(f"EXECUTE_COMMAND_INVOCATION: {display_invocation}") | ||
| lines.append(f"EXECUTE_COMMAND_INVOCATION: {display_invocation} {event_name}") |
Comment on lines
+30
to
+32
| 1. Find the key matching the event name (e.g., `after_tasks:`). | ||
| 2. If the event key exists **and** has `enabled: true` → auto-commit is **enabled**. Use the `message` value from that key. | ||
| 3. If the event key exists **and** has `enabled: false` → auto-commit is **disabled**. Exit silently. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
speckit.git.commitfires as a hook (e.g., afterspeckit.tasks), AI agents read the command template's "Behavior" section and treat it as manual instructions — but never actually read.specify/extensions/git/git-config.yml. They assume the default config (all events disabled) and fabricate messages like:This happens even when the user has set
after_tasks.enabled: trueanddefault: truein their config.The user's workaround in #2702 confirms this — explicitly attaching the config file with
@forces the AI to read it, and then it works.Root Cause
speckit.git.commit.md— The old template had a descriptive "Behavior" section that AI agents interpreted without actually reading the config fileformat_hook_message()— The hook event name (e.g.,after_tasks) was not passed through to the command invocation, so agents had to infer it from context (and often failed)Changes
extensions/git/commands/speckit.git.commit.md— Rewrote with explicit step-by-step instructions that mandate reading the config file (Step 2: "You MUST read the file") before deciding whether to commitsrc/specify_cli/extensions.py— AddedHook event: {event_name}toformat_hook_message()output and appended event name toEXECUTE_COMMAND_INVOCATIONfor both optional and mandatory hookstest_extensions.pyandtest_integration_claude.pyto match the new hook message formatTesting
Full test suite: 2999 passed, 1 skipped, 0 failures
Fixes #2279
Fixes #2702