Skip to content

feat(config): add suppress_hook_warning option#776

Open
mvanhorn wants to merge 1 commit intortk-ai:developfrom
mvanhorn:osc/682-suppress-hook-warning-config
Open

feat(config): add suppress_hook_warning option#776
mvanhorn wants to merge 1 commit intortk-ai:developfrom
mvanhorn:osc/682-suppress-hook-warning-config

Conversation

@mvanhorn
Copy link

Summary

  • Add hooks.suppress_hook_warning config option in config.toml
  • Add RTK_SUPPRESS_HOOK_WARNING=1 env var as zero-config alternative

Why this matters

Users running rtk via CLAUDE.md instructions (instead of hooks) or with tools like OpenCode get [rtk] /!\ No hook installed on every command (#682). The warning wastes tokens and confuses AI agents - @btbxbob reports it printing on every git add, git commit, and git status. 5 users across Windows and OpenCode report the same problem.

Currently the warning is rate-limited to once per day, but there's no way to suppress it permanently.

Changes

src/config.rs:

  • Added suppress_hook_warning: bool field to HooksConfig (defaults to false)
  • Added hook_warning_suppressed() helper that checks the env var first, then config file

src/hook_check.rs:

  • check_and_warn() now returns early when hook_warning_suppressed() is true

The rtk gain diagnostic output (src/gain.rs) still shows hook status since that's an explicit diagnostic command.

Usage

Config file (~/.config/rtk/config.toml):

[hooks]
suppress_hook_warning = true

Or env var (useful for CI, OpenCode, non-Claude tools):

export RTK_SUPPRESS_HOOK_WARNING=1

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test (1074 tests pass)
  • suppress_hook_warning deserializes correctly from TOML
  • Default is false (existing behavior unchanged)
  • Missing field in [hooks] section defaults to false

Fixes #682

This contribution was developed with AI assistance (Claude Code).

Add hooks.suppress_hook_warning config option and RTK_SUPPRESS_HOOK_WARNING
env var to disable "No hook installed" and "Hook outdated" warnings.

Users running rtk via CLAUDE.md instructions instead of hooks, or with
tools like OpenCode, get these warnings on every command. The warnings
waste tokens and confuse AI agents since rtk is working correctly.

The env var is checked first (useful for CI and tools without config
files), then the config file. Both default to false so existing
behavior is unchanged.

Fixes rtk-ai#682

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@pszymkowiak
Copy link
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟢 Risk low

Summary

Adds a new suppress_hook_warning config option and RTK_SUPPRESS_HOOK_WARNING env var to let users permanently silence the recurring 'No hook installed' and 'Hook outdated' warnings. This addresses user complaints where the warning wastes tokens and confuses AI agents when rtk is run via CLAUDE.md instructions or non-Claude tools like OpenCode.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #682


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-small Quelques heures, 1 fichier enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants