home / skills / joncrangle / .dotfiles / prevention-patterns
This skill helps you prevent regressions by applying known bug patterns across frontend, backend, and general code health during reviews.
npx playbooks add skill joncrangle/.dotfiles --skill prevention-patternsReview the files below or copy the command above to add this skill to your agents.
---
name: PreventionPatterns
description: Known bug patterns and their fixes to prevent regression.
---
<skill_doc>
# Prevention Patterns
When reviewing code or debugging, check against these known issues.
## 🛡️ React/Frontend Patterns
- **Missing Dependency**: `useEffect` dependency array incomplete?
- **Stale Closures**: Using state in callbacks without refs or functional updates?
- **Key Props**: Using `index` as 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()` or `try/catch` in 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:
1. "Could this have been caught by a type?"
2. "Could this have been caught by a test?"
3. "Could this have been caught by a lint rule?"
Add the answer here.
</skill_doc>
This skill catalogs known bug patterns and suggested fixes to prevent regressions across frontend, backend, and general code health. It helps reviewers and maintainers spot common issues quickly and standardize post-mortem checks. Use it to reduce repeat bugs and improve codebase reliability.
The skill highlights recurring anti-patterns (e.g., stale closures, unhandled promises, SQL injection risks) and recommends concrete preventive actions. It groups patterns by area (React/frontend, Node/backend, general code health) and provides a short post-mortem protocol to capture lessons learned after fixes. Apply the checks during code review, debugging, or writing tests.
How do I decide if a pattern needs a lint rule?
If the pattern is frequent and easily detected statically (e.g., unused imports, excessive nesting), create or enable a lint rule; otherwise prefer tests or code review checklists.
What if a fix adds too much boilerplate?
Balance ergonomics and safety: use helper utilities, abstractions, or shared patterns so fixes stay consistent without repeating boilerplate.