[GH-ISSUE #369] Hook errors when running checkpoint in non-git directory #134

Closed
opened 2026-03-02 04:12:07 +03:00 by kerem · 3 comments
Owner

Originally created by @sstraus on GitHub (Jan 18, 2026).
Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/369

Originally assigned to: @acunniffe on GitHub.

Description

When git-ai is configured as a Claude Code hook and runs in a directory that is not a git repository, it produces hook errors that appear in the Claude Code output.

Environment

  • git-ai version: 1.0.35
  • Claude Code with hooks configured in ~/.claude/settings.json

Configuration

"hooks": {
  "PostToolUse": [
    {
      "matcher": "Write|Edit|MultiEdit",
      "hooks": [
        {
          "type": "command",
          "command": "git-ai checkpoint claude --hook-input stdin"
        }
      ]
    }
  ],
  "PreToolUse": [
    {
      "matcher": "Write|Edit|MultiEdit",
      "hooks": [
        {
          "type": "command",
          "command": "git-ai checkpoint claude --hook-input stdin"
        }
      ]
    }
  ]
}

Steps to Reproduce

  1. Configure git-ai hooks in Claude Code global settings as shown above
  2. Navigate to a directory that is NOT a git repository
  3. Use Claude Code to edit a file (e.g., approve-prs.sh)
  4. Observe hook errors in the output

Expected Behavior

One of the following would be ideal:

  • Gracefully skip checkpointing with a silent exit when not in a git repo
  • Return a clear, non-error message that can be suppressed by Claude Code
  • Provide a flag to make the hook silently succeed in non-git directories

Actual Behavior

Hook errors are displayed:

⏺ Update(approve-prs.sh)
  ⎿  PreToolUse:Edit hook error
  ⎿  Added 1 line
  ⎿  PostToolUse:Edit hook error

The file edit succeeds, but the errors create noise in the output.

Impact

While the functionality still works (the edit succeeds), the error messages:

  • Create confusion about whether the operation succeeded
  • Add noise to the Claude Code output
  • May cause users to think something went wrong

Suggested Fix

Add a check at the start of the checkpoint command to detect if we're in a git repository, and if not, exit gracefully with a success code (0) instead of failing.

Originally created by @sstraus on GitHub (Jan 18, 2026). Original GitHub issue: https://github.com/git-ai-project/git-ai/issues/369 Originally assigned to: @acunniffe on GitHub. ## Description When git-ai is configured as a Claude Code hook and runs in a directory that is not a git repository, it produces hook errors that appear in the Claude Code output. ## Environment - git-ai version: 1.0.35 - Claude Code with hooks configured in `~/.claude/settings.json` ## Configuration ```json "hooks": { "PostToolUse": [ { "matcher": "Write|Edit|MultiEdit", "hooks": [ { "type": "command", "command": "git-ai checkpoint claude --hook-input stdin" } ] } ], "PreToolUse": [ { "matcher": "Write|Edit|MultiEdit", "hooks": [ { "type": "command", "command": "git-ai checkpoint claude --hook-input stdin" } ] } ] } ``` ## Steps to Reproduce 1. Configure git-ai hooks in Claude Code global settings as shown above 2. Navigate to a directory that is NOT a git repository 3. Use Claude Code to edit a file (e.g., `approve-prs.sh`) 4. Observe hook errors in the output ## Expected Behavior One of the following would be ideal: - Gracefully skip checkpointing with a silent exit when not in a git repo - Return a clear, non-error message that can be suppressed by Claude Code - Provide a flag to make the hook silently succeed in non-git directories ## Actual Behavior Hook errors are displayed: ``` ⏺ Update(approve-prs.sh) ⎿ PreToolUse:Edit hook error ⎿ Added 1 line ⎿ PostToolUse:Edit hook error ``` The file edit succeeds, but the errors create noise in the output. ## Impact While the functionality still works (the edit succeeds), the error messages: - Create confusion about whether the operation succeeded - Add noise to the Claude Code output - May cause users to think something went wrong ## Suggested Fix Add a check at the start of the checkpoint command to detect if we're in a git repository, and if not, exit gracefully with a success code (0) instead of failing.
kerem 2026-03-02 04:12:07 +03:00
Author
Owner

@acunniffe commented on GitHub (Jan 18, 2026):

This is a great issue, working on fixing it today. To be clear, you wouldn't expect AI authorship to be saved in this case? Git AI only guarantees accurate authorship logs in Git repos.

<!-- gh-comment-id:3765312361 --> @acunniffe commented on GitHub (Jan 18, 2026): This is a great issue, working on fixing it today. To be clear, you wouldn't expect AI authorship to be saved in this case? Git AI only guarantees accurate authorship logs in Git repos.
Author
Owner

@svarlamov commented on GitHub (Jan 18, 2026):

I wonder if there are any other agents that might have the same issue?

<!-- gh-comment-id:3765482724 --> @svarlamov commented on GitHub (Jan 18, 2026): I wonder if there are any other agents that might have the same issue?
Author
Owner

@acunniffe commented on GitHub (Jan 18, 2026):

@svarlamov and @sstraus - https://github.com/acunniffe/git-ai/pull/374 is open now to fix this. Will get it in a release in a couple of hours alongside some other fixes.

This is a big one, esp now that many Agents are encouraging people to write hooks that interrupt agent flows.

<!-- gh-comment-id:3765572724 --> @acunniffe commented on GitHub (Jan 18, 2026): @svarlamov and @sstraus - https://github.com/acunniffe/git-ai/pull/374 is open now to fix this. Will get it in a release in a couple of hours alongside some other fixes. This is a big one, esp now that many Agents are encouraging people to write hooks that interrupt agent flows.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#134
No description provided.