Release v0.2.0: Context Resilience, AskUserQuestion, /design-systems

* Add context resilience: file-backed state, incremental writing, auto-recovery

Prevents "prompt too long" crashes from killing sessions by persisting work
to disk incrementally instead of relying on conversation memory.

Changes:
- pre-compact.sh: dumps session state before context compression
- session-start.sh: detects active.md for crash recovery
- session-stop.sh: archives and clears active.md on clean shutdown
- context-management.md: file-backed state as primary strategy
- 9 agents updated with incremental section writing protocol
  (game-designer, systems-designer, economy-designer, narrative-director,
   level-designer, world-builder, writer, art-director, audio-director)
- CLAUDE.md: trimmed redundant imports (10 → 5) to reduce token overhead
- design-docs.md rule: enforces incremental writing pattern
- .gitignore: excludes ephemeral session state files
- directory-structure.md: documents session-state/ and session-logs/
- COLLABORATIVE-DESIGN-PRINCIPLE.md: documents incremental writing pattern

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add AskUserQuestion integration across collaborative protocols

Explicitly reference the AskUserQuestion tool in all collaborative agent
definitions, protocol templates, team orchestrator skills, and the master
principle doc. Introduces the Explain-then-Capture pattern: agents write
full expert analysis in conversation, then call AskUserQuestion with
concise labels to capture decisions via structured UI.

26 files updated:
- 3 protocol templates (design, leadership, implementation)
- 14 agent definitions (10 design + 3 leadership + writer)
- 8 orchestrator skills (brainstorm + 7 team-*)
- 1 master principle doc (COLLABORATIVE-DESIGN-PRINCIPLE.md)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Add /design-systems skill: concept-to-GDD decomposition workflow

Bridges the gap between game concept and per-system design documents.
Professional studios use systems enumeration + dependency sorting between
concept and feature docs — skipping this step is one of the most expensive
mistakes (systems discovered during production cost 5-10x more to add).

New files:
- .claude/skills/design-systems/SKILL.md — 7-phase orchestration skill
  (enumerate systems, map dependencies, assign priorities, write GDDs)
- .claude/docs/templates/systems-index.md — master tracking template

Flow integration (7 existing skills updated):
- brainstorm, start, setup-engine, design-review, gate-check,
  project-stage-detect, game-concept template all reference /design-systems
  at the appropriate workflow touchpoints

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix cross-platform bugs, add missing tool permissions, and update docs for v0.2.0

Hooks: fix \s → [[:space:]] in grep -E fallbacks (3 files), fix detect-gaps.sh
empty-variable bug, fix log-agent.sh field name (agent_name → agent_type),
harden validate-push.sh with explicit $MATCHED_BRANCH, convert for-in loops
to while-read for space-safe iteration, add POSIX head -n syntax, increase
PreCompact timeout, widen session-stop log window.

Skills: add AskUserQuestion to 10 skills and TodoWrite to 8 multi-phase skills.
Fix project-stage-detect template/output paths, tech-artist → technical-artist.

Docs: add /design-systems to all references (README, quick-start, workflow guide,
skills-reference), update skill count 35 → 36, remove stale AI artifacts from
COLLABORATIVE-DESIGN-PRINCIPLE.md, add AskUserQuestion note to examples README.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Donchitos
2026-02-20 20:52:35 +11:00
committed by GitHub
parent 882b76f942
commit e289ce906f
59 changed files with 1454 additions and 170 deletions

View File

@@ -15,7 +15,7 @@ FRESH_PROJECT=true
# Check if engine is configured
if [ -f ".claude/docs/technical-preferences.md" ]; then
ENGINE_LINE=$(grep -E "^\- \*\*Engine\*\*:" .claude/docs/technical-preferences.md 2>/dev/null)
if echo "$ENGINE_LINE" | grep -qv "TO BE CONFIGURED" 2>/dev/null; then
if [ -n "$ENGINE_LINE" ] && ! echo "$ENGINE_LINE" | grep -q "TO BE CONFIGURED" 2>/dev/null; then
FRESH_PROJECT=false
fi
fi
@@ -151,3 +151,5 @@ fi
echo ""
echo "💡 To get a comprehensive project analysis, run: /project-stage-detect"
echo "==================================="
exit 0

View File

@@ -3,15 +3,15 @@
# Tracks which agents are being used and when
#
# Input schema (SubagentStart):
# { "agent_name": "game-designer", "model": "sonnet", ... }
# { "agent_id": "agent-abc123", "agent_type": "game-designer", ... }
INPUT=$(cat)
# Parse agent name -- use jq if available, fall back to grep
# Parse agent type -- 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)
AGENT_NAME=$(echo "$INPUT" | jq -r '.agent_type // "unknown"' 2>/dev/null)
else
AGENT_NAME=$(echo "$INPUT" | grep -oE '"agent_name"\s*:\s*"[^"]*"' | sed 's/"agent_name"\s*:\s*"//;s/"$//')
AGENT_NAME=$(echo "$INPUT" | grep -oE '"agent_type"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"agent_type"[[:space:]]*:[[:space:]]*"//;s/"$//')
[ -z "$AGENT_NAME" ] && AGENT_NAME="unknown"
fi

View File

@@ -1,15 +1,82 @@
#!/bin/bash
# Claude Code PreCompact hook: Save session state before context compression
# Ensures progress notes survive context window compression
# Claude Code PreCompact hook: Dump session state before context compression
# This output appears in the conversation right before compaction, ensuring
# critical state survives the summarization process.
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
echo "=== SESSION STATE BEFORE COMPACTION ==="
echo "Timestamp: $(date)"
# --- Active session state file ---
STATE_FILE="production/session-state/active.md"
if [ -f "$STATE_FILE" ]; then
echo ""
echo "## Active Session State (from $STATE_FILE)"
STATE_LINES=$(wc -l < "$STATE_FILE" 2>/dev/null | tr -d ' ')
if [ "$STATE_LINES" -gt 100 ] 2>/dev/null; then
head -n 100 "$STATE_FILE"
echo "... (truncated — $STATE_LINES total lines, showing first 100)"
else
cat "$STATE_FILE"
fi
else
echo ""
echo "## No active session state file found"
echo "Consider maintaining production/session-state/active.md for better recovery."
fi
# --- Files modified this session (unstaged + staged + untracked) ---
echo ""
echo "## Files Modified (git working tree)"
CHANGED=$(git diff --name-only 2>/dev/null)
STAGED=$(git diff --staged --name-only 2>/dev/null)
UNTRACKED=$(git ls-files --others --exclude-standard 2>/dev/null)
if [ -n "$CHANGED" ]; then
echo "Unstaged changes:"
echo "$CHANGED" | while read -r f; do echo " - $f"; done
fi
if [ -n "$STAGED" ]; then
echo "Staged changes:"
echo "$STAGED" | while read -r f; do echo " - $f"; done
fi
if [ -n "$UNTRACKED" ]; then
echo "New untracked files:"
echo "$UNTRACKED" | while read -r f; do echo " - $f"; done
fi
if [ -z "$CHANGED" ] && [ -z "$STAGED" ] && [ -z "$UNTRACKED" ]; then
echo " (no uncommitted changes)"
fi
# --- Work-in-progress design docs ---
echo ""
echo "## Design Docs — Work In Progress"
WIP_FOUND=false
for f in design/gdd/*.md; do
[ -f "$f" ] || continue
INCOMPLETE=$(grep -n -E "TODO|WIP|PLACEHOLDER|\[TO BE|\[TBD\]" "$f" 2>/dev/null)
if [ -n "$INCOMPLETE" ]; then
WIP_FOUND=true
echo " $f:"
echo "$INCOMPLETE" | while read -r line; do echo " $line"; done
fi
done
if [ "$WIP_FOUND" = false ]; then
echo " (no WIP markers found in design docs)"
fi
# --- Log compaction event ---
SESSION_LOG_DIR="production/session-logs"
# Create session log directory if it doesn't exist
mkdir -p "$SESSION_LOG_DIR" 2>/dev/null
# Save a marker file noting that compaction occurred
echo "Context compaction occurred at $(date). Session state may have been compressed." \
echo "Context compaction occurred at $(date)." \
>> "$SESSION_LOG_DIR/compaction-log.txt" 2>/dev/null
echo ""
echo "## Recovery Instructions"
echo "After compaction, read $STATE_FILE to recover full working context."
echo "Then read any files listed above that are being actively worked on."
echo "=== END SESSION STATE ==="
exit 0

View File

@@ -54,5 +54,22 @@ if [ -d "src" ]; then
fi
fi
# --- Active session state recovery ---
STATE_FILE="production/session-state/active.md"
if [ -f "$STATE_FILE" ]; then
echo ""
echo "=== ACTIVE SESSION STATE DETECTED ==="
echo "A previous session left state at: $STATE_FILE"
echo "Read this file to recover context and continue where you left off."
echo ""
echo "Quick summary:"
head -20 "$STATE_FILE" 2>/dev/null
TOTAL_LINES=$(wc -l < "$STATE_FILE" 2>/dev/null)
if [ "$TOTAL_LINES" -gt 20 ]; then
echo " ... ($TOTAL_LINES total lines — read the full file to continue)"
fi
echo "=== END SESSION STATE PREVIEW ==="
fi
echo "==================================="
exit 0

View File

@@ -7,10 +7,23 @@ SESSION_LOG_DIR="production/session-logs"
mkdir -p "$SESSION_LOG_DIR" 2>/dev/null
# Log recent git activity from this session
RECENT_COMMITS=$(git log --oneline --since="1 hour ago" 2>/dev/null)
# Log recent git activity from this session (check up to 8 hours for long sessions)
RECENT_COMMITS=$(git log --oneline --since="8 hours ago" 2>/dev/null)
MODIFIED_FILES=$(git diff --name-only 2>/dev/null)
# --- Clean up active session state on normal shutdown ---
STATE_FILE="production/session-state/active.md"
if [ -f "$STATE_FILE" ]; then
# Archive to session log before removing
{
echo "## Archived Session State: $TIMESTAMP"
cat "$STATE_FILE"
echo "---"
echo ""
} >> "$SESSION_LOG_DIR/session-log.md" 2>/dev/null
rm "$STATE_FILE" 2>/dev/null
fi
if [ -n "$RECENT_COMMITS" ] || [ -n "$MODIFIED_FILES" ]; then
{
echo "## Session End: $TIMESTAMP"

View File

@@ -12,7 +12,7 @@ INPUT=$(cat)
if command -v jq >/dev/null 2>&1; then
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
else
FILE_PATH=$(echo "$INPUT" | grep -oE '"file_path"\s*:\s*"[^"]*"' | sed 's/"file_path"\s*:\s*"//;s/"$//')
FILE_PATH=$(echo "$INPUT" | grep -oE '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"file_path"[[:space:]]*:[[:space:]]*"//;s/"$//')
fi
# Normalize path separators (Windows backslash to forward slash)

View File

@@ -12,7 +12,7 @@ INPUT=$(cat)
if command -v jq >/dev/null 2>&1; then
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
else
COMMAND=$(echo "$INPUT" | grep -oE '"command"\s*:\s*"[^"]*"' | sed 's/"command"\s*:\s*"//;s/"$//')
COMMAND=$(echo "$INPUT" | grep -oE '"command"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"command"[[:space:]]*:[[:space:]]*"//;s/"$//')
fi
# Only process git commit commands
@@ -31,7 +31,7 @@ WARNINGS=""
# Check design documents for required sections
DESIGN_FILES=$(echo "$STAGED" | grep -E '^design/gdd/')
if [ -n "$DESIGN_FILES" ]; then
for file in $DESIGN_FILES; do
while IFS= read -r file; do
if [[ "$file" == *.md ]] && [ -f "$file" ]; then
for section in "Overview" "Detailed" "Edge Cases" "Dependencies" "Acceptance Criteria"; do
if ! grep -qi "$section" "$file"; then
@@ -39,7 +39,7 @@ if [ -n "$DESIGN_FILES" ]; then
fi
done
fi
done
done <<< "$DESIGN_FILES"
fi
# Validate JSON data files -- block invalid JSON
@@ -54,7 +54,7 @@ if [ -n "$DATA_FILES" ]; then
fi
done
for file in $DATA_FILES; do
while IFS= read -r file; do
if [ -f "$file" ]; then
if [ -n "$PYTHON_CMD" ]; then
if ! "$PYTHON_CMD" -m json.tool "$file" > /dev/null 2>&1; then
@@ -65,32 +65,32 @@ if [ -n "$DATA_FILES" ]; then
echo "WARNING: Cannot validate JSON (python not found): $file" >&2
fi
fi
done
done <<< "$DATA_FILES"
fi
# Check for hardcoded gameplay values in gameplay code
# Uses grep -E (POSIX extended) instead of grep -P (Perl) for cross-platform compatibility
CODE_FILES=$(echo "$STAGED" | grep -E '^src/gameplay/')
if [ -n "$CODE_FILES" ]; then
for file in $CODE_FILES; do
while IFS= read -r file; do
if [ -f "$file" ]; then
if grep -nE '(damage|health|speed|rate|chance|cost|duration)[[:space:]]*[:=][[:space:]]*[0-9]+' "$file" 2>/dev/null; then
WARNINGS="$WARNINGS\nCODE: $file may contain hardcoded gameplay values. Use data files."
fi
fi
done
done <<< "$CODE_FILES"
fi
# Check for TODO/FIXME without assignee -- uses grep -E instead of grep -P
SRC_FILES=$(echo "$STAGED" | grep -E '^src/')
if [ -n "$SRC_FILES" ]; then
for file in $SRC_FILES; do
while IFS= read -r file; do
if [ -f "$file" ]; then
if grep -nE '(TODO|FIXME|HACK)[^(]' "$file" 2>/dev/null; then
WARNINGS="$WARNINGS\nSTYLE: $file has TODO/FIXME without owner tag. Use TODO(name) format."
fi
fi
done
done <<< "$SRC_FILES"
fi
# Print warnings (non-blocking) and allow commit

View File

@@ -12,7 +12,7 @@ INPUT=$(cat)
if command -v jq >/dev/null 2>&1; then
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
else
COMMAND=$(echo "$INPUT" | grep -oE '"command"\s*:\s*"[^"]*"' | sed 's/"command"\s*:\s*"//;s/"$//')
COMMAND=$(echo "$INPUT" | grep -oE '"command"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"command"[[:space:]]*:[[:space:]]*"//;s/"$//')
fi
# Only process git push commands
@@ -21,23 +21,23 @@ if ! echo "$COMMAND" | grep -qE '^git[[:space:]]+push'; then
fi
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
FULL_GATE=false
MATCHED_BRANCH=""
# Check if pushing to a protected branch
for branch in develop main master; do
if [ "$CURRENT_BRANCH" = "$branch" ]; then
FULL_GATE=true
MATCHED_BRANCH="$branch"
break
fi
# Also check if pushing to a protected branch explicitly (quote branch name for safety)
if echo "$COMMAND" | grep -qE "[[:space:]]${branch}([[:space:]]|$)"; then
FULL_GATE=true
MATCHED_BRANCH="$branch"
break
fi
done
if [ "$FULL_GATE" = true ]; then
echo "Push to protected branch '$CURRENT_BRANCH' detected." >&2
if [ -n "$MATCHED_BRANCH" ]; then
echo "Push to protected branch '$MATCHED_BRANCH' detected." >&2
echo "Reminder: Ensure build passes, unit tests pass, and no S1/S2 bugs exist." >&2
# Allow the push but warn -- uncomment below to block instead:
# echo "BLOCKED: Run tests before pushing to $CURRENT_BRANCH" >&2