بنقرة واحدة
code-review-assistant
Perform comprehensive code reviews following SOLID principles and best practices
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Perform comprehensive code reviews following SOLID principles and best practices
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
| name | Code Review Assistant |
| description | Perform comprehensive code reviews following SOLID principles and best practices |
| version | 1.0.0 |
Use this skill when reviewing:
DO NOT use for:
Principle: SOLID
Single Responsibility: Each class/function does ONE thing well
UserManager that handles auth + emails + loggingAuthService, EmailService, LoggerDependency Inversion: Depends on abstractions, not concretions
class OrderService depends on PostgreSQLRepositoryRepositorioBase (Protocol/Interface)Open/Closed: Open for extension, closed for modification
Naming: Variables/functions have clear, descriptive names
def calc(x, y)def calculate_total_price(items: list[Item], tax_rate: float)Complexity: Cyclomatic complexity < 10 per function
radon cc file.py to measureDRY (Don't Repeat Yourself): No code duplication (3+ lines repeated)
pylint --disable=all --enable=duplicate-codeCoverage: Critical paths have tests (>80% coverage)
pytest --cov=api --cov-report=term-missing --cov-fail-under=80Test Quality: Tests are isolated, deterministic, fast
Edge Cases: Error conditions tested
Input Validation: All user inputs validated with Pydantic
# ✅ Good
class TaskCreate(BaseModel):
title: str = Field(min_length=1, max_length=200)
priority: int = Field(ge=1, le=5)
SQL Injection: Parameterized queries used
db.execute(f"SELECT * FROM users WHERE id = {user_id}")db.execute("SELECT * FROM users WHERE id = ?", (user_id,))Secrets: No hardcoded credentials
os.getenv("API_KEY").env filesN+1 Queries: No database query loops
# ❌ N+1 query
for user_id in user_ids:
user = db.query(User).get(user_id) # N queries!
# ✅ Single query with eager loading
users = db.query(User).filter(User.id.in_(user_ids)).all()
Caching: Expensive operations cached
@lru_cache for pure functionsAsync I/O: Blocking operations are async
async with httpx.AsyncClient()await session.execute()🔴 CRITICAL: Must fix before merge
🟡 MAJOR: Should fix before merge
🟢 MINOR: Nice to have
ruff to autofix)For each issue found, provide:
[SEVERITY] [CATEGORY]: Brief description
**Issue**: Detailed explanation of the problem
**Location**: file.py:line_number
**Impact**: What could go wrong / why it matters
**Fix**:
```python
# Code showing the correction
Reference: Link to relevant documentation or checklist.md section
## Example Review
**Code being reviewed**:
```python
# api/tasks.py
def get_user_tasks(user_id: str) -> list[dict]:
user = db.query(User).get(user_id)
tasks = []
for task_id in user.task_ids:
task = db.query(Task).get(task_id) # ⚠️ N+1 query!
tasks.append({
"id": task.id,
"title": task.title,
"status": task.status
})
return tasks
Review output:
🟡 MAJOR: N+1 Query Detected
**Issue**: Line 5 executes a database query inside a loop, causing N+1 queries.
**Location**: api/tasks.py:5
**Impact**:
- Performance degrades linearly with number of tasks
- 100 tasks = 101 database queries (1 for user + 100 for tasks)
- Database connection pool exhaustion under load
**Fix**:
```python
def get_user_tasks(user_id: str) -> list[dict]:
user = db.query(User).get(user_id)
# Single query with eager loading
tasks = db.query(Task).filter(
Task.id.in_(user.task_ids)
).all()
return [
{
"id": task.id,
"title": task.title,
"status": task.status
}
for task in tasks
]
Reference: See performance_patterns.md section 3.2 - "Avoiding N+1 Queries"
🟢 MINOR: Missing Type Hints for Return
Issue: Return type annotation missing
Location: api/tasks.py:1
Fix:
from typing import TypedDict
class TaskDict(TypedDict):
id: int
title: str
status: str
def get_user_tasks(user_id: str) -> list[TaskDict]:
...
Reference: PEP 484 - Type Hints
## Tools Integration
This skill can be invoked from LangChain agents:
```python
def code_review_with_skill(code: str, file_path: str) -> str:
"""
Invoke Agent Skill for code review.
This loads:
- .claude/skills/code-review/SKILL.md
- .claude/skills/code-review/checklist.md
Returns structured review output.
"""
# Agent with skills executes review
return claude_with_skills.review(code, file_path)
Track review quality:
# metrics.json
{
"reviews_performed": 42,
"critical_issues_found": 3,
"major_issues_found": 15,
"minor_issues_found": 28,
"avg_time_per_review": "2.5 minutes"
}
Update checklist based on:
performance-optimizer - For deep performance analysissecurity-hardening - For comprehensive security audittest-coverage-strategist - For testing guidance