codeflash/.claude/hooks/status-line.sh
Kevin Turcios e4b1fb854b chore: rebuild .claude config from scratch
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.
2026-04-23 04:31:04 -05:00

50 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# Status line: derive context from git state.
input=$(cat)
project_dir=$(echo "$input" | jq -r '.workspace.project_dir')
user=$(whoami)
branch=$(git -C "$project_dir" branch --show-current 2>/dev/null)
changed=$(git -C "$project_dir" diff --name-only HEAD 2>/dev/null)
[ -z "$changed" ] && changed=$(git -C "$project_dir" diff --name-only 2>/dev/null)
[ -z "$changed" ] && changed=$(git -C "$project_dir" diff --name-only --cached 2>/dev/null)
if [ -n "$changed" ]; then
area=$(echo "$changed" | sed 's|/.*||' | sort | uniq -c | sort -rn | head -1 | awk '{print $2}')
else
area=""
fi
context=""
case "$area" in
codeflash)
subsystem=$(echo "$changed" | grep '^codeflash/' | sed 's|^codeflash/||; s|/.*||' | sort | uniq -c | sort -rn | head -1 | awk '{print $2}')
[ -n "$subsystem" ] && context="editing $subsystem" ;;
tests)
target=$(echo "$changed" | grep '^tests/' | sed 's|^tests/||; s|/.*||' | sort -u | head -1)
[ -n "$target" ] && context="testing $target" ;;
.claude)
context="configuring claude" ;;
esac
if [ -z "$context" ] && [ -n "$branch" ]; then
case "$branch" in
feat/*|cf-*) context="building: ${branch#feat/}" ;;
fix/*) context="fixing: ${branch#fix/}" ;;
refactor/*) context="refactoring: ${branch#refactor/}" ;;
test/*) context="testing: ${branch#test/}" ;;
chore/*) context="chore: ${branch#chore/}" ;;
esac
fi
dirty=""
if [ -n "$(git -C "$project_dir" status --porcelain 2>/dev/null)" ]; then
dirty=" *"
fi
status="$user | codeflash"
[ -n "$context" ] && status="$status | $context"
[ -n "$branch" ] && status="$status | $branch$dirty"
echo "$status"