`if` property on hooks stripped when settings.json is rewritten by `/model`

Resolved 💬 3 comments Opened Apr 1, 2026 by maxcollie-mavencare Closed Apr 5, 2026

Description

The if property on hook entries (introduced as a performance optimization to conditionally gate hook execution) is silently removed whenever Claude Code rewrites settings.json via the /model command.

Steps to Reproduce

  1. Add if conditions to hook entries in settings.json:

``json
{
"type": "command",
"command": "~/.claude/hooks/pre-git-lock-cleanup.sh",
"if": "Bash(*git *)",
"timeout": 2
}
``

  1. Run /model to switch models
  2. Inspect settings.json — all if fields have been removed

Expected Behavior

Fields not managed by Claude Code (or newly-added schema fields like if) should be preserved during settings rewrites.

Actual Behavior

All if properties are silently stripped. This defeats the performance benefit of conditional hook execution — every hook fires on every Bash call rather than only when the command matches.

Environment

  • Claude Code version: 2.1.89
  • Platform: macOS

Related Issues

  • #22659 / #17982 — general "settings.json rewrite strips manually-added fields" (closed as duplicate)
  • #36124 / #24995 — hook schema on SchemaStore is out of sync with supported hook properties

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗