AgentSkillsCN

crv

审查代码变更或整段文件,确保其质量、正确性与最佳实践。当被要求审查代码、核查变更,或对文件进行审计时使用此功能。

SKILL.md
--- frontmatter
name: crv
description: Review code changes or entire files for quality, correctness, and best practices. Use when asked to review code, check changes, or audit files.

Code Review Skill

Review code changes or entire files for quality, correctness, and best practices.

Usage

code
/crv [--staged] [--file <path>] [--full] [--thorough]

Options:

  • --staged - Review only staged changes (default: all changes)
  • --file <path> - Review specific file only
  • --full - Review entire file(s), not just changes (requires --file)
  • --thorough - Perform deep analysis including security and performance

Examples:

bash
/crv                           # Review all unstaged changes
/crv --staged                  # Review staged changes
/crv --file src/Foo.cs         # Review changes in specific file
/crv --file src/Foo.cs --full  # Review entire file (no changes required)
/crv --thorough                # Deep analysis

Instructions

When this skill is invoked:

  1. Determine scope based on arguments:

    • Parse --staged, --file, --full, and --thorough flags
    • Default to reviewing all unstaged changes if no flags provided
    • If --full is provided without --file, inform user that --file is required
  2. Gather changes using git (or read full file):

    • If --full flag is set:
      • Read the entire file specified by --file using the Read tool
      • Skip git diff entirely - review the complete file contents
    • Otherwise use git diff:
      • For all changes: git diff
      • For staged: git diff --cached
      • For specific file: git diff [--cached] -- <file>
      • If no changes found, inform user and exit
  3. Context gathering:

    • Read affected files completely to understand full context
    • Check for related test files
    • Look for relevant documentation or schema files (e.g., Regions_V1.0.xsd)
  4. Perform review covering:

    Always check:

    • Syntax errors and compilation issues
    • Logic errors and edge cases
    • Null reference handling
    • Exception handling appropriateness
    • Code consistency with existing patterns
    • Naming conventions
    • Unnecessary complexity or over-engineering
    • Missing validation at boundaries
    • Backwards compatibility issues (unused code should be deleted, not commented)

    For C# specifically:

    • Proper using statements
    • LINQ query efficiency
    • Async/await usage
    • IDisposable implementation
    • Nullable reference handling
    • XML documentation on public APIs

    If --thorough flag:

    • Security vulnerabilities (SQL injection, XSS, command injection, etc.)
    • Performance implications (N+1 queries, excessive allocations, etc.)
    • Thread safety issues
    • Memory leaks or resource management
    • OWASP Top 10 vulnerabilities
  5. Review test changes:

    • If tests are modified, verify they test the right behavior
    • Check for missing test coverage of new functionality
    • Validate test assertions are meaningful
  6. Generate report with this structure:

    markdown
    ## Code Review Summary
    
    **Scope:** [describe what was reviewed]
    **Overall Assessment:** [APPROVE / NEEDS CHANGES / MAJOR ISSUES]
    
    ### Issues Found
    
    #### Critical (must fix)
    - [file:line] Issue description
    
    #### Important (should fix)
    - [file:line] Issue description
    
    #### Suggestions (consider)
    - [file:line] Suggestion description
    
    ### Positive Observations
    - Things done well
    
    ### Recommendations
    - General advice for improvement
    
  7. Be specific:

    • Reference exact file paths and line numbers (file:line format)
    • Quote problematic code snippets
    • Provide concrete fix suggestions
    • Explain WHY something is an issue
  8. Be balanced:

    • Point out good practices too
    • Don't nitpick minor style issues unless they impact readability
    • Focus on correctness, maintainability, and avoiding bugs
    • Don't suggest adding features beyond the change scope

Important Notes

  • This skill is for REVIEW only - don't make changes unless explicitly asked
  • Be objective and constructive in feedback
  • Prioritize correctness and security over style preferences
  • If no issues found, say so clearly
  • Always validate against project patterns (check CLAUDE.md if it exists)