mirror of
https://github.com/codeflash-ai/codeflash.git
synced 2026-05-04 18:25:17 +00:00
Delete all existing .claude/ tracked files and recreate from scratch, adapting patterns from codeflash-agent. Hooks (6, up from 1): - bash-guard: blocks grep/find/cat in Bash, redirects to dedicated tools - require-read + track-read: enforces Read-before-Write/Edit - post-compact: injects git state + project conventions into compaction - post-edit-lint: runs prek on edited Python files (kept) - status-line: shows user, area, branch, dirty state Rules (10, up from 8): - New: sessions, debugging, github (from codeflash-agent) - Rewrote: code-style (absorbed source-code), git (added sizing/hygiene) - Removed: source-code (folded into code-style) Settings: permissions allowlist, attribution, includeCoAuthoredBy, full hook wiring, status line, enableAllProjectMcpServers. .gitignore: whitelist .claude/skills/ for tracking.
25 lines
708 B
Bash
Executable file
25 lines
708 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# PreToolUse hook: Block Write/Edit on existing files that haven't been Read first.
|
|
# Exit 0 = allow, Exit 2 = block (message on stderr).
|
|
|
|
INPUT=$(cat 2>/dev/null || true)
|
|
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty' 2>/dev/null || true)
|
|
|
|
[ -z "$FILE_PATH" ] && exit 0
|
|
|
|
# New files don't need prior reads
|
|
[ ! -f "$FILE_PATH" ] && exit 0
|
|
|
|
TRACKER="$CLAUDE_PROJECT_DIR/.claude/.read-tracker"
|
|
|
|
if [ ! -f "$TRACKER" ]; then
|
|
echo "BLOCKED: Read \`$(basename "$FILE_PATH")\` first before modifying it." >&2
|
|
exit 2
|
|
fi
|
|
|
|
if grep -qxF "$FILE_PATH" "$TRACKER"; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "BLOCKED: Read \`$(basename "$FILE_PATH")\` first before modifying it." >&2
|
|
exit 2
|