mirror of
https://github.com/Donchitos/Claude-Code-Game-Studios
synced 2026-04-21 21:37:19 +00:00
61 lines
2 KiB
Markdown
61 lines
2 KiB
Markdown
|
|
# Hook: pre-commit-code-quality
|
||
|
|
|
||
|
|
## Trigger
|
||
|
|
|
||
|
|
Runs before any commit that modifies files in `src/`.
|
||
|
|
|
||
|
|
## Purpose
|
||
|
|
|
||
|
|
Enforces coding standards before code enters version control. Catches style
|
||
|
|
violations, missing documentation, overly complex methods, and hardcoded
|
||
|
|
values that should be data-driven.
|
||
|
|
|
||
|
|
## Implementation
|
||
|
|
|
||
|
|
```bash
|
||
|
|
#!/bin/bash
|
||
|
|
# Pre-commit hook: Code quality checks
|
||
|
|
# Adapt the specific checks to your language and tooling
|
||
|
|
|
||
|
|
CODE_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '^src/')
|
||
|
|
|
||
|
|
EXIT_CODE=0
|
||
|
|
|
||
|
|
if [ -n "$CODE_FILES" ]; then
|
||
|
|
for file in $CODE_FILES; do
|
||
|
|
# Check for hardcoded magic numbers in gameplay code
|
||
|
|
if [[ "$file" == src/gameplay/* ]]; then
|
||
|
|
# Look for numeric literals that are likely balance values
|
||
|
|
# Adjust the pattern for your language
|
||
|
|
if grep -nP '(?<![\w.])(?:damage|health|speed|rate|chance|cost|duration)\s*[:=]\s*\d+' "$file"; then
|
||
|
|
echo "WARNING: $file may contain hardcoded gameplay values. Use data files."
|
||
|
|
# Warning only, not blocking
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Check for TODO/FIXME without assignee
|
||
|
|
if grep -nP '(TODO|FIXME|HACK)(?!\()' "$file"; then
|
||
|
|
echo "WARNING: $file has TODO/FIXME without owner tag. Use TODO(name) format."
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Run language-specific linter (uncomment appropriate line)
|
||
|
|
# For GDScript: gdlint "$file" || EXIT_CODE=1
|
||
|
|
# For C#: dotnet format --check "$file" || EXIT_CODE=1
|
||
|
|
# For C++: clang-format --dry-run -Werror "$file" || EXIT_CODE=1
|
||
|
|
done
|
||
|
|
|
||
|
|
# Run unit tests for modified systems
|
||
|
|
# Uncomment and adapt for your test framework
|
||
|
|
# python -m pytest tests/unit/ -x --quiet || EXIT_CODE=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
exit $EXIT_CODE
|
||
|
|
```
|
||
|
|
|
||
|
|
## Agent Integration
|
||
|
|
|
||
|
|
When this hook fails:
|
||
|
|
1. For style violations: auto-fix with your formatter or invoke `lead-programmer`
|
||
|
|
2. For hardcoded values: invoke `gameplay-programmer` to externalize the values
|
||
|
|
3. For test failures: invoke `qa-tester` to diagnose and `gameplay-programmer` to fix
|