Install
npx skillscat add joncrangle/dotfiles/preventionpatterns Install via the SkillsCat registry.
About this skill
The PreventionPatterns skill provides a checklist of common bug patterns in React, Node, and general code, along with fixes to avoid regression. It helps developers identify and correct issues such as missing dependencies, unhandled promises, and naming problems during review or debugging.
SKILL.md
# Prevention Patterns
When reviewing code or debugging, check against these known issues.
🛡️ React/Frontend Patterns
- Missing Dependency:
useEffectdependency array incomplete? - Stale Closures: Using state in callbacks without refs or functional updates?
- Key Props: Using
indexas key in list rendering? (Bad for re-ordering). - Zod Schema mismatch: Frontend types not aligned with Backend API responses?
🛡️ Node/Backend Patterns
- Unhandled Promise: Missing
.catch()ortry/catchin async handlers? - SQL Injection: String concatenation in queries instead of parameters?
- Env Vars: Hardcoded secrets instead of
process.env? - Race Conditions: Parallel DB updates to the same record?
🛡️ General Code Health
- Slop Variables:
data,info,temp,obj. Rename them. - Deep Nesting: More than 3 levels of indentation? Refactor/Extract.
- Dead Code: Imports unused? Functions never called?
🧪 Post-Mortem Protocol
When a bug is fixed, ask:
- "Could this have been caught by a type?"
- "Could this have been caught by a test?"
- "Could this have been caught by a lint rule?"
Add the answer here.</skill_doc>