AgentSkillsCN

code-review

为 Flare Stack 博客提供官方的样式与设计指南。

SKILL.md
--- frontmatter
name: code-review
description: Reviews code changes for bugs, style issues, and best practices. Use when reviewing PRs, checking code quality, or validating changes before commit.

Code Review Skill

When reviewing code changes, follow this systematic approach to ensure quality and consistency.

Review Checklist

1. Correctness

  • Does the code do what it's supposed to do?
  • Are edge cases handled (null, empty, boundary values)?
  • Are error conditions properly caught and handled?
  • Is the logic correct and complete?

2. Type Safety

  • Are types properly defined (no any or unknown without justification)?
  • Are nullable values handled with proper checks?
  • Do function signatures match their implementations?

3. Architecture Compliance

Verify changes follow project patterns:

LayerExpected Pattern
Data LayerPure DB queries, no business logic
Service LayerBusiness logic, caching, typed context (DbContext, AuthContext)
API LayercreateServerFn() with middleware chains

4. Security

  • Are user inputs validated (Zod schemas)?
  • Is authentication/authorization properly enforced?
  • Are sensitive data properly protected?
  • No hardcoded secrets or credentials?

5. Performance

  • Are there obvious inefficiencies (N+1 queries, unnecessary re-renders)?
  • Is caching used appropriately?
  • Are background tasks delegated to waitUntil when appropriate?

6. Code Style

  • Follows naming conventions (camelCase, PascalCase, kebab-case files)?
  • Server Functions end with Fn suffix?
  • Proper use of semantic color variables for styling?

Review Process

Step 1: Understand Context

bash
# View recent commits
git log -5 --oneline

# View staged changes
git diff --cached

# View unstaged changes
git diff

Step 2: Identify Changed Files

Categorize by type:

  • Backend (.service.ts, .api.ts, .data.ts)
  • Frontend (.tsx in routes/components)
  • Config (.config.ts, wrangler.jsonc)
  • Tests (.test.ts)

Step 3: Review Each Change

For each file, check:

  1. What changed? (additions, deletions, modifications)
  2. Why? (bug fix, feature, refactor)
  3. Is it correct? (logic, types, patterns)
  4. Any concerns? (breaking changes, missing tests)

Step 4: Validate

bash
# Type check
bun tsc --noEmit

# Lint and format
bun check

# Run tests if applicable
bun run test

Providing Feedback

Format

Structure feedback as:

markdown
## Summary
Brief overview of changes and overall assessment.

## Issues Found
- 🔴 **Critical**: Must fix before merge
- 🟡 **Warning**: Should fix, but not blocking
- 🔵 **Suggestion**: Nice to have improvements

## Specific Comments
File-by-file or section-by-section feedback with code references.

## Questions
Any clarifications needed from the author.

Tone Guidelines

  • Be specific about what needs to change
  • Explain why, not just what
  • Suggest alternatives when possible
  • Acknowledge good patterns and improvements
  • Use questions for subjective preferences

Common Issues to Watch For

Backend

IssueExampleFix
Wrong context typecontext: anyUse DbContext, AuthContext, etc.
Missing cache invalidationUpdate without bumpVersion()Add cache invalidation
Workflow not triggeredDirect DB update on publishCall workflow via binding

Frontend

IssueExampleFix
Missing loading stateNo pendingComponentAdd skeleton component
Stale query dataMissing queryKey invalidationCall queryClient.invalidateQueries()
Hardcoded colorstext-gray-500Use text-muted-foreground

Tests

IssueExampleFix
Missing awaitawait seedUser() not awaitedAdd await
No background task waitAssert immediately after async opUse waitForBackgroundTasks()
Using anyas any castUpdate test-utils or use proper types