safety-check
Audit code for runtime safety and security vulnerabilities. Use when reviewing code, before commits, or performing security assessments.
When & Why to Use This Skill
The safety-check Claude skill is a comprehensive code auditing tool designed to identify critical runtime safety issues and security vulnerabilities. By automating the inspection of source code for common pitfalls like null pointer dereferences, race conditions, and OWASP Top 10 threats, it helps developers ensure application stability and harden software against potential exploits during the development lifecycle.
Use Cases
- Pre-commit Security Audits: Automatically scan code changes for injection vulnerabilities and hardcoded secrets before they reach the repository.
- Runtime Reliability Checks: Identify complex concurrency issues such as race conditions, deadlocks, and resource leaks in high-performance applications.
- Automated Peer Review: Supplement manual code reviews with an objective safety checklist to catch edge cases like integer overflows or unhandled errors.
- Legacy Code Assessment: Perform deep-dive security assessments on existing codebases to align with modern safety standards and cryptographic best practices.
| name | safety-check |
|---|---|
| description | Audit code for runtime safety and security vulnerabilities. Use when reviewing code, before commits, or performing security assessments. |
| allowed-tools | ["shell", "read_file"] |
| short-description | Comprehensive safety audit |
Safety Audit
Read this reference:
~/.config/agent/domain/coding/safety.md- Complete safety checklist (Part 1: Runtime, Part 2: Security)
Instructions
Perform comprehensive safety audit covering both runtime and security:
Part 1: Runtime Safety (9 Categories)
Nil/Null Pointer Dereferences
- All pointer dereferences checked
- Optional/Result types properly unwrapped
- No assumptions about non-nil values
Race Conditions & Data Races
- Shared mutable state properly synchronized
- Mutex usage correct (defers, no double-locks)
- No unprotected concurrent access
Resource Leaks
- File handles closed (defers)
- Connections released
- Memory freed (in manual-memory languages)
- Contexts cancelled
Buffer Overflows & Bounds Checking
- Array/slice access within bounds
- String operations safe
- No unchecked buffer writes
Integer Overflow/Underflow
- Arithmetic checked for overflow
- Type conversions validated
- Size calculations safe
Uninitialized Values
- All variables initialized before use
- No reliance on zero values unless intentional
Error Handling
- All errors checked and handled
- No ignored errors
- Error context preserved (wrapping)
Panics/Crashes
- No panic in library code (return errors)
- Recover only where appropriate
- Graceful degradation
Deadlocks
- Consistent lock ordering
- No circular dependencies
- Timeouts on blocking operations
Part 2: Security Safety (OWASP Top 10+)
Injection Vulnerabilities
- SQL injection (use parameterized queries)
- Command injection (avoid shell, sanitize input)
- XSS (escape output, CSP headers)
Authentication & Authorization
- Proper credential storage (hashed, salted)
- Session management secure
- Authorization checks on all resources
Sensitive Data Exposure
- No hardcoded secrets
- Encryption for data at rest/in transit
- No secrets in logs
Input Validation
- All external input validated
- Type checking, range checking
- Sanitization before use
Cryptography
- Use standard libraries (no custom crypto)
- Secure random number generation
- Proper key management
Arguments
Target file(s) or package(s): ${ARGUMENTS}