safety-critical-patterns
SolidNASA Power of 10 rules adapted for writing robust, verifiable code with context-appropriate rigor
AI & Automation 310 stars
27 forks Updated today MIT
Install
Quality Score: 94/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# Safety-Critical Coding Patterns
Guidelines adapted from NASA's Power of 10 rules for safety-critical software.
## When to Apply
**Full rigor**: Safety-critical systems, financial transactions, data integrity code
**Selective application**: Business logic, API handlers, core algorithms
**Light touch**: Scripts, prototypes, non-critical utilities
> "Match rigor to consequence" - The real engineering principle
## The 10 Rules (Adapted)
### 1. Restrict Control Flow
Avoid `goto`, `setjmp/longjmp`, and **limit recursion**.
**Why**: Ensures acyclic call graphs that tools can verify.
**Adaptation**: Recursion acceptable with provable termination (tail recursion, bounded depth).
### 2. Fixed Loop Bounds
All loops should have verifiable upper bounds.
```python
# Good - bound is clear
for i in range(min(len(items), MAX_ITEMS)):
process(item)
# Risky - unbounded
while not_done: # When does this end?
process_next()
```
**Adaptation**: Document expected bounds; add safety limits on potentially unbounded loops.
### 3. No Dynamic Memory After Initialization
Avoid heap allocation in critical paths after startup.
**Why**: Prevents allocation failures at runtime.
**Adaptation**: Pre-allocate pools; use object reuse patterns in hot paths.
### 4. Function Length ~60 Lines
Functions should fit on one screen/page.
**Why**: Cognitive limits on comprehension remain valid.
**Adaptation**: Flexible for declarative code; strict for complex logic.
### 5. Assertion Density
Inclu...
Details
- Author
- athola
- Repository
- athola/claude-night-market
- Created
- 6 months ago
- Last Updated
- today
- Language
- Python
- License
- MIT
Bundled in these plugins
Similar Skills
Semantically similar based on skill content — not just same category
AI & Automation Listed
ai-code-maintainability
Write production-safe code that survives maintenance — avoid the 15 patterns AI agents commonly generate that work on day 1 but break 3 months later; enforce error handling, logging, type safety, no magic values, and testable structure before writing any code.
1 Updated today
phamlongh230-lgtm Code & Development Featured
clean-code
Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
28,146 Updated today
davila7 Code & Development Listed
clean-code
Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
1 Updated 3 days ago
phuonghx