/insights command generates invalid settings.json hook configuration

Resolved 💬 3 comments Opened Mar 20, 2026 by drewmerc302 Closed Apr 14, 2026

The /insights slash command suggested the following as a ready-to-paste settings.json snippet under the "Features to Try > Hooks" section:

{
  "hooks": {
    "pre-commit": {
      "command": "git diff --cached --name-only | xargs -I {} sh -c 'if grep -P \"\\x1b\\[\" {} 2>/dev/null; then echo \"ANSI codes detected in {}\" && exit 1; fi'"
    }
  }
}

This is wrong in two ways:

  1. pre-commit is not a valid Claude Code hook event. Valid events are PreToolUse, PostToolUse, Notification, Stop, SubagentStop, etc.
  1. The format doesn't match Claude Code's hook schema — hooks require an array with a type: "command" field, not a flat key/value object.

The suggestion conflates git hooks with Claude Code hooks. A user who applied it would get a silently broken config with no error and no effect.

The correct solution for catching ANSI codes before commits is a git pre-commit hook at .git/hooks/pre-commit (or via init.templateDir), not a Claude Code settings.json entry.

Suggested fix: The insights command should either recommend the correct git hook approach, or if recommending a Claude Code hook, use a valid event like PreToolUse with a Bash matcher and the correct array format.

View original on GitHub ↗

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