AgentSkillsCN

code-review-pr

针对代码质量、编码规范与正确性,对拉取请求中的变更进行审查。

SKILL.md
--- frontmatter
name: code-review-pr
description: Review pull request changes for code quality, conventions, and correctness.
license: Complete terms in LICENSE.txt

When to use this skill

When you need to review changes in a pull request or a set of commits before merging. This skill focuses on the delta (changed files) rather than a full component audit.

How to use this skill

  1. Identify the PR or commit range to review.
  2. Gather the list of changed files.
  3. Follow the detailed instructions to review each category.
  4. Generate findings and add them to the sprint backlog.

Detailed instructions

Step 1: Scope the review

Determine what is being reviewed:

  • For a PR: use git diff main...HEAD or gh pr diff to see changes.
  • For commits: use git diff COMMIT1..COMMIT2.

List all changed files and categorise them by component and facet.

Step 2: Review checklist

For each changed file, apply the following checks. Not all checks apply to all files - use judgement based on what was changed.

Headers & Licensing

CheckDescription
Copyright headerEvery .hpp and .cpp file must have the standard copyright header.
Mode lineFiles should have the Emacs mode line at the top.

Reference: See any existing file in the codebase for the expected format.

Code Style & Naming

CheckDescription
snake_caseAll components except ores.qt must use snake_case for classes, methods, and variables.
CamelCase for Qtores.qt must use CamelCase due to Qt conventions.
Include orderStandard library first, then third-party, then project headers.

Reference: Component Creator skill for component conventions.

Comment Quality

CheckDescription
No stale commentsRemove historical, deprecated, or TODO comments that are no longer relevant.
Useful comments onlyComments should explain "why", not "what".
Doxygen for public APIAll public classes and methods should have @brief documentation.

Platform Isolation

CheckDescription
Platform-specific codeOS-specific code (_WIN32, __linux__, etc.) should only be in ores.platform.
No platform leakageOther components should not have platform-specific macros or includes.

Code Locality

CheckDescription
Utility placementGeneric helper code belongs in ores.utility or ores.platform.
No duplicationCheck if similar code already exists elsewhere in the codebase.
Function extractionRepetitive code should be factored into functions.

C++23 Idioms

CheckDescription
Modern patternsPrefer std::expected over exceptions for error handling.
Ranges and viewsUse C++23 ranges where appropriate.
ConceptsUse concepts for template constraints.
std::formatPrefer std::format over stream concatenation for string formatting.

Domain Types

If adding or modifying domain types, verify completeness per Domain Type Creator:

CheckDescription
JSON I/ODomain type has _json_io.hpp/.cpp for serialization.
Table I/ODomain type has _table_io.hpp/.cpp for table output.
GeneratorDomain type has a generator in the generators facet.
RepositoryIf persisted, domain type has entity, mapper, and repository.

Protocol & Messaging

If adding or modifying protocol messages, verify per Binary Protocol Developer:

CheckDescription
Message type enumNew messages added to message_types.hpp in correct range.
Request/response pairRequests end with _request, responses with _response.
Serializationserialize() and deserialize() methods implemented correctly.
Message traitsmessage_traits specialization added for new request types.
Version bumpProtocol version updated if breaking change.

Temporality Patterns

If adding or modifying persisted domain types, verify temporal audit patterns:

CheckDescription
Domain type fieldsDomain types have recorded_by and recorded_at fields for audit.
Entity fieldsDatabase entities have corresponding temporal columns.
Mapper correctnessMappers correctly convert temporal fields between domain and entity.
Repository writesRepository write operations populate temporal fields.
Time point queriesRepository supports read_at_timepoint() for historical queries.

Unit Tests

Verify test coverage per Unit Test Writer:

CheckDescription
Tests existChanged code has corresponding test coverage.
Test namingTests follow layer_class_tests.cpp naming convention.
No SECTIONsTests use separate TEST_CASE instead of SECTION blocks.
LoggingTests use BOOST_LOG_SEV for debugging output.

Error Handling

CheckDescription
std::expectedUse std::expected for operations that can fail.
No silent failuresErrors should be logged or propagated, never ignored.
Meaningful messagesError messages should be descriptive and actionable.

Security

CheckDescription
No hardcoded secretsNo passwords, keys, or tokens in code.
Input validationExternal input is validated before use.
AuthorizationServer-side authorization checks in message handlers.

Skill Consistency

If changing code patterns that are documented in skills, verify skills remain accurate:

CheckDescription
Skill alignmentChanges don't contradict instructions in relevant skills.
Skill updates neededIf introducing new patterns, consider if skills should be updated.
Cross-referenceCheck skills under doc/skills/ that relate to changed code.

Relevant skills to check based on changes:

Step 3: Generate findings

For each issue found, categorise by severity:

Critical (Must Fix)

Issues that must be resolved before merge:

  • Bugs that cause incorrect behaviour.
  • Security vulnerabilities.
  • Data loss risks.
  • Broken functionality.

Important (Should Fix)

Issues that should be addressed but don't block merge:

  • Architecture problems.
  • Missing features from requirements.
  • Poor error handling.
  • Test coverage gaps.
  • Convention violations.

Minor (Nice to Have)

Suggestions for improvement:

  • Code style preferences.
  • Optimisation opportunities.
  • Documentation improvements.
  • Refactoring suggestions.

Step 4: Document findings

For each issue, provide:

  • <line> - Exact location of the issue.
  • What's wrong - Clear description of the problem.
  • Why it matters - Impact of not fixing.
  • How to fix - Suggested resolution (if not obvious).

Step 5: Add to sprint backlog

Create stories in the sprint backlog per Agile Product Owner skill:

  • Group related issues into stories by component or theme.
  • Use :code: tag for implementation fixes.
  • Use :doc: tag for documentation issues.
  • Include <line> references in task descriptions.

Example story format:

code
**** STARTED [component] Address PR review findings :code:

Review findings from PR #XXX.

***** Tasks
- [ ] Fix: missing copyright header in src/domain/foo.cpp
- [ ] Fix: snake_case violation in bar_service.hpp:42
- [ ] Add: unit tests for baz_repository

***** Notes

PR: https://github.com/OreStudio/OreStudio/pull/XXX

Step 6: Provide verdict

Conclude the review with:

  • Ready to merge - No critical issues, important issues acceptable.
  • Ready with fixes - Critical issues identified that must be fixed first.
  • Not ready - Significant rework required.

Include a 1-2 sentence reasoning for the verdict.