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.
30 lines
772 B
Bash
Executable File
30 lines
772 B
Bash
Executable File
#!/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
|