Files
Claude-Code-Game-Studios/.claude/hooks/log-agent-stop.sh
Donchitos 392e3befec Adopt new Claude Code features: agent memory, context fork, worktree isolation, SubagentStop hook
- Add `memory: project` to 14 specialist agents for cross-session learning
- Add `context: fork` + `agent:` to 6 analysis skills to preserve main context
- Add `isolation: worktree` to prototyper agent for safe throwaway experiments
- Add SubagentStop hook to complete agent audit trail (start + stop logging)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 13:58:05 +11:00

26 lines
854 B
Bash

#!/bin/bash
# Claude Code SubagentStop hook: Log agent completion for audit trail
# Tracks when agents finish and their outcome
#
# Input schema (SubagentStop):
# { "agent_id": "agent-abc123", "agent_name": "game-designer", ... }
INPUT=$(cat)
# Parse agent name -- use jq if available, fall back to grep
if command -v jq >/dev/null 2>&1; then
AGENT_NAME=$(echo "$INPUT" | jq -r '.agent_name // "unknown"' 2>/dev/null)
else
AGENT_NAME=$(echo "$INPUT" | grep -oE '"agent_name"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"agent_name"[[:space:]]*:[[:space:]]*"//;s/"$//')
[ -z "$AGENT_NAME" ] && AGENT_NAME="unknown"
fi
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
SESSION_LOG_DIR="production/session-logs"
mkdir -p "$SESSION_LOG_DIR" 2>/dev/null
echo "$TIMESTAMP | Agent completed: $AGENT_NAME" >> "$SESSION_LOG_DIR/agent-audit.log" 2>/dev/null
exit 0