Commit e930700
Add Safe Scientific Development System for Claude Code (#10)
* feat: add hook utility libraries for env and numerical validation
- env_check.sh: Conda environment detection and validation
- numerical_validation.sh: Snapshot and invariant checking utilities
- Fix .gitignore to allow .claude/hooks/lib/ (was blocked by /lib/ pattern)
Part of safe scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: add pre-tool-use hook for environment and commit safety
- Warns when Python commands run outside conda environment
- Reminds to run tests before commits
- Blocks snapshot updates without approval
Part of safe scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix test cache detection in pre-tool-use hook
The find command on line 42 was looking for files with a "*.pytest_cache"
pattern, which doesn't exist. The .pytest_cache directory contains files
with various names (like .gitignore, CACHEDIR.TAG, README.md, v/cache/, etc.),
not files ending in .pytest_cache.
Changed from:
find .pytest_cache -name "*.pytest_cache" -mmin -5
To:
find .pytest_cache -type f -mmin -5
This correctly finds any files in the .pytest_cache directory that were
modified within the last 5 minutes, properly detecting recent test runs.
Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: add user-prompt-submit hook for snapshot detection
- Detects when snapshot files have changed
- Reminds Claude to provide full analysis before updates
Part of safe scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: add scientific-tdd skill for test-driven development
Pragmatic TDD workflow for scientific code with numerical validation.
Part of safe scientific development system.
* feat: add numerical-validation skill for mathematical correctness
Comprehensive numerical validation workflow with tolerance guidelines.
Part of safe scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: add safe-refactoring skill for structure changes
Zero-tolerance workflow for behavior-preserving refactoring.
Part of safe scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* docs: enhance CLAUDE.md with operational rules, numerical standards, and workflow guide
Add three critical sections to CLAUDE.md for safe scientific development:
**Task 7 - Critical Operational Rules:**
- Mandatory skills usage (scientific-tdd, numerical-validation, safe-refactoring, jax)
- Environment enforcement rules (conda activation required)
- Guided autonomy boundaries (what Claude can do vs. must ask permission)
- Snapshot update approval process with required 4-part analysis format
**Task 8 - Numerical Accuracy Standards:**
- When numerical validation is required (which files/components)
- Tolerance specifications table (1e-14 for refactoring, 1e-10 for algorithms)
- Mathematical invariants that must always hold (probabilities, stochastic matrices, etc.)
- Validation commands (property tests, golden regression, snapshots)
**Task 9 - Workflow Selection Guide:**
- Decision tree for selecting appropriate workflow/skill
- Task-based guidance (new features, bugs, refactoring, JAX, etc.)
- JAX code requirements and best practices
- JAX-specific validation checklist
These enhancements provide Claude with clear operational guidelines, numerical
accuracy requirements, and workflow selection criteria for scientific development.
Before: 132 lines
After: 357 lines
Added: 225 lines
Part of safe scientific development system implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* docs: add README files for skills and hooks directories
Task 10: Create .claude/skills/README.md
- Overview of all 3 skills (scientific-tdd, numerical-validation, safe-refactoring)
- Usage guidance for each skill
- Workflow summaries
- Integration and maintenance information
Task 11: Create .claude/hooks/README.md
- Overview of both hooks (pre-tool-use.sh, user-prompt-submit.sh)
- Utility library documentation (env_check.sh, numerical_validation.sh)
- Testing procedures and expected behavior
- Debugging guidance
- Integration with skills explanation
Both READMEs provide clear documentation of the safe scientific
development system components.
Part of safe scientific development system implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* feat: add integration test and user guide for safe development system
Task 12: Integration test script (tests/test_safe_dev_system.sh)
- Tests all 8 categories: hook utilities, hooks, skills, CLAUDE.md,
functional tests, snapshot protection, git config, documentation
- Validates complete system installation and functionality
- All tests passing
Task 13: Comprehensive user guide (docs/SAFE_DEVELOPMENT_GUIDE.md)
- Quick start for users and Claude
- Three-layer system explanation
- Common workflow examples with checkpoints
- Approval gate processes with checklists
- Numerical tolerance guidelines
- Troubleshooting guide
- Customization instructions
- Best practices and FAQ
Both are final documentation/testing deliverables for the safe
scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* docs: add system verification report
Complete verification of all components, functional testing results,
and maintenance procedures.
Final deliverable for safe scientific development system.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add XML headers to skill files
- Add proper XML metadata headers to scientific-tdd skill
- Add proper XML metadata headers to numerical-validation skill
- Add proper XML metadata headers to safe-refactoring skill
Headers follow Claude Code skill format with name, description, tags, and version.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: resolve ruff linting errors
- Fix import sorting (ruff I001)
- Remove unused variable assignment (ruff F841)
- Remove trailing whitespace (ruff W291)
- Remove whitespace from blank lines (ruff W293)
- Remove unused import (ruff F401)
All auto-fixed with ruff check --fix and ruff format.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: apply black formatting for CI compliance
Black and ruff have slightly different formatting preferences.
Applying black formatting to match CI requirements.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* refactor: switch from black to ruff formatting
- Remove black formatting check from CI workflow
- Use ruff format exclusively for code formatting
- Reformat all files with ruff format
Ruff provides equivalent formatting to black with additional
linting capabilities, simplifying the toolchain.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: actually remove black formatting check from CI
Previous commit included the workflow file but the edit didn't apply correctly.
This commit properly removes the black formatting check step.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>1 parent 2197d48 commit e930700
File tree
28 files changed
+6179
-221
lines changed- .claude
- hooks
- lib
- skills
- numerical-validation
- safe-refactoring
- scientific-tdd
- docs
- plans
- src/non_local_detector
- tests
- integration
- likelihoods
- models
- transitions
- visualization
- tests
28 files changed
+6179
-221
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments