Code Inspection: An Agent Skill for Four-Dimensional Structured Code Review of Changes

Preface

Running the linter immediately after code changes only catches formatting and some static rules; issues like security, transaction boundaries, and N+1 queries often only surface during Code Review or in production incidents. When asking the model “help me take a look” verbally, the answer style isn’t fixed, making it hard to use as a comparable checklist for the team.

The Code Patrol introduced below is a Skill from the SkillHub community (Coordinate @user_71026492/code-patrol, Version 1.0.0). It is positioned as an automated code security inspector: it performs a systematic review of git diff or specified files across four dimensions—security, performance, maintainability, and correctness—and outputs a report based on a fixed template. It does not handle formatting (which should be left to format tools), does not write tests (which should use test-writer type Skills), and does not replace explanatory Q&A like “what does this logic mean”.

What is it

One-sentence positioning: After a user completes a set of changes, scan for hidden dangers and output a structured patrol report.

Item Description
Name Code Patrol
Publisher Community Publisher user_71026492
Category dev-programming
Page https://www.skillhub.cn/skills/user_71026492/code-patrol
API Resource https://api.skillhub.cn/user_71026492/code-patrol
Tags requires_api_key=false (No API Key required per documentation)

The rating displayed on the SkillHub page is 100,000, with 705 downloads (statistics are based on the page and may change over time).

Core Features

Review Targets

  1. Change Mode: When no extra parameters are provided, review uncommitted changes according to execution rules (default git diff).
  2. File Mode: When the user specifies a file name, perform a full review of that file, but only output high-priority issues.

Four Review Dimensions

The check items given in the documentation are as follows; the Agent will categorize issues according to these directions:

Dimension Check Items
Security SQL Injection, XSS, Hardcoded Keys, Privilege Escalation, CSRF, Insecure Deserialization
Performance N+1 Queries, Memory Leaks, Deadlocks, No Pagination, Infinite Loops Calling External Services, Unreleased Resources
Maintainability Magic Numbers, Over-nesting (>4 layers), Duplicate Code, God Functions, Long Functions (>50 lines)
Correctness Null Pointer, Swallowed Exceptions, Race Conditions, Transaction Boundaries, Missing Edge Cases

Output Requirements

Each issue must include: Severity Level + Line Number + Issue Description + Fix Code Example. The end of the report should be accompanied by star ratings for each dimension and a comprehensive conclusion (Pass / Conditional Pass / Fail).

Pure formatting style issues will be ignored and left to the linter.

Installation and Enablement

Current public materials only indicate the SkillHub coordinate and page address; no unified installation commands or local directory conventions are provided for environments like Cursor, Codex CLI, or Claude Code. Please refer to the instructions for this Skill on SkillHub for the activation method:

  • Page: https://www.skillhub.cn/skills/user_71026492/code-patrol
  • Coordinate: @user_71026492/code-patrol

If your IDE has integrated a SkillHub-like skill source, it is generally installed by searching for “Code Patrol” or the coordinate mentioned above; if specific steps cannot be verified, do not fabricate shell commands.

Typical Usage

Trigger Statements

Any of the following sentences spoken by the user will trigger it (consistent with official materials):

  • /code-patrol or “review the code” / “code security inspection”
  • /code-patrol [filename]
  • “Help me look at this code” / “Is this PR problematic?”

The English trigger phrases in the user cues (e.g., code review, 审查代码) have the same meaning and can be used to invoke this Skill.

No Parameters: Review Uncommitted Changes

  1. Keep uncommitted changes in the repository.
  2. Tell the Agent: review 一下代码 or /code-patrol.
  3. The Skill executes git diff according to rules and performs a four-dimensional review within the scope of changes.

With Filename: Single File High-Priority Issues

Tell the Agent:

/code-patrol src/handlers/order.go

It reads the file in full, but only retains high-priority items in the report to avoid cluttering with INFO messages.

Report Structure (Illustrative)

The output must conform to the official template and structure is roughly as follows:

🔍 Code Patrol Report
Mode: [Change Mode / File Mode]
Scope: [File List]

🔴 CRITICAL (Must Fix)
- `[File:Line]` Brief Description | Dimension: Security
  - Fix Example: `Specific Code`

🟡 WARNING (Recommended Fix)
- `[File:Line]` Brief Description | Dimension: Performance
  - Fix Example: `Specific Code`

🔵 INFO (Optional Optimization)
- `[File:Line]` Brief Description | Dimension: Maintainability
  - Suggestion: `Explanation`

📊 Star Ratings
- Security: ★☆☆☆☆
- Performance: ★★★☆☆
- Maintainability: ★★★★☆
- Correctness: ★★★☆☆

Overall Rating: ✅ Pass / ⚠️ Conditional Pass / ❌ Fail

Applicable Scenarios and Notes

More Suitable

  • Before committing or submitting a PR, performing a checklist-style review of the diff.
  • Needing review records with “line numbers + fix examples” for easy follow-up in comments.
  • Scenarios where security/performance/maintainability/correctness are scored separately to determine pass/fail.

Not Applicable

  • Only doing code formatting or style unification → use format / linter.
  • Needing to generate test cases → use test-writer type Skills.
  • Just want to understand what the code means → just ask directly, no need to go through the patrol template.

Constraints in Execution Rules (Be Clear When Using)

  1. Label uncertain issues as “Requires Manual Confirmation” and do not guess.
  2. Every issue must be accompanied by an actionable fix example.
  3. In file mode, cross-file call chain issues may still be missed; complex PRs should be used in conjunction with manual Review.

Conclusion

Code Patrol turns the “self-check after code changes” into a fixed four-dimension and fixed report format, suitable for teams already accustomed to doing Reviews in Agents and wishing to output archival records.

Official page and resource addresses:

  • https://www.skillhub.cn/skills/user_71026492/code-patrol
  • https://api.skillhub.cn/user_71026492/code-patrol
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye