AgentSkillsCN

klair-pr-review

针对 Klair 代码库的模式,开展全面的 PR 审查。在审查拉取请求、检查代码质量,或进行合并前验证时使用。可通过“审查 PR”“审查我的改动”“合并前检查”“Klair 审查”等操作触发。

SKILL.md
--- frontmatter
name: klair-pr-review
description: Comprehensive PR review tailored to Klair codebase patterns. Use when reviewing a pull request, checking code quality, or running pre-merge validation. Triggers on "review PR", "review my changes", "pre-merge check", "klair review".
allowed-tools: [Read, Bash, Glob, Grep, Task, Edit]

Klair PR Review

Comprehensive code review skill derived from analysis of 500+ PRs and 1,988 human review comments from the Klair team. Covers both frontend (React/TypeScript) and backend (Python/FastAPI) with codebase-specific patterns.

When to Use

  • Before creating or merging a PR
  • After implementing a feature or fix
  • When asked to review code changes

Workflow

code
1. Gather Changes  ──►  2. Review (7 dimensions)  ──►  3. Report
   git diff main           Run all applicable           Structured output
   Read changed files      checklists in parallel       by severity

Step 1: Gather Context

bash
# Get the diff
git diff main...HEAD --stat        # Overview of changed files
git diff main...HEAD               # Full diff
git log main..HEAD --oneline       # Commits in this PR

Read each changed file in full (not just the diff). Many issues require surrounding context.

Step 2: Run Review Dimensions

Run ALL 7 dimensions that apply to the changed files. Use Task agents in parallel for independent dimensions.

#DimensionApplies ToGuideline
1Correctness & LogicAll files[guidelines/correctness-review.md]
2Error Handling & ResilienceAll files[guidelines/error-handling-review.md]
3SecurityAll files[guidelines/security-review.md]
4Frontend Patterns.ts/.tsx/.css[guidelines/frontend-review.md]
5Backend Patterns.py[guidelines/backend-review.md]
6Data Pipelinepipelines/, ETL code[guidelines/pipeline-review.md]
7Cross-Cutting ConcernsAll files[guidelines/cross-cutting-review.md]

Step 3: Generate Report

Output a structured report following this format:

markdown
# PR Review: [PR title or branch name]

## Critical (must fix before merge)
- [file:line] Issue description. **Why:** Impact explanation. **Fix:** Specific recommendation.

## High (strongly recommended)
- ...

## Medium (should fix)
- ...

## Low / Suggestions
- ...

## Positive Observations
- Things done well (reinforces good patterns)

## Summary
- X critical, Y high, Z medium, W low findings
- Recommendation: APPROVE / REQUEST CHANGES / APPROVE WITH SUGGESTIONS

Severity Classification

LevelCriteriaExamples
CriticalWill cause incorrect behavior, data loss, security vulnerability, or production failureWrong formula, silent data corruption, XSS, unhandled crash path
HighSignificant quality issue likely to cause problemsSilent failures, missing error propagation, React anti-patterns causing state bugs
MediumShould be fixed but won't cause immediate problemsMissing validation, hardcoded values, stale comments, inconsistent patterns
LowSuggestions for improvementNaming, minor refactoring, optional type narrowing

Key Principles

  1. Trace through the code - Don't just pattern-match on the diff. Follow data flow across files.
  2. Check both what changed AND what should have changed - Missing changes are as important as incorrect changes.
  3. Verify cross-file consistency - Same concept should behave the same everywhere.
  4. Distinguish between actual bugs and stylistic preferences - Prioritize correctness over style.
  5. Include fix recommendations - Every finding should have a concrete fix suggestion.
  6. Acknowledge good work - Note positive patterns to reinforce them.