spec-kit
spec-kit copied to clipboard
fix: pass hook event name to speckit.git.commit so AI agents read config
Problem
When speckit.git.commit fires as a hook (e.g., after speckit.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:
The after_tasks git hook is disabled in configuration, so no auto-commit occurred.
This happens even when the user has set after_tasks.enabled: true and default: true in 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 hooks- Tests — Updated assertions in
test_extensions.pyandtest_integration_claude.pyto match the new hook message format
Testing
Full test suite: 2999 passed, 1 skipped, 0 failures
Fixes #2279 Fixes #2702