spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

fix: pass hook event name to speckit.git.commit so AI agents read config

Open mnriem opened this issue 6 months ago • 0 comments

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

  1. speckit.git.commit.md — The old template had a descriptive "Behavior" section that AI agents interpreted without actually reading the config file
  2. format_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 commit
  • src/specify_cli/extensions.py — Added Hook event: {event_name} to format_hook_message() output and appended event name to EXECUTE_COMMAND_INVOCATION for both optional and mandatory hooks
  • Tests — Updated assertions in test_extensions.py and test_integration_claude.py to match the new hook message format

Testing

Full test suite: 2999 passed, 1 skipped, 0 failures

Fixes #2279 Fixes #2702

mnriem avatar May 27 '26 12:05 mnriem