Agent skill
code-changes-review
Perform a comprehensive code review of current uncommitted changes in a git repository. Analyzes for bugs, security vulnerabilities, best practices, DRY violations, code smells, performance issues, and areas of improvement. Use when: review changes, code review, check my code, review diff, pre-commit review, PR review, quality check. Works with any language or framework.
Install this agent skill to your Project
npx add-skill https://github.com/yorch/claude-skills/tree/main/code-changes-review
SKILL.md
Code Changes Review
Perform a thorough, professional code review of uncommitted changes in the current git working copy.
Overview
This skill analyzes all staged and unstaged changes, providing actionable feedback across multiple quality dimensions:
- Correctness - Logic errors, bugs, edge cases
- Security - Vulnerabilities, injection risks, sensitive data exposure
- Best Practices - Language idioms, framework conventions, patterns
- DRY/Reusability - Code duplication, abstraction opportunities
- Code Smells - Maintainability issues, complexity, coupling
- Performance - Inefficiencies, N+1 queries, memory leaks
- Testing - Test coverage gaps, test quality
Instructions
Step 1: Gather Changes
First, collect all changes to be reviewed:
# Check repository status
git status
# Get the full diff of all changes (staged + unstaged)
git diff HEAD
# If only staged changes should be reviewed
git diff --cached
Important: Review BOTH staged and unstaged changes unless the user specifically requests otherwise.
Step 2: Understand Context
Before reviewing changes, understand the broader context:
- Identify the purpose - What is the change trying to accomplish?
- Check related files - Read unchanged files that interact with modified code
- Understand the codebase patterns - Look at existing code style and conventions
- Review recent commits - Check
git log -5 --onelinefor context
Step 3: Analyze Each Change
For each modified file, evaluate against the Review Checklist:
3.1 Correctness & Logic
- Does the code do what it's supposed to do?
- Are edge cases handled (null, empty, boundary values)?
- Are error conditions properly handled?
- Is the control flow correct (loops, conditionals)?
- Are there off-by-one errors?
- Are race conditions possible in concurrent code?
3.2 Security
- Input validation present for user data?
- SQL/NoSQL injection prevention (parameterized queries)?
- XSS prevention (output encoding)?
- Command injection prevention?
- Sensitive data not logged or exposed?
- Authentication/authorization properly enforced?
- Secrets not hardcoded?
- Dependencies up-to-date and without known vulnerabilities?
3.3 Best Practices
- Follows language/framework idioms?
- Consistent naming conventions?
- Appropriate abstraction level?
- Single Responsibility Principle followed?
- Functions/methods reasonably sized?
- Comments explain "why", not "what"?
- Error messages helpful and not exposing internals?
3.4 DRY & Reusability
- No duplicated code within the change?
- No duplication with existing codebase?
- Opportunities to extract reusable functions/components?
- Consistent patterns with existing code?
3.5 Code Smells
- No magic numbers/strings (use constants)?
- No deeply nested code (max 3 levels)?
- No overly long functions (context-dependent, usually <50 lines)?
- No God objects/functions doing too much?
- No tight coupling between components?
- No dead code or commented-out code?
3.6 Performance
- No N+1 query patterns?
- Appropriate data structures used?
- No unnecessary iterations or computations?
- Resources properly closed/disposed?
- Caching considered where appropriate?
- No memory leaks (especially in long-running processes)?
3.7 Testing
- Are new features covered by tests?
- Are edge cases tested?
- Do tests follow AAA pattern (Arrange, Act, Assert)?
- Are tests independent and deterministic?
- Is test naming clear and descriptive?
Step 4: Provide Structured Feedback
Organize findings by severity and category:
## Code Review Summary
**Scope**: [X files changed, Y insertions, Z deletions]
**Overall Assessment**: [Brief summary]
---
### Critical Issues (Must Fix)
These issues must be resolved before merging:
1. **[SECURITY]** `path/to/file.js:42` - SQL injection vulnerability
- **Problem**: User input directly interpolated into query
- **Fix**: Use parameterized query with `db.query(sql, [param])`
2. **[BUG]** `path/to/file.py:87` - Off-by-one error in loop
- **Problem**: Loop iterates one extra time causing IndexError
- **Fix**: Change `range(len(items) + 1)` to `range(len(items))`
---
### Important Issues (Should Fix)
These issues should be addressed:
1. **[PERFORMANCE]** `path/to/file.ts:23` - N+1 query in loop
- **Problem**: Database query inside forEach loop
- **Suggestion**: Batch fetch with single query using `IN` clause
---
### Suggestions (Nice to Have)
These are recommendations for improvement:
1. **[DRY]** `path/to/utils.js:15-30` - Duplicated validation logic
- **Current**: Same email regex in 3 places
- **Suggestion**: Extract to shared `validateEmail()` function
---
### Positive Observations
Good practices noticed in this change:
- Proper error handling with specific error types
- Clear function naming following conventions
- Comprehensive input validation on API endpoints
Step 5: Provide Actionable Recommendations
For each issue:
- Be specific - Include file path and line numbers
- Explain why - Not just what's wrong, but the impact
- Show how to fix - Provide concrete code suggestions when possible
- Prioritize - Critical > Important > Suggestions
Step 6: Summary and Next Steps
End with:
- Overall quality assessment (Ready to merge / Needs work / Major revision needed)
- Priority items - Top 3 things to fix first
- Follow-up questions - Clarifications needed from the author
Severity Levels
| Level | Label | Description | Action |
|---|---|---|---|
| Critical | [CRITICAL] |
Security vulnerabilities, data loss, crashes | Must fix before merge |
| Bug | [BUG] |
Incorrect behavior, logic errors | Must fix |
| Security | [SECURITY] |
Potential security issues | Must fix |
| Performance | [PERFORMANCE] |
Significant performance impact | Should fix |
| Warning | [WARNING] |
Code smells, potential issues | Should fix |
| DRY | [DRY] |
Duplication, reusability | Consider fixing |
| Style | [STYLE] |
Conventions, formatting | Nice to have |
| Suggestion | [SUGGESTION] |
Improvements, alternatives | Nice to have |
| Positive | [POSITIVE] |
Good practices observed | Acknowledgment |
Language-Specific Considerations
JavaScript/TypeScript
- Check for
===vs== - Proper async/await error handling
- Memory leaks in event listeners
- Type safety (TypeScript)
- Module import/export patterns
Python
- Type hints usage
- Context managers for resources
- List comprehension vs loops
- Exception handling specificity
- PEP 8 compliance
Go
- Error handling (not ignoring errors)
- Goroutine leaks
- Proper defer usage
- Interface segregation
- Effective Go patterns
Rust
- Ownership and borrowing
- Error handling with Result/Option
- Unsafe code justification
- Clippy warnings
- Idiomatic patterns
SQL Changes
- Injection vulnerabilities
- Index usage
- N+1 patterns
- Transaction boundaries
- Migration reversibility
Review Modes
Quick Review (Default)
Focus on critical and important issues:
- Security vulnerabilities
- Obvious bugs
- Major code smells
Thorough Review (--thorough)
Complete analysis including:
- All checklist items
- Style consistency
- Documentation quality
- Test coverage analysis
Security-Focused Review (--security)
Deep dive into security:
- OWASP Top 10 checks
- Authentication/authorization
- Data validation
- Cryptographic practices
Performance Review (--performance)
Focus on efficiency:
- Algorithm complexity
- Database query patterns
- Memory usage
- Caching opportunities
Integration with CI/CD
For automated reviews, output can be formatted as:
# JSON format for CI integration
--format json
# GitHub-compatible annotations
--format github
# GitLab-compatible notes
--format gitlab
Examples
Example 1: Simple Review Request
User: Review my changes
Response: [Full review following the structure above]
Example 2: Focused Review
User: Review my changes focusing on security
Response: [Security-focused review with OWASP considerations]
Example 3: Pre-commit Review
User: Quick review before I commit
Response: [Quick review highlighting only critical/important issues]
Additional Resources
- CHECKLIST.md - Complete review checklist with examples
- OWASP Top 10 - Security reference
- Code Smells Catalog - Refactoring patterns
Best Practices for Reviewers
- Be constructive - Focus on the code, not the person
- Explain the "why" - Help the author learn
- Offer alternatives - Don't just criticize
- Acknowledge good work - Positive feedback matters
- Ask questions - Understand before judging
- Be timely - Quick feedback is valuable feedback
- Stay focused - Review what changed, not unrelated code
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
typescript-unknown-jsx-expression
Fix TypeScript error "Type 'unknown' is not assignable to type ReactNode" when using Record<string, unknown> values directly in JSX && short-circuit expressions. Use when: (1) JSX expression {someObj.field && <Component />} fails with TS2322, (2) Reading from a JSON or untyped object via bracket notation in JSX conditionals, (3) Values typed as unknown appear in JSX even when wrapped in String() or guarded with truthiness checks. Fix: use !! to coerce to boolean before the && operator.
gha-docker-publish
ALWAYS invoke this skill before writing any GitHub Actions workflow that builds or pushes Docker images — it contains specific opinionated patterns that produce secure, reliable workflows and that you cannot reliably guess. The conventions it enforces include: (1) datetime+SHA image tags in YYYYMMDDHHMMSS_sha format for unambiguous build traceability, (2) a `workflow_dispatch` boolean `push` input that defaults to `false` (safe dry-run by default — a common mistake is using `type:choice` with `dry_run` inversion instead), (3) a `publish-docker` PR label gate that lets CI validate builds on PRs without pushing, (4) conditional `latest` tag using `enable={{is_default_branch}}` (never hardcoded `enable=true`), (5) GHA layer cache with `mode=max` for maximum rebuild speed, (6) no inline `${{ github.sha }}` in `run:` scripts (security hardening), (7) dual-registry login and push patterns when publishing to both GHCR and a private registry. Use this whenever the user asks to: set up GHCR publishing, add a docker-publish.yml workflow, add layer caching to Docker CI, configure datetime/SHA image tags, add a manual build-only dispatch trigger, push to multiple registries, or build Docker images on PRs.
prisma-7-docker-migrations
Run Prisma 7 migrations inside a multi-stage Docker production image. Use when: (1) `prisma migrate deploy` crashes with "Cannot resolve environment variable: DATABASE_URL" or "cannot find module" at container startup, (2) building a production Docker image that needs to run migrations before starting the server, (3) you copied only node_modules/prisma + node_modules/@prisma but the Prisma 7 CLI still fails with MODULE_NOT_FOUND at runtime, (4) Yarn 4 node-modules linker .bin/prisma symlink breaks after Docker COPY. Covers prisma.config.ts (Prisma 7), full node_modules copy requirement, and symlink recreation pattern.
rails-auto-assigned-field-validation
Fix for Rails models where validates :field, presence: true causes ALL creates to fail when the field is set by a before_create callback. Use when: (1) validates :number, presence: true is added to a model that uses before_create to auto-assign a sequence number, (2) model creates silently fail with "number can't be blank", (3) auto-generated fields (number, slug, token) fail presence validation despite being set in callbacks. Root cause: before_create runs AFTER validations. Fix: change before_create to before_validation on: :create.
app-docker-deploy-with-traefik
Generate Docker and Traefik deployment configurations for any application (Node.js, Python, Go, Rust, Java). Creates Dockerfile, docker-compose.yml, docker-compose.for-traefik.yml overlay, and .env.sample with production best practices. Use when: dockerize app, containerize, add Docker, deploy with Traefik, reverse proxy setup, HTTPS/SSL, Let's Encrypt certificates, production deployment, docker-compose setup. Requires: Docker, docker-compose.
edit-article
Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.
Didn't find tool you were looking for?