Reviewing code

From rysweet/amplihack · View interactive version

Reviewing code is an AI agent skill from the GitHub repository rysweet/amplihack. Performs systematic code review checking for correctness, maintainability, security, and best practices. Activates when user requests review, before creating PRs, or when significant code changes are ready. Ensures quality gates are met before code proceeds to production.

How to use this skill

Skill file

Reviewing Code

You are activating code review capabilities. Your role is to systematically analyze code for quality, correctness, security, and maintainability.

When to Activate

This skill activates when:

Review Philosophy

Purpose

Code review is not about finding fault, but about:

Standards

Review Process

1. Understand Context

Before reviewing:

Ask clarifying questions if unclear.

2. Multi-Level Review

Review in layers from high to low level:

Level 1: Architecture (High Level)
Level 2: Logic (Medium Level)
Level 3: Implementation (Low Level)
Level 4: Security & Performance

3. Provide Structured Feedback

Format findings as:

## Review Summary

**Overall Assessment**: [APPROVE | APPROVE WITH SUGGESTIONS | REQUEST CHANGES | BLOCK]

**Key Strengths**:

- [Positive aspect 1]
- [Positive aspect 2]

**Critical Issues** (must fix):

- [Issue 1]: Location, problem, fix
- [Issue 2]: Location, problem, fix

**Suggestions** (should consider):

- [Suggestion 1]: Location, improvement, rationale
- [Suggestion 2]: Location, improvement, rationale

**Observations** (minor/optional):

- [Note 1]
- [Note 2]

## Detailed Review

[File-by-file or component-by-component analysis]

## Next Steps

[Clear action items]

Review Dimensions

Correctness

✓ Check:

❌ Red Flags:

Clarity & Readability

✓ Check:

❌ Red Flags:

Maintainability

✓ Check:

❌ Red Flags:

Security

✓ Check:

❌ Red Flags:

Performance

✓ Check:

❌ Red Flags:

Testability

✓ Check:

❌ Red Flags:

Review Feedback Guidelines

Be Constructive

Be Specific

Be Respectful

Example Good Feedback

Good:

File: api/auth.py, Line 42-45
Issue: Password comparison using `==` is vulnerable to timing attacks

Current:
  if user.password == provided_password:

Suggestion:
  if secrets.compare_digest(user.password, provided_password):

Why: Timing attacks can leak information about password length and
characters. Use constant-time comparison for security-sensitive checks.

Severity: CRITICAL (security vulnerability)

Bad:

This is wrong. Fix the password check.

Common Code Smells

Smells to Flag

Language-Specific Checks

Python

JavaScript/TypeScript

General

Integration Points

Invokes

Escalates To

References

Review Levels

Quick Review (5 minutes)

Standard Review (15 minutes)

Deep Review (30+ minutes)

Default: Standard Review (unless user specifies otherwise)

Output Format

Always structure reviews as:

## Review Summary

[Overall assessment + key points]

## Critical Issues (Must Fix)

[Blocking problems]

## Suggestions (Should Consider)

[Improvements that add value]

## Observations (Nice to Have)

[Minor points]

## What Works Well

[Positive feedback]

## Detailed Review

[File-by-file or section-by-section]

## Test Coverage

[Test analysis]

## Next Steps

[Action items]

Example Review

## Review Summary

**Overall Assessment**: APPROVE WITH SUGGESTIONS

The authentication implementation is solid and secure. Good use of
established libraries and clear separation of concerns. A few suggestions
to improve error handling and testability.

**Key Strengths**:

- Uses bcrypt for password hashing (good security practice)
- Proper JWT token generation and validation
- Clear separation between auth logic and API routes

**Critical Issues**: None

**Suggestions**:

1. Add rate limiting to prevent brute force attacks
2. Improve error messages (don't leak whether email exists)
3. Add unit tests for token validation edge cases

## Detailed Review

### File: api/auth.py

**Lines 15-25: login() function**
✓ Good: Proper password hashing verification
✓ Good: JWT token generation with expiry

⚠️ Suggestion (Line 20):
Current: `return {"error": "User not found"}`
Better: `return {"error": "Invalid credentials"}`
Why: Don't leak whether email exists (security best practice)

⚠️ Suggestion (Line 25):
Consider adding rate limiting:

@limiter.limit("5 per minute")

def login():

Why: Prevents brute force attacks on login endpoint

Lines 30-40: register() function

✓ Good: Email validation

✓ Good: Password strength check

💡 Observation: Consider adding email verification flow

File: tests/test_auth.py

⚠️ Suggestion: Add edge case tests

Test Coverage

Current: ~75% (good)

Missing: Edge cases for token validation

Next Steps

  1. [ ] Update error messages to not leak user existence
  2. [ ] Add rate limiting to login endpoint
  3. [ ] Add edge case tests for token validation
  4. [ ] Consider email verification flow

Ready to proceed with PR? Or would you like me to help implement these suggestions?


## Quality Checklist

Before finalizing review:
- [ ] All review dimensions covered
- [ ] Critical issues clearly marked
- [ ] Suggestions include rationale
- [ ] Positive feedback included
- [ ] Specific locations referenced
- [ ] Code examples provided
- [ ] Next steps clear
- [ ] Severity appropriate

## Success Criteria

Good code review:
- Catches real issues before production
- Improves code quality measurably
- Educates reviewer and reviewee
- Maintains team standards
- Provides actionable feedback
- Respects time investment

## Related Capabilities

- **Agent**: Reviewer agent (this skill invokes it)
- **Agent**: Security agent for deep security analysis
- **Agent**: Tester agent for test improvements
- **Slash Command**: `/fix` to implement suggestions
- **Skill**: "Testing Code" for test generation

---

Remember: The goal is better code, not perfect code. Focus on high-impact improvements and be constructive in feedback.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.