/insights command generates invalid settings.json hook configuration
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:
pre-commitis not a valid Claude Code hook event. Valid events are PreToolUse, PostToolUse, Notification, Stop, SubagentStop, etc.
- 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗