Skip to content

chore(claude): add granular hook timeouts per event type - #1213

Merged
shunkakinoki merged 2 commits into
mainfrom
chore/claude-hook-timeouts
Mar 19, 2026
Merged

chore(claude): add granular hook timeouts per event type#1213
shunkakinoki merged 2 commits into
mainfrom
chore/claude-hook-timeouts

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Mar 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • notify.sh (all events): 3s — osascript local notification
  • pushover.sh (all events): 6s — curl has --max-time 5, so 6s is the ceiling
  • git-ai checkpoint: 15s — git network op (was 10s)
  • rtk-rewrite.sh: 5s — blocking pre-tool script, now has explicit timeout
  • UserPromptSubmit jq: 3s — pure local I/O (was 5s)
  • WorktreeCreate/Remove: 30s — git worktree ops (was no timeout)

Follows the curl timeout fix in pushover.sh from #1212 to fully bound Stop hook latency to ≤6s.

🤖 Generated with Claude Code


Summary by cubic

Add per-event hook timeouts in config/claude/settings.json to cap notification latency and prevent slow hooks from blocking. Sets practical ceilings for git/network tasks and fast local scripts.

  • New Features

    • Notifications: notify.sh 3s; pushover.sh 6s (Stop hook ≤6s).
    • Git ops: git-ai checkpoint 15s; WorktreeCreate/Remove 30s.
    • Pre-tool: rtk-rewrite.sh and security.sh 5s.
    • Local I/O: UserPromptSubmit jq 3s.
    • Bash: added dcg hook (and async probe) with 5s.
  • Bug Fixes

    • Added missing 5s timeout to the duplicate dcg hook entry.

Written for commit 1996613. Summary will update on new commits.

- notify.sh (osascript): 3s — local notification, very fast
- pushover.sh (curl w/ --max-time 5): 6s — just above curl ceiling
- git-ai checkpoint: 15s — git network operation
- rtk-rewrite.sh / security.sh: 5s — blocking pre-tool scripts
- UserPromptSubmit jq: 3s — pure local I/O
- WorktreeCreate/Remove: 30s — git worktree operations
Entire-Checkpoint: fa19a44077e5
Copilot AI review requested due to automatic review settings March 19, 2026 17:24
@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@shunkakinoki has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 05ef5bea-c0aa-4941-970c-6ca7659e002a

📥 Commits

Reviewing files that changed from the base of the PR and between cf1483f and 1996613.

📒 Files selected for processing (1)
  • config/claude/settings.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/claude-hook-timeouts
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Mar 19, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the timeout configurations for various internal hooks within the Claude system, aiming to optimize performance and prevent indefinite waits. It introduces granular timeouts for several existing commands and adds timeouts to previously unbounded operations, ensuring more predictable execution and responsiveness. Additionally, a new Bash matcher with a dcg command hook was integrated.

Highlights

  • Granular Hook Timeouts: Adjusted timeouts for various hooks to improve performance and reliability. Specifically, notify.sh and pushover.sh timeouts were reduced to 3s and 6s respectively across multiple event types. The git-ai checkpoint timeout was increased to 15s, and UserPromptSubmit jq command timeout was reduced to 3s.
  • New Hook Timeouts: Introduced explicit timeouts for previously unbounded operations. The rtk-rewrite.sh hook now has a 5s timeout, and WorktreeCreate/WorktreeRemove hooks were given a 30s timeout.
  • New Bash Matcher Hook: Added a new Bash matcher configuration with a dcg command hook.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mesa-dot-dev

mesa-dot-dev Bot commented Mar 19, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Added granular, per-event type hook timeouts within Claude's configuration to prevent slow operations from blocking the system, particularly for notifications and various Git operations.

What changed?

  • config/claude/settings.json:
    • Adjusted command timeouts:
      • Reduced for notify.sh (3s), pushover.sh (6s), and UserPromptSubmit jq (3s).
      • Increased for git-ai checkpoint claude (15s).
      • Added new timeouts for rtk-rewrite.sh (5s) and WorktreeCreate/Remove operations (30s).
    • Introduced a new "Bash" matcher hook executing the dcg command.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the hook timeouts to be more granular and appropriate for each event type, which is a great improvement for performance and reliability. I've reviewed the changes and they look good, with adjusted timeouts for notifications, git operations, and other scripts. I found one issue: a duplicate hook configuration for Bash tools was added in PreToolUse, which could cause issues. I've left a comment with a suggestion to remove the redundant block. Other than that, the changes are solid.

Comment on lines +167 to 176
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "dcg"
}
]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This adds a duplicate hook configuration for matcher: "Bash" within the PreToolUse event. An existing configuration for this matcher is already defined on lines 125-158, which includes an asynchronous, safer call to dcg. This new block introduces a synchronous, blocking call to dcg without a timeout, which is redundant and could lead to performance issues or failures if dcg is not present or hangs. This block should be removed to avoid duplication and potential problems.

      }

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="config/claude/settings.json">

<violation number="1" location="config/claude/settings.json:169">
P2: This adds a second `PreToolUse` entry with `matcher: "Bash"`, duplicating the existing Bash matcher block (which already includes an async `dcg` hook among others). Additionally, this synchronous `dcg` command has no `timeout` set, which contradicts the purpose of this PR to add granular timeouts to all hooks. If `dcg` hangs, it will block tool execution indefinitely.</violation>

<violation number="2" location="config/claude/settings.json:173">
P1: The new Bash hook runs `dcg` unconditionally and without an explicit timeout. This can fail on machines where `dcg` is not installed and weakens the timeout bounding introduced in this change.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread config/claude/settings.json Outdated
Comment thread config/claude/settings.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts Claude Code hook configuration to use per-event timeout ceilings, aiming to bound hook latency (notably Stop hooks) while allowing slower git-related operations more time.

Changes:

  • Reduce notification hook timeouts (notify.sh → 3s, pushover.sh → 6s) across multiple events.
  • Increase git-ai checkpoint hook timeout to 15s for tool-write/edit events.
  • Add/adjust explicit timeouts for rtk-rewrite.sh, UserPromptSubmit history append, and worktree create/remove hooks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +167 to +175
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "dcg"
}
]
Comment on lines +168 to +175
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "dcg"
}
]
@shunkakinoki
shunkakinoki merged commit b47b409 into main Mar 19, 2026
20 of 28 checks passed
@shunkakinoki
shunkakinoki deleted the chore/claude-hook-timeouts branch March 19, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants