| name | review |
| description | Review code quality, security, and maintainability before committing. Use when reviewing code changes, checking code quality, performing security review, or validating changes before commit. |
Code Review Before Commit
Review code quality, security, and maintainability before committing changes to Linus Dashboard.
Your Role
Senior code reviewer ensuring quality, security, and maintainability.
Context Required:
- .aidriven/memorybank.md
- .aidriven/rules/ - All rule files
- Changed files (git diff)
Review Checklist
1. Code Quality
Readability:
Structure:
Type Safety:
2. Documentation
3. Error Handling
4. Async/Await
5. Home Assistant Patterns
6. Security
7. Performance
8. Testing
Review Process
Step 1: Get Changed Files
git status
git diff
git diff path/to/file.py
Step 2: Analyze Changes
For each changed file:
- Read the diff
- Understand the purpose
- Check against standards
- Look for issues
- Note improvements
Step 3: Check Build and Tests
npm run build
npm run type-check
npm run lint:check
npm run test:smoke
Step 4: Provide Feedback
Format:
File: path/to/file.py
✅ Good:
- Clear function names
- Proper type hints
- Good error handling
⚠️ Issues:
1. Line 42: Missing docstring
2. Line 78: Blocking I/O in async function
3. Line 103: Exception too broad
💡 Suggestions:
- Consider caching this result
- Extract this logic to separate function
Common Issues to Watch For
Python Issues
Async/Await:
async def fetch_data():
response = requests.get(url)
async def fetch_data():
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
return await response.json()
Error Handling:
try:
do_something()
except:
pass
try:
do_something()
except ValueError as err:
_LOGGER.error("Invalid value: %s", err)
raise
Type Hints:
def process_data(data):
return data.get("value")
def process_data(data: dict[str, Any]) -> str | None:
"""Process data and return value."""
return data.get("value")
TypeScript Issues
Type Safety:
function process(data: any): any {
return data.value;
}
function process(data: DataType): string | undefined {
return data.value;
}
Null Safety:
const value = entity.state.toUpperCase();
const value = entity.state?.toUpperCase() ?? "unknown";
Security Review Checklist
Performance Review Checklist
Final Review
Before approving:
Code Quality:
- Follows project standards
- Well-documented
- Properly typed
- Good error handling
Functionality:
- Implements requirements
- No obvious bugs
- Edge cases handled
- Tested manually
Maintainability:
- Easy to understand
- Well-structured
- Follows patterns
- Documented properly
Security:
- No vulnerabilities
- Input validated
- Secrets protected
Review Outcome
APPROVE - Code meets all standards
REQUEST CHANGES - Issues must be fixed
COMMENT - Suggestions for improvement
Quick Commands
git diff
git diff path/to/file
git log --oneline -10
npm run lint:check
npm run type-check
npm run build
npm run test:smoke