Skip to content

Commit ba56064

Browse files
authored
Merge pull request #2108 from codeflash-ai/chore/fix-claude-hooks
chore: fix claude hooks and add LSP tool env
2 parents 3224f21 + 5cb0a44 commit ba56064

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

.claude/hooks/bash-guard.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ case "$FIRST_CMD" in
2424
echo "BLOCKED: Use the Read tool instead of \`$FIRST_CMD\`. Read provides line numbers and supports images/PDFs." >&2
2525
exit 2
2626
;;
27+
awk)
28+
echo "BLOCKED: Use the Grep tool or Read tool instead of \`awk\`." >&2
29+
exit 2
30+
;;
2731
sed)
2832
if echo "$COMMAND" | grep -qE '(^|[[:space:]])sed[[:space:]]+-i'; then
2933
echo "BLOCKED: Use the Edit tool instead of \`sed -i\`. Edit tracks changes properly." >&2

.claude/hooks/post-compact.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ STATE="${STATE}- libcst for code transforms, ast for read-only analysis\n"
4040

4141
[ -z "$STATE" ] && exit 0
4242

43-
cat <<EOF
44-
{
45-
"systemMessage": "PRESERVE the following session state through compaction:\n$(echo -e "$STATE" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')"
46-
}
47-
EOF
43+
EXPANDED=$(printf '%b' "$STATE")
44+
jq -n --arg msg "PRESERVE the following session state through compaction:
45+
$EXPANDED" '{"systemMessage": $msg}'
4846

4947
exit 0

.claude/hooks/track-read.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null |
66

77
[ -z "$FILE_PATH" ] && exit 0
88

9-
echo "$FILE_PATH" >> "$CLAUDE_PROJECT_DIR/.claude/.read-tracker"
9+
TRACKER="$CLAUDE_PROJECT_DIR/.claude/.read-tracker"
10+
grep -qxF "$FILE_PATH" "$TRACKER" 2>/dev/null || echo "$FILE_PATH" >> "$TRACKER"
1011
exit 0

.claude/settings.json

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@
4242
"timeout": 5
4343
}
4444
]
45-
},
46-
{
47-
"matcher": "Edit",
48-
"hooks": [
49-
{
50-
"type": "command",
51-
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/require-read.sh",
52-
"timeout": 5
53-
}
54-
]
5545
}
5646
],
5747
"PostToolUse": [
@@ -92,5 +82,8 @@
9282
"type": "command",
9383
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/status-line.sh"
9484
},
95-
"enableAllProjectMcpServers": true
85+
"enableAllProjectMcpServers": true,
86+
"env": {
87+
"ENABLE_LSP_TOOL": "1"
88+
}
9689
}

0 commit comments

Comments
 (0)