Required Pre-Commit Checks
Before committing changes, you must verify your code passes all checks.Quick Verification
Pre-Commit Hooks
Automatically run verification checks on commit and push.Installation
Hook Stages
- pre-commit (Fast)
- pre-push (Heavy)
Runs on
git commit, file-scoped fast checks:ruff check(linting)import-linter(import contracts)ty check(type checking)scripts/check_docs.py(docs validation)sg scan(ast-grep)ziglint(Zig linting, if applicable)
ziglint behavior is configured in
crimson-zig/.ziglint.zon (Z024 disabled).CI-Equivalent Local Runs
Run the exact checks that CI will run:Python/Docs/Tooling Changes
For changes tosrc/, tests/, docs/, tools/:
Zig-Only Changes
For changes tocrimson-zig/:
Mixed Changes
For changes to both Python and Zig:Individual Verification Steps
Linting
pyproject.toml:
- Line length: 120
- Enabled rules: B007, B017, B023, B904, COM812, I001, PGH003, PT017, RUF012, RUF100, S113, S607, TRY004, UP035
- Ignored: E402
Import Contracts
pyproject.toml:
grim must not import crimson
grim must not import crimson
The engine layer (
grim) must remain independent of game logic (crimson).Perk isolation
Perk isolation
Perk implementations and runtime must stay out of selection and availability logic.
Selection/availability independence
Selection/availability independence
Selection and availability must not import perk implementations directly.
Type Checking
Documentation Validation
AST-grep Scanning
Testing
Build Verification
Verification Failures
Linting Failures
Most linting issues can be auto-fixed:Type Checking Failures
Common fixes:- Add type annotations to function signatures
- Use proper type guards for conditionals
- Define typed dataclasses for structured data
- Fix boundary parsing to return typed objects
Import Contract Violations
Iflint-imports fails:
- Review the contract - Is the import genuinely needed?
- Restructure - Can the dependency be inverted?
- Extract interface - Should there be a shared protocol?
Test Failures
For test failures:- Read the failure message - What assertion failed?
- Check parity evidence - Does this match native behavior?
- Isolate the test - Run it individually with
-v - Debug - Use
--pdbto drop into debugger
Skipping Checks (Discouraged)
Skip Pre-Commit Hook
Skip Pre-Push Hook
Verification Best Practices
Run Checks Frequently
Run
just check frequently during development, not just before committing.Fix Issues Immediately
Address verification failures as they arise, don’t accumulate technical debt.
Understand Failures
Don’t blindly fix verification failures. Understand why the check exists.
Use Hooks
Install pre-commit and pre-push hooks to catch issues early.
Next Steps
Testing Guide
Deep dive into testing practices
Parity Workflow
Learn the parity-first development approach
Code Style
Follow project coding standards
Tooling Guide
Explore development tools and scripts