skills/cain96/code-review/SKILL.md
Automated code review analyzing security, performance, maintainability, and test coverage. Activated during code reviews or when conducting analysis.
npx skillsauth add aiskillstore/marketplace code-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides comprehensive automated code review with focus on security, performance, maintainability, and test coverage.
Check for:
Common Vulnerabilities:
// ❌ SQL Injection risk
const query = `SELECT * FROM users WHERE id = ${userId}`;
// ✅ Use parameterized queries
const query = 'SELECT * FROM users WHERE id = ?';
db.query(query, [userId]);
// ❌ XSS vulnerability
element.innerHTML = userInput;
// ✅ Sanitize input
element.textContent = userInput;
// or use a sanitization library
// ❌ Hardcoded secret
const API_KEY = "sk_live_abc123xyz789";
// ✅ Use environment variables
const API_KEY = process.env.API_KEY;
Check for:
Common Issues:
// ❌ N+1 query problem
for (const user of users) {
const posts = await db.query('SELECT * FROM posts WHERE user_id = ?', [user.id]);
}
// ✅ Single query with JOIN
const usersWithPosts = await db.query(`
SELECT users.*, posts.*
FROM users
LEFT JOIN posts ON users.id = posts.user_id
`);
// ❌ Unnecessary re-renders
function Component({ data }) {
const processedData = expensiveOperation(data); // Runs every render
return <div>{processedData}</div>;
}
// ✅ Memoization
function Component({ data }) {
const processedData = useMemo(() => expensiveOperation(data), [data]);
return <div>{processedData}</div>;
}
Check for:
Metrics:
// ❌ High complexity (complexity: 10+)
function processOrder(order) {
if (order.type === 'standard') {
if (order.amount > 100) {
if (order.customer.isPremium) {
if (order.items.length > 5) {
// Deep nesting continues...
}
}
}
}
}
// ✅ Refactored (complexity: 3)
function processOrder(order) {
if (!isProcessable(order)) {
return handleInvalidOrder(order);
}
const discount = calculateDiscount(order);
return applyDiscount(order, discount);
}
function isProcessable(order) {
return order.type === 'standard' && order.amount > 0;
}
Check for:
Coverage Goals:
🔍 Code Analysis Results
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📈 Performance
✅ 3 optimization opportunities found
- UsersList component: Recommend React.memo (line 45)
- API call results: Add caching (line 128)
- Array operations: Parallelize with Promise.all (line 201)
🔒 Security
✅ No critical issues detected
⚠️ 1 warning
- Input validation: Add sanitization for user-generated content (line 89)
🛠️ Maintainability
⚠️ 2 method extractions recommended
- validateUserInput: Complexity 15 → recommend <10 (line 156)
- processPaymentData: Length 120 lines → recommend <50 (line 234)
✅ Test Coverage
📊 85% (target: 90%)
- Add 3 error handling test cases
- Test invalid email format (auth.test.ts)
- Test network timeout (api.test.ts)
- Test concurrent updates (user.test.ts)
- Add 2 edge case tests
- Test empty array input (utils.test.ts)
- Test boundary values (validation.test.ts)
📚 Documentation
⚠️ 2 functions missing proper documentation
- calculateTotalPrice(): Add JSDoc (line 45)
- formatUserData(): Missing parameter descriptions (line 123)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Priority: 🔴 1 Critical, 🟡 5 High, 🟢 8 Medium
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Execute during review:
# Automated checks script
pnpm run lint
pnpm tsc --noEmit
pnpm test -- --coverage
pnpm audit
# Run automated checks
pnpm run lint
pnpm tsc --noEmit
pnpm test -- --coverage
pnpm audit
# Generate coverage report
pnpm test -- --coverage --coverageReporters=html
# Check bundle size
pnpm run build
pnpm run analyze
Focus on:
Structure feedback:
## Review Comments
### 🔴 Critical Issues
1. **Security**: SQL injection vulnerability in user search (line 45)
- Use parameterized queries
- Add input validation
### 🟡 High Priority
1. **Performance**: N+1 query in getUserPosts (line 123)
- Recommend eager loading with JOIN
- Estimated improvement: 80% faster
### 🟢 Suggestions
1. **Maintainability**: Extract validation logic (line 200)
- Create separate validator function
- Improves testability
### ✅ Positive Feedback
- Clean error handling implementation
- Good test coverage for new features
- Clear commit messages
Long Method (>50 lines):
// Smell: Method too long
function processOrder(order) {
// 100+ lines of code
}
// Fix: Extract smaller functions
function processOrder(order) {
validateOrder(order);
calculateTotal(order);
applyDiscounts(order);
finalizeOrder(order);
}
Large Class (>300 lines):
// Smell: God object
class UserManager {
// 500+ lines handling everything
}
// Fix: Split responsibilities
class UserAuthenticator { }
class UserProfileManager { }
class UserNotificationService { }
Duplicate Code:
// Smell: Copy-paste code
function calculatePriceA(items) {
let total = 0;
for (const item of items) {
total += item.price * item.quantity;
}
return total * 1.1; // tax
}
function calculatePriceB(products) {
let sum = 0;
for (const product of products) {
sum += product.price * product.quantity;
}
return sum * 1.1; // tax
}
// Fix: Extract common logic
function calculateSubtotal(items) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
function applyTax(amount) {
return amount * 1.1;
}
function calculatePrice(items) {
return applyTax(calculateSubtotal(items));
}
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.