chore(claude): add SessionStart compact context injector

inject-sprint-context.sh fires on SessionStart with matcher=compact
and emits branch, last 10 commits, and the top of BACKLOG.md so
Claude resumes with sprint context after auto-compaction. Output
capped at ~600 tokens.
This commit is contained in:
2026-05-05 23:24:46 +02:00
parent f7ef26d450
commit 1e65a65b20

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$CLAUDE_PROJECT_DIR" 2>/dev/null || exit 0
branch="$(git branch --show-current 2>/dev/null || echo unknown)"
recent="$(git log --oneline -10 2>/dev/null || echo '(git log unavailable)')"
backlog_excerpt="(BACKLOG.md not found)"
if [ -f dev-docs/BACKLOG.md ]; then
# First 40 lines, capped at ~3500 chars to stay well under 600 tokens for the whole output.
backlog_excerpt="$(head -n 40 dev-docs/BACKLOG.md | head -c 3500)"
fi
cat <<EOF
## Sprint context (re-injected after compaction)
**Branch:** $branch
**Last 10 commits:**
$recent
**Top of BACKLOG.md:**
$backlog_excerpt
Reminder: re-read /CLAUDE.md if any zero-compromise principle is unclear. /dev-docs/SCHEMA.md is authoritative for table structure.
EOF
exit 0