Files
Claude-Code-Game-Studios/.claude/hooks/validate-commit.sh
Donchitos 7d08e396e3 Release v0.3.0: /design-system, /map-systems, status line, UPGRADING guide (#2)
* Add UPGRADING.md migration guide and link from README

Covers v0.1→v0.2 upgrade with three strategies (git merge, cherry-pick,
manual copy), file safety categories, and post-upgrade verification steps.
Structured to support future version sections.

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

* Rename /design-systems to /map-systems + /design-system and fix all references

Split the monolithic /design-systems skill into two focused skills:
- /map-systems: systems decomposition and index creation
- /design-system: guided section-by-section GDD authoring

Updated all cross-references across 14 files: README, UPGRADING,
WORKFLOW-GUIDE, quick-start, skills-reference, game-concept template,
systems-index template, brainstorm, design-review, gate-check,
project-stage-detect, setup-engine, and start skills. Fixed skill
counts from 36 to 37 everywhere. Added /map-systems and /design-system
to quick-start Paths A and B workflows.

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

* Fix cross-reference gaps, broken hooks, and stale workflow chains

- Fix log-agent.sh parsing agent_type instead of agent_name (always logged "unknown")
- Fix GDD status lifecycle: design-system now writes Approved/Designed/In Review
- Clean up settings.local.json vestigial Bash grants from development
- Delete orphaned docs marked for removal in UPGRADING.md
- Add /design-system to next-steps in /start, /brainstorm, /setup-engine
- Fix WORKFLOW-GUIDE: add /map-systems + /design-system to Appendix C Workflow 1
- Fix invalid /map-systems map argument in WORKFLOW-GUIDE Step 2.1
- Update map-systems frontmatter to document [system-name] argument
- Update commit hook to validate all 8 required GDD sections (was 5)
- Update README template count 28 → 29, add 5 missing templates to quick-start

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

* Add custom status line with 7-stage production pipeline

Introduces a status line showing context %, model name, and production
stage at a glance. Aligns gate-check and project-stage-detect to a
unified 7-stage model (Concept → Systems Design → Technical Setup →
Pre-Production → Production → Polish → Release). Stage is determined
by explicit override (production/stage.txt) or auto-detected from
project artifacts. Epic/Feature/Task breadcrumb appears conditionally
in Production+ stages via a structured STATUS block in active.md.

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

* Add v0.2→v0.3 upgrade guide and PR validation test suite

- UPGRADING.md: add v0.2.0→v0.3.0 section documenting breaking rename
  of /design-systems→/map-systems, new /design-system skill, statusline.sh,
  gate-check stage advancement, and safe-to-overwrite file list

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 12:51:21 +11:00

102 lines
3.4 KiB
Bash

#!/bin/bash
# Claude Code PreToolUse hook: Validates git commit commands
# Receives JSON on stdin with tool_input.command
# Exit 0 = allow, Exit 2 = block (stderr shown to Claude)
#
# Input schema (PreToolUse for Bash):
# { "tool_name": "Bash", "tool_input": { "command": "git commit -m ..." } }
INPUT=$(cat)
# Parse command -- use jq if available, fall back to grep
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"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/"command"[[:space:]]*:[[:space:]]*"//;s/"$//')
fi
# Only process git commit commands
if ! echo "$COMMAND" | grep -qE '^git[[:space:]]+commit'; then
exit 0
fi
# Get staged files
STAGED=$(git diff --cached --name-only 2>/dev/null)
if [ -z "$STAGED" ]; then
exit 0
fi
WARNINGS=""
# Check design documents for required sections
DESIGN_FILES=$(echo "$STAGED" | grep -E '^design/gdd/')
if [ -n "$DESIGN_FILES" ]; then
while IFS= read -r file; do
if [[ "$file" == *.md ]] && [ -f "$file" ]; then
for section in "Overview" "Player Fantasy" "Detailed" "Formulas" "Edge Cases" "Dependencies" "Tuning Knobs" "Acceptance Criteria"; do
if ! grep -qi "$section" "$file"; then
WARNINGS="$WARNINGS\nDESIGN: $file missing required section: $section"
fi
done
fi
done <<< "$DESIGN_FILES"
fi
# Validate JSON data files -- block invalid JSON
DATA_FILES=$(echo "$STAGED" | grep -E '^assets/data/.*\.json$')
if [ -n "$DATA_FILES" ]; then
# Find a working Python command
PYTHON_CMD=""
for cmd in python python3 py; do
if command -v "$cmd" >/dev/null 2>&1; then
PYTHON_CMD="$cmd"
break
fi
done
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
echo "BLOCKED: $file is not valid JSON" >&2
exit 2
fi
else
echo "WARNING: Cannot validate JSON (python not found): $file" >&2
fi
fi
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
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 <<< "$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
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 <<< "$SRC_FILES"
fi
# Print warnings (non-blocking) and allow commit
if [ -n "$WARNINGS" ]; then
echo -e "=== Commit Validation Warnings ===$WARNINGS\n================================" >&2
fi
exit 0