codeprobe

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Review Orchestrator

代码审查协调器

READ-ONLY CONSTRAINT

只读约束

THIS SKILL IS STRICTLY READ-ONLY. NEVER modify, write, edit, or delete any user files. NEVER run commands that have side effects (no
npm install
, no
pip install
, no file writes, no git commits, no database mutations). If a fix is needed, generate a copy-pasteable fix prompt that the user can run separately. Violations of this constraint are NEVER acceptable, regardless of user request.

本技能严格为只读模式。绝不能修改、写入、编辑或删除任何用户文件。绝不能执行有副作用的命令(如
npm install
pip install
、文件写入、git提交、数据库变更)。若需要修复,生成可复制粘贴的修复提示供用户单独执行。无论用户如何请求,违反此约束的行为都是绝对不允许的。

1. Command Routing

1. 命令路由

Parse the user's input to extract a subcommand and target path. The input format is:
/codeprobe [subcommand] [path]
解析用户输入以提取子命令和目标路径。输入格式如下:
/codeprobe [subcommand] [path]

Routing Table

路由表

CommandBehaviorSub-skills Invoked
/codeprobe audit <path>
Full audit — visual health dashboard (category scores, codebase stats, hot spots) followed by detailed P0-P3 findings with fix promptsAll available sub-skills +
file_stats.py
/codeprobe solid <path>
SOLID principles analysis only
codeprobe-solid
/codeprobe security <path>
Security audit only
codeprobe-security
/codeprobe smells <path>
Code smells detection only
codeprobe-code-smells
/codeprobe architecture <path>
Architecture analysis only
codeprobe-architecture
/codeprobe patterns <path>
Design patterns analysis only
codeprobe-patterns
/codeprobe performance <path>
Performance audit only
codeprobe-performance
/codeprobe errors <path>
Error handling audit only
codeprobe-error-handling
/codeprobe tests <path>
Test quality audit only
codeprobe-testing
/codeprobe framework <path>
Framework best practices only
codeprobe-framework
/codeprobe quick <path>
Top 5 issues — run all sub-skills in scan mode, then generate full detail for top 5All available
/codeprobe diff [branch]
PR-style review on changed files vs branch (default:
main
)
All relevant (Phase 3)
/codeprobe report
Generate report from last audit
scripts/generate_report.py
(Phase 3)
命令行为调用的子技能
/codeprobe audit <path>
全面审计——先展示可视化健康仪表盘(分类评分、代码库统计、热点文件),随后提供带有修复提示的详细P0-P3级问题结果所有可用子技能 +
file_stats.py
/codeprobe solid <path>
仅进行SOLID原则分析
codeprobe-solid
/codeprobe security <path>
仅进行安全审计
codeprobe-security
/codeprobe smells <path>
仅检测代码异味
codeprobe-code-smells
/codeprobe architecture <path>
仅进行架构分析
codeprobe-architecture
/codeprobe patterns <path>
仅进行设计模式分析
codeprobe-patterns
/codeprobe performance <path>
仅进行性能审计
codeprobe-performance
/codeprobe errors <path>
仅进行错误处理审计
codeprobe-error-handling
/codeprobe tests <path>
仅进行测试质量审计
codeprobe-testing
/codeprobe framework <path>
仅检查框架最佳实践
codeprobe-framework
/codeprobe quick <path>
显示前5个问题——以扫描模式运行所有子技能,然后生成前5个问题的完整详情所有可用子技能
/codeprobe diff [branch]
针对变更文件与指定分支进行PR风格审查(默认分支:
main
所有相关子技能(第三阶段)
/codeprobe report
根据上次审计生成报告
scripts/generate_report.py
(第三阶段)

Default Behaviors

默认行为

  • No subcommand given: Ask the user what they want. Present the available commands.
  • No path given: Use the current working directory.
  • Phase 3 stubs: If the user invokes
    diff
    or
    report
    , respond: "This feature is coming in Phase 3. Available now: audit, solid, security, smells, architecture, patterns, performance, errors, tests, framework, quick."

  • 未指定子命令:询问用户需求,并展示可用命令。
  • 未指定路径:使用当前工作目录。
  • 第三阶段占位功能:若用户调用
    diff
    report
    ,回复:"此功能将在第三阶段推出。当前可用功能:audit、solid、security、smells、architecture、patterns、performance、errors、tests、framework、quick。"

2. Stack Auto-Detection

2. 技术栈自动检测

Before routing to any sub-skill, detect the technology stack at the target path. This informs which reference guides to load and pass to sub-skills.
在路由到任何子技能之前,检测目标路径下的技术栈。这将决定加载哪些参考指南并传递给子技能。

Detection Procedure

检测流程

  1. Use Glob to scan file extensions at the target path (recursive, reasonable depth).
  2. Apply the following detection rules — multiple stacks can match simultaneously:
SignalStack DetectedReference to Load
.php
files
PHP / Laravel
references/php-laravel.md
.js
,
.ts
,
.jsx
,
.tsx
files
JavaScript / TypeScript
references/javascript-typescript.md
.py
files
Python
references/python.md
.jsx
,
.tsx
files +
next.config.*
present
React / Next.js
references/react-nextjs.md
.sql
files or
migrations/
directory
SQL / Database
references/sql-database.md
routes/
directory or API route patterns
API Design
references/api-design.md
  1. For each detected stack, attempt to load the corresponding reference file using Read. If the file does not exist yet (Phase 2+), skip silently.
  2. Collect all loaded references into a context bundle to pass to sub-skills.
  1. 使用Glob工具递归扫描目标路径下的文件扩展名(扫描深度合理)。
  2. 应用以下检测规则——可同时匹配多个技术栈:
信号检测到的技术栈加载的参考文档
.php
文件
PHP / Laravel
references/php-laravel.md
.js
.ts
.jsx
.tsx
文件
JavaScript / TypeScript
references/javascript-typescript.md
.py
文件
Python
references/python.md
.jsx
.tsx
文件 + 存在
next.config.*
React / Next.js
references/react-nextjs.md
.sql
文件或
migrations/
目录
SQL / 数据库
references/sql-database.md
routes/
目录或API路由模式
API设计
references/api-design.md
  1. 对于每个检测到的技术栈,尝试使用Read工具加载对应的参考文件。若文件尚未存在(第二阶段及以后),则静默跳过。
  2. 将所有加载的参考文档收集到上下文包中,传递给子技能。

Reference Loading

参考文档加载

References are loaded from the
references/
directory within this skill's own directory. Resolve the path relative to this SKILL.md file's location, NOT the user's project. Use Read with:
references/{reference-file}.md
(This resolves to the
references/
folder next to this SKILL.md file.)
If a reference file does not exist, continue without it. Never fail the review because a reference is missing.

参考文档从本技能目录下的
references/
文件夹加载。路径相对于本SKILL.md文件的位置解析,而非用户项目路径。使用Read工具加载:
references/{reference-file}.md
(此路径指向本SKILL.md文件旁的
references/
文件夹。)
若参考文档不存在,继续执行流程即可,绝不能因缺少参考文档而终止审查。

3. Config Loading

3. 配置加载

Check for a
.codeprobe-config.json
file in the project root (the target path or its ancestor directories).
检查项目根目录(目标路径或其上级目录)中是否存在
.codeprobe-config.json
文件。

Config Schema

配置 Schema

json
{
  "severity_overrides": {
    "long_method_loc": 50,
    "large_class_loc": 500,
    "deep_nesting_max": 4,
    "max_constructor_deps": 6
  },
  "skip_categories": ["codeprobe-testing"],
  "skip_rules": ["SPEC-GEN-001"],
  "framework": "laravel",
  "extra_references": [],
  "report_format": "markdown"
}
json
{
  "severity_overrides": {
    "long_method_loc": 50,
    "large_class_loc": 500,
    "deep_nesting_max": 4,
    "max_constructor_deps": 6
  },
  "skip_categories": ["codeprobe-testing"],
  "skip_rules": ["SPEC-GEN-001"],
  "framework": "laravel",
  "extra_references": [],
  "report_format": "markdown"
}

Config Behavior

配置行为

  • If absent: All defaults apply. No error.
  • severity_overrides
    : Pass to sub-skills so they adjust thresholds accordingly.
  • skip_categories
    : Do not invoke the listed sub-skills, even in
    audit
    or
    quick
    mode.
  • skip_rules
    : Pass to sub-skills so they suppress findings with matching IDs.
  • framework
    : If set, skip auto-detection for that framework and force-load the corresponding reference. Other auto-detection still proceeds.
  • extra_references
    : Additional reference file paths to load and pass to sub-skills.
  • report_format
    : Output format preference (default:
    markdown
    ).

  • 配置不存在:应用所有默认值,不报错。
  • severity_overrides
    :传递给子技能,使其相应调整阈值。
  • skip_categories
    :不调用列出的子技能,即使在
    audit
    quick
    模式下也不执行。
  • skip_rules
    :传递给子技能,使其屏蔽匹配ID的问题结果。
  • framework
    :若已设置,跳过该框架的自动检测,强制加载对应的参考文档。其他自动检测仍正常执行。
  • extra_references
    :额外的参考文件路径,将加载并传递给子技能。
  • report_format
    :输出格式偏好(默认:
    markdown
    )。

4. Sub-Skill Execution

4. 子技能执行

Pre-Loading Phase (runs once before any sub-skill)

预加载阶段(在调用任何子技能前执行一次)

Before invoking any sub-skill, the orchestrator MUST pre-load all shared context:
  1. Read the shared preamble from
    shared-preamble.md
    (in this skill's directory). This contains the output contract, execution modes, and constraints shared by all sub-skills.
  2. Read all source files at the target path:
    • Use Glob to find all source files (
      .ts
      ,
      .tsx
      ,
      .js
      ,
      .jsx
      ,
      .py
      ,
      .php
      ,
      .vue
      ,
      .sql
      ,
      .css
      ,
      .scss
      and config files like
      next.config.*
      ,
      package.json
      ,
      composer.json
      ,
      requirements.txt
      ,
      .env.example
      ).
    • Read each file using Read.
    • Size cap: If the codebase has more than 50 source files or total LOC exceeds 10,000 lines, do NOT pre-load all files. Instead, pass only the file listing (paths + line counts) and let sub-agents read files they need. Note this in the agent prompt: "Large codebase — file listing provided, use Read for files you need to inspect."
    • Store all file contents as a map:
      {filepath: content}
      .
  3. Read all applicable reference files (already loaded during stack detection in Section 2). Store the content.
在调用任何子技能之前,协调器必须预加载所有共享上下文:
  1. 读取共享前置内容:从本技能目录下的
    shared-preamble.md
    读取。其中包含所有子技能共享的输出约定、执行模式和约束条件。
  2. 读取目标路径下的所有源文件
    • 使用Glob工具查找所有源文件(
      .ts
      .tsx
      .js
      .jsx
      .py
      .php
      .vue
      .sql
      .css
      .scss
      以及配置文件如
      next.config.*
      package.json
      composer.json
      requirements.txt
      .env.example
      )。
    • 使用Read工具读取每个文件。
    • 大小限制:若代码库包含超过50个源文件或总行数超过10000行,则不预加载所有文件。仅传递文件列表(路径+行数),让子代理自行读取需要检查的文件。并在代理提示中注明:"大型代码库——已提供文件列表,请使用Read工具读取需要检查的文件。"
    • 将所有文件内容存储为映射表:
      {filepath: content}
  3. 读取所有适用的参考文档(已在第2节的技术栈检测阶段完成加载)。存储文档内容。

Invocation Protocol

调用协议

For each sub-skill to run, spawn an Agent with a prompt that includes:
  1. The shared preamble (from
    shared-preamble.md
    ) — output contract, modes, constraints.
  2. The sub-skill name to invoke (e.g.,
    codeprobe-security
    ).
  3. The mode — one of
    full
    or
    scan
    .
  4. Pre-loaded source files — the full content of every source file, formatted as:
    === FILE: {filepath} ===
    {content}
    === END FILE ===
  5. Pre-loaded references — the content of all applicable reference files.
  6. Config overrides — severity overrides and skip rules from
    .codeprobe-config.json
    .
  7. Target path — so the sub-skill knows the project root for any targeted lookups.
The sub-skill's own SKILL.md contains only its domain-specific detection logic. All shared context (output format, modes, source code, references) comes from the orchestrator's prompt.
Collect findings returned by each sub-skill in the standard output contract format (Section 5).
对于每个要运行的子技能,生成一个Agent,其提示内容包含:
  1. 共享前置内容(来自
    shared-preamble.md
    )——输出约定、模式、约束条件。
  2. 要调用的子技能名称(如
    codeprobe-security
    )。
  3. 模式——
    full
    scan
    之一。
  4. 预加载的源文件——每个源文件的完整内容,格式如下:
    === FILE: {filepath} ===
    {content}
    === END FILE ===
  5. 预加载的参考文档——所有适用参考文档的内容。
  6. 配置覆盖项——来自
    .codeprobe-config.json
    的严重程度覆盖规则和跳过规则。
  7. 目标路径——让子技能知晓项目根目录,以便进行针对性查找。
子技能自身的SKILL.md仅包含其领域特定的检测逻辑。所有共享上下文(输出格式、模式、源代码、参考文档)均来自协调器的提示。
收集结果:以第5节的标准输出约定格式收集每个子技能返回的问题结果。

Execution Modes

执行模式

ModeUsed ByBehavior
full
/codeprobe audit
,
/codeprobe solid
, etc.
Run complete analysis, return all findings
scan
/codeprobe quick
Count violations, identify top issues, return only counts + top 5 candidates
模式使用场景行为
full
/codeprobe audit
/codeprobe solid
执行完整分析,返回所有问题结果
scan
/codeprobe quick
统计违规数量,识别主要问题,仅返回数量+前5个候选问题

Execution Order

执行顺序

  • /codeprobe audit
    : Run sub-skills sequentially in this order:
    codeprobe-security
    ,
    codeprobe-error-handling
    ,
    codeprobe-solid
    ,
    codeprobe-architecture
    ,
    codeprobe-patterns
    ,
    codeprobe-performance
    ,
    codeprobe-code-smells
    ,
    codeprobe-testing
    ,
    codeprobe-framework
    — all in
    full
    mode. Collect all findings. Apply deduplication (Section 7A). Derive category scores from severity counts. Compute hot spots by aggregating findings per file and ranking by distinct-categories-flagged. Also run
    scripts/file_stats.py
    for codebase stats (skip gracefully if Python 3 unavailable).
  • /codeprobe quick
    : Run all 9 sub-skills in
    scan
    mode. Collect candidate issues from all. Rank by severity (critical > major > minor > suggestion), then select top 5. Re-run relevant sub-skills in
    full
    mode for just those 5 findings to get complete detail.
  • /codeprobe audit
    :按以下顺序依次运行子技能:
    codeprobe-security
    codeprobe-error-handling
    codeprobe-solid
    codeprobe-architecture
    codeprobe-patterns
    codeprobe-performance
    codeprobe-code-smells
    codeprobe-testing
    codeprobe-framework
    ——全部使用
    full
    模式。收集所有问题结果。执行去重操作(第7A节)。根据严重程度统计结果得出分类评分。通过按文件聚合问题结果并按标记的不同分类数量排序,计算热点文件。同时运行
    scripts/file_stats.py
    获取代码库统计信息(若Python 3不可用则优雅跳过)。
  • /codeprobe quick
    :以
    scan
    模式运行所有9个子技能。收集所有候选问题。按严重程度排序(critical > major > minor > suggestion),然后选择前5个问题。针对这5个问题,重新运行相关子技能的
    full
    模式以获取完整详情。

Available Sub-Skills

可用子技能

  1. codeprobe-security
    — Security vulnerability detection
  2. codeprobe-error-handling
    — Error handling & resilience
  3. codeprobe-solid
    — SOLID principles analysis
  4. codeprobe-architecture
    — Architecture analysis
  5. codeprobe-patterns
    — Design patterns advisor
  6. codeprobe-performance
    — Performance & scalability
  7. codeprobe-code-smells
    — Code smell detection
  8. codeprobe-testing
    — Test quality & coverage
  9. codeprobe-framework
    — Framework-specific best practices

  1. codeprobe-security
    — 安全漏洞检测
  2. codeprobe-error-handling
    — 错误处理与韧性检查
  3. codeprobe-solid
    — SOLID原则分析
  4. codeprobe-architecture
    — 架构分析
  5. codeprobe-patterns
    — 设计模式建议
  6. codeprobe-performance
    — 性能与可扩展性检查
  7. codeprobe-code-smells
    — 代码异味检测
  8. codeprobe-testing
    — 测试质量与覆盖率检查
  9. codeprobe-framework
    — 框架特定最佳实践检查

5. Output Contract

5. 输出约定

Every finding from every sub-skill MUST include these fields:
FieldRequiredDescription
id
YesUnique identifier in format
{PREFIX}-{NNN}
(e.g.,
SRP-001
,
SEC-003
)
severity
YesOne of:
critical
,
major
,
minor
,
suggestion
location
YesFile path + line range (e.g.,
src/UserService.php:45-67
)
problem
YesOne sentence describing the issue
evidence
YesConcrete proof from the code — quote the relevant lines
suggestion
YesWhat to do to fix it
fix_prompt
YesA copy-pasteable prompt the user can give to Claude Code to apply the fix
refactored_sketch
NoOptional code snippet showing the improved version
每个子技能返回的每个问题结果必须包含以下字段:
字段必填描述
id
唯一标识符,格式为
{PREFIX}-{NNN}
(如
SRP-001
SEC-003
severity
以下值之一:
critical
major
minor
suggestion
location
文件路径+行范围(如
src/UserService.php:45-67
problem
描述问题的一句话
evidence
来自代码的具体证据——引用相关代码行
suggestion
修复建议
fix_prompt
用户可直接复制粘贴给Claude Code以应用修复的提示语
refactored_sketch
可选的代码片段,展示改进后的版本

Finding Format Example

问题结果格式示例

undefined
undefined

SRP-001 | Major |
src/UserService.php:45-67

SRP-001 | Major |
src/UserService.php:45-67

Problem: UserService violates Single Responsibility — handles authentication, email sending, and database queries in one class.
Evidence:
Lines 45-50:
public function authenticate($credentials) { ... }
Lines 52-60:
public function sendWelcomeEmail($user) { ... }
Lines 62-67:
public function findByUsername($name) { ... }
Suggestion: Extract email logic into a dedicated
UserMailer
service and database queries into a
UserRepository
.
Fix prompt:
Refactor
src/UserService.php
to follow Single Responsibility Principle: extract
sendWelcomeEmail()
into a new
UserMailer
class and
findByUsername()
into a
UserRepository
class. Keep
authenticate()
in
UserService
and inject the new dependencies.

---
问题: UserService违反单一职责原则——在一个类中处理身份验证、邮件发送和数据库查询。
证据:
第45-50行:
public function authenticate($credentials) { ... }
第52-60行:
public function sendWelcomeEmail($user) { ... }
第62-67行:
public function findByUsername($name) { ... }
建议: 将邮件逻辑提取到专用的
UserMailer
服务中,将数据库查询提取到
UserRepository
中。
修复提示:
重构
src/UserService.php
以遵循单一职责原则:将
sendWelcomeEmail()
提取到新的
UserMailer
类中,将
findByUsername()
提取到
UserRepository
类中。将
authenticate()
保留在
UserService
中,并注入新的依赖项。

---

6. Severity Levels

6. 严重程度等级

LevelEmojiMeaningExamples
Critical🔴Confirmed bugs, exploitable security vulnerabilities, or data loss/corruption risks that would cause harm in productionSQL injection with user input, missing auth on data-mutating endpoint, race condition causing data corruption, unhandled crash on a core path, missing DB transaction on multi-step writes
Major🟠Significant maintainability, reliability, or scalability problem that increases risk but is not an immediate production defectMissing tests for critical business logic, large classes, code duplication, missing error handling on external calls, N+1 queries, missing input validation
Minor🟡Code smell, low risk, worth addressing for long-term healthMagic numbers, deep nesting, poor naming, missing edge case tests, verbose error details
Suggestion🔵Improvement idea, nice to have, no real risk if ignoredPattern opportunities, style improvements, speculative generality
等级表情含义示例
Critical🔴已确认的bug、可利用的安全漏洞或数据丢失/损坏风险,会在生产环境中造成危害用户输入导致的SQL注入、数据变更端点缺少认证、导致数据损坏的竞态条件、核心路径上未处理的崩溃、多步骤写入缺少数据库事务
Major🟠显著的可维护性、可靠性或可扩展性问题,会增加风险但并非即时生产缺陷关键业务逻辑缺少测试、大型类、代码重复、外部调用缺少错误处理、N+1查询、缺少输入验证
Minor🟡代码异味,低风险,为了长期健康值得修复魔法数字、深层嵌套、命名不佳、缺少边缘情况测试、冗长的错误详情
Suggestion🔵改进建议,可有可无,忽略不会带来实际风险设计模式应用机会、风格改进、过度设计

Severity Guardrails

严重程度规则

The following are NEVER Critical — classify as Major at most:
  • Missing tests (even for critical business logic)
  • Code duplication or large classes/files
  • Code smells of any kind
  • Framework convention violations
  • Missing documentation, comments, or type annotations
Critical is reserved exclusively for:
  • Confirmed bugs (code that produces wrong results or crashes)
  • Exploitable security vulnerabilities (injection, auth bypass, IDOR with proof)
  • Data loss or corruption risks (missing transactions, race conditions on writes)
  • Sensitive data exposure (secrets in code, credentials in logs)
Sub-skills: do NOT escalate findings beyond the severity specified in your detection table. If your table says "Major," report it as Major even if the specific instance seems severe. The orchestrator's scoring formula accounts for finding counts at each level.

以下情况绝不能归为Critical——最多归为Major:
  • 缺少测试(即使是关键业务逻辑)
  • 代码重复或大型类/文件
  • 任何类型的代码异味
  • 违反框架约定
  • 缺少文档、注释或类型注解
Critical仅适用于:
  • 已确认的bug(产生错误结果或崩溃的代码)
  • 可利用的安全漏洞(注入、认证绕过、有证据的IDOR)
  • 数据丢失或损坏风险(缺少事务、写入操作的竞态条件)
  • 敏感数据泄露(代码中的密钥、日志中的凭证)
子技能注意: 不要将问题结果的严重程度提升到检测表中指定的等级之上。若检测表中标记为“Major”,即使具体实例看似严重,也需报告为Major。协调器的评分公式会考虑各等级的问题数量。

7. Scoring

7. 评分

After collecting all findings, compute scores per category and an overall score.
收集所有问题结果后,计算每个分类的评分和整体评分。

Category Score Formula

分类评分公式

Each penalty component is capped to prevent a single severity level from dominating the score:
crit_penalty  = min(50, critical_count * 15)
major_penalty = min(30, major_count * 6)
minor_penalty = min(10, minor_count * 2)

category_score = max(0, 100 - crit_penalty - major_penalty - minor_penalty)
Suggestions do not affect the score.
Rationale: Diminishing returns prevent a single severity from flooring the score. A category with 4 criticals scores 40 (not 0), reflecting problems exist but the code is not completely broken. The maximum total penalty from all three levels combined is 90, so a score of 0 requires extreme findings across all severities.
每个惩罚组件都有上限,防止单一严重程度等级主导评分:
crit_penalty  = min(50, critical_count * 15)
major_penalty = min(30, major_count * 6)
minor_penalty = min(10, minor_count * 2)

category_score = max(0, 100 - crit_penalty - major_penalty - minor_penalty)
Suggestion级别的问题不影响评分。
原理: 边际递减效应防止单一严重程度等级将评分降至最低。一个有4个Critical问题的分类评分为40(而非0),反映代码存在问题但并未完全失效。三个等级的最大总惩罚为90,因此评分为0需要所有严重程度等级都出现极端问题。

Category Weights

分类权重

CategoryWeight
Security20%
SOLID15%
Architecture15%
Error Handling12%
Performance12%
Test Quality10%
Code Smells8%
Design Patterns4%
Framework4%
All 9 categories are active. Weights sum to 100%.
分类权重
Security20%
SOLID15%
Architecture15%
Error Handling12%
Performance12%
Test Quality10%
Code Smells8%
Design Patterns4%
Framework4%
所有9个分类均生效,权重总和为100%。

Overall Score

整体评分

overall = sum(category_score_i * weight_i for each active category)
If
skip_categories
in
.codeprobe-config.json
excludes some categories, normalize by dividing by the sum of active weights:
overall = sum(category_score_i * weight_i for each active category) / sum(weight_i for each active category)
Clamp the result to the range [0, 100].
overall = sum(category_score_i * weight_i for each active category)
.codeprobe-config.json
中的
skip_categories
排除了部分分类,则通过除以生效分类的权重总和进行归一化:
overall = sum(category_score_i * weight_i for each active category) / sum(weight_i for each active category)
将结果限制在[0, 100]范围内。

Score Interpretation

评分解读

RangeStatus
80-100Healthy
60-79Needs Attention
0-59Critical

范围状态
80-100健康
60-79需要关注
0-59严重

7A. Cross-Category Deduplication

7A. 跨分类去重

Before computing scores, deduplicate findings that flag the same issue from multiple categories.
计算评分前,对多个分类标记的同一问题进行去重。

Deduplication Procedure

去重流程

  1. Group findings by location. Normalize each finding's
    location
    to
    {file}:{start_line}
    . Two findings overlap if they share the same file AND their line ranges overlap (i.e., start_line_A <= end_line_B AND start_line_B <= end_line_A).
  2. For each group of overlapping findings from different categories: a. Select a primary finding. Use this priority order:
    • Security findings (SEC) take priority for anything involving auth, injection, or data exposure
    • Error Handling findings (ERR) take priority for exception/validation issues
    • Performance findings (PERF) take priority for query/caching issues
    • SOLID findings (SRP/OCP/LSP/ISP/DIP) take priority for structural violations
    • Architecture findings (ARCH) take priority for layer/boundary violations
    • If still ambiguous, the category with the higher weight (Section 7) wins b. Mark duplicates. For each non-primary finding in the group, append to its
      problem
      field:
      [Duplicate of {primary_id} — counted there]
      and change its severity to
      suggestion
      so it does not affect the score of its own category. c. Cross-reference the primary. Append to the primary finding's
      suggestion
      field:
      Also flagged by: {list of duplicate category:id pairs}
  3. Recount severity totals per category after deduplication, then proceed to scoring.
  1. 按位置分组:将每个问题结果的
    location
    标准化为
    {file}:{start_line}
    。若两个问题结果共享同一文件且行范围重叠(即start_line_A <= end_line_B 且 start_line_B <= end_line_A),则视为重叠。
  2. 针对每个来自不同分类的重叠问题组: a. 选择主问题结果:按以下优先级顺序选择:
    • 涉及认证、注入或数据泄露的Security问题(SEC)优先
    • 涉及异常/验证的Error Handling问题(ERR)优先
    • 涉及查询/缓存的Performance问题(PERF)优先
    • 涉及结构违规的SOLID问题(SRP/OCP/LSP/ISP/DIP)优先
    • 涉及分层/边界违规的Architecture问题(ARCH)优先
    • 若仍存在歧义,权重更高的分类(第7节)胜出 b. 标记重复项:对于组中的每个非主问题结果,在其
      problem
      字段后追加:
      [重复项,对应主问题ID:{primary_id} — 已在该分类统计]
      ,并将其严重程度改为
      suggestion
      ,使其不影响自身分类的评分。 c. 交叉引用主问题结果:在主问题结果的
      suggestion
      字段后追加:
      同时被以下分类标记:{重复分类:ID列表}
  3. 去重后重新统计各分类的严重程度总数,然后进行评分计算。

Examples

示例

  • "Refresh bypasses quota" found as SEC-007, ERR-011, FW-001 at same location: keep SEC-007, mark ERR-011 and FW-001 as duplicates (severity → suggestion).
  • "God component" found as SRP-001, SMELL-001, ARCH-005 at same file: keep SRP-001 (SOLID priority for structural), mark others as duplicates.
  • Same SRP violation found as SRP-001 and SMELL-001: keep SRP-001, mark SMELL-001 as duplicate.

  • "刷新绕过配额"被SEC-007、ERR-011、FW-001在同一位置标记:保留SEC-007,将ERR-011和FW-001标记为重复项(严重程度改为suggestion)。
  • "上帝组件"在同一文件被SRP-001、SMELL-001、ARCH-005标记:保留SRP-001(结构问题SOLID优先),将其他标记为重复项。
  • 同一SRP违规被SRP-001和SMELL-001标记:保留SRP-001,将SMELL-001标记为重复项。

8. Report Rendering

8. 报告渲染

Render the final output based on the command used.
根据使用的命令渲染最终输出。

/codeprobe audit
— Full Audit Report

/codeprobe audit
— 全面审计报告

Use the template at
templates/full-audit-report.md
(loaded via Read). The template opens with a visual health dashboard (category scores, codebase stats, hot spots) and then uses a tiered output format for findings to control token usage. Render order:
  1. Dashboard header:
    Code Health Report — {project}
    title line and
    Overall Health: {score}/100 {status_emoji}
    where status is derived from the thresholds in the "Status thresholds" block below.
  2. Category score bars: a 10-character block-character bar proportional to the score for each of the 9 categories (Architecture, Security, Framework, Performance, SOLID, Design Patterns, Code Smells, Test Quality, Error Handling), followed by
    {score}/100 {status}
    .
  3. Codebase Stats: output of
    scripts/file_stats.py
    (total files, LOC, backend/frontend split, largest file, test file ratio, comment ratio). If Python 3 is unavailable, omit this block and note: "Install Python 3 for codebase statistics."
  4. Hot Spots: top 3 files by distinct-categories-flagged (computed from the same findings that feed the scores).
  5. Horizontal rule.
  6. Executive Summary: 2-3 sentences covering the most important findings.
  7. Critical findings — Full detail: Each critical finding rendered with evidence, suggestion, and fix prompt. These are the most important and justify the token cost.
  8. Major findings — Summary table: One row per major finding with ID, file, problem, and fix prompt. No evidence block (saves ~200 tokens per finding).
  9. Minor findings — Counts only: Aggregated count per category. No individual findings listed.
  10. Suggestions — Counts only: Aggregated count per category. No individual findings listed.
  11. Prioritized Fix Order: Ordered list of all critical and major fix prompts, ranked by impact.
If the template does not exist, render inline following the same structure.
Status thresholds (applied to overall health and each category score):
  • 80-100 = "Healthy"
  • 60-79 = "Needs Attention"
  • 0-59 = "Critical"
Token budget guidance: For a codebase with ~100 findings, the tiered findings format (steps 7-10) targets ~8,000-12,000 tokens (vs ~40,000 with full detail for all findings). The dashboard adds a small fixed cost (~400 tokens). The user can drill into specific categories with
/codeprobe security .
etc. for full detail on any category.
使用
templates/full-audit-report.md
中的模板(通过Read工具加载)。模板开头为可视化健康仪表盘(分类评分、代码库统计、热点文件),随后采用分层输出格式展示问题结果以控制token使用量。渲染顺序:
  1. 仪表板标题
    代码健康报告 — {project}
    标题行,以及
    整体健康评分:{score}/100 {status_emoji}
    ,其中状态由下方“状态阈值”块中的阈值决定。
  2. 分类评分条:为9个分类(Architecture、Security、Framework、Performance、SOLID、Design Patterns、Code Smells、Test Quality、Error Handling)分别生成一个10字符的方块字符条,长度与评分成正比,随后显示
    {score}/100 {status}
  3. 代码库统计
    scripts/file_stats.py
    的输出结果(总文件数、总行数、前后端拆分、最大文件、测试文件占比、注释占比)。若Python 3不可用,则省略此块并注明:"安装Python 3以获取代码库统计信息。"
  4. 热点文件:按标记的不同分类数量排序的前3个文件。
  5. 水平线分隔。
  6. 执行摘要:2-3句话概述最重要的问题结果。
  7. Critical级问题结果——完整详情:每个Critical级问题结果均展示证据、建议和修复提示。这些是最重要的内容,值得消耗token。
  8. Major级问题结果——摘要表格:每个Major级问题结果占一行,包含ID、文件、问题描述和修复提示。不展示证据块(每个问题结果可节省约200个token)。
  9. Minor级问题结果——仅统计数量:按分类汇总数量。不列出单个问题结果。
  10. Suggestion级问题——仅统计数量:按分类汇总数量。不列出单个问题结果。
  11. 优先修复顺序:所有Critical和Major级修复提示的有序列表,按影响排序。
若模板不存在,则按相同结构直接渲染。
状态阈值(适用于整体健康评分和各分类评分):
  • 80-100 = "健康"
  • 60-79 = "需要关注"
  • 0-59 = "严重"
Token预算指南:对于包含约100个问题结果的代码库,分层结果格式(步骤7-10)目标消耗约8000-12000个token(若所有问题结果均展示完整详情则约消耗40000个token)。仪表板增加少量固定成本(约400个token)。用户可通过
/codeprobe security .
等命令深入查看特定分类的完整详情。

/codeprobe quick
— Quick Review Summary

/codeprobe quick
— 快速审查摘要

Use the template at
templates/quick-review-summary.md
(loaded via Read). If the template does not exist yet, render inline:
  1. Header: Project name, "Quick Review — Top 5 Issues".
  2. Top 5 Findings: Full detail for the 5 most impactful issues, each with fix prompt.
  3. Summary Counts: Total issues found by severity across all categories.
  4. Next Step: Suggest running
    /codeprobe audit
    for the complete picture.
使用
templates/quick-review-summary.md
中的模板(通过Read工具加载)。若模板尚未存在,则直接渲染:
  1. 标题:项目名称,"快速审查——前5个问题"
  2. 前5个问题结果:5个影响最大的问题的完整详情,每个均包含修复提示。
  3. 摘要统计:所有分类按严重程度统计的总问题数量。
  4. 下一步建议:建议运行
    /codeprobe audit
    以获取完整分析结果。

9. Claude.ai Degraded Mode

9. Claude.ai降级模式

Detect whether filesystem access is available. If the user has pasted or uploaded code rather than providing a file path, or if Read/Glob/Grep tools are unavailable:
  1. Switch to degraded mode: Analyze only the in-context code provided.
  2. Execute sub-skills sequentially on the pasted code (no parallel agents).
  3. Skip
    file_stats.py
    and all script-dependent steps.
  4. Skip
    /codeprobe diff
    ,
    /codeprobe report
    , and the Codebase Stats row of the audit dashboard (still render scores, hot spots, and findings).
  5. Inform the user: "Running in Claude.ai mode — some features like codebase statistics, diff review, and multi-file analysis are unavailable. Analyzing the provided code directly."
  6. Still produce findings in the standard output contract format.
  7. Still compute scores based on findings from available sub-skills.

检测是否可访问文件系统。若用户粘贴或上传代码而非提供文件路径,或Read/Glob/Grep工具不可用:
  1. 切换到降级模式:仅分析上下文提供的代码。
  2. 依次执行子技能:对粘贴的代码依次执行子技能(不使用并行代理)。
  3. 跳过
    file_stats.py
    和所有依赖脚本的步骤。
  4. 跳过
    /codeprobe diff
    /codeprobe report
    以及审计仪表板的代码库统计行(仍渲染评分、热点文件和问题结果)。
  5. 告知用户:"当前运行在Claude.ai模式下——部分功能如代码库统计、差异审查和多文件分析不可用。将直接分析提供的代码。"
  6. 仍按标准输出约定格式生成问题结果。
  7. 仍根据可用子技能的问题结果计算评分。

10. Phase 3 Stubs

10. 第三阶段占位功能

When the user invokes a command that routes to an unbuilt feature, respond with:
Not yet available. This feature is coming in Phase 3. Currently available commands:
  • /codeprobe audit <path>
    — Full code audit
  • /codeprobe solid <path>
    — SOLID principles check
  • /codeprobe security <path>
    — Security audit
  • /codeprobe smells <path>
    — Code smells detection
  • /codeprobe architecture <path>
    — Architecture analysis
  • /codeprobe patterns <path>
    — Design patterns analysis
  • /codeprobe performance <path>
    — Performance audit
  • /codeprobe errors <path>
    — Error handling audit
  • /codeprobe tests <path>
    — Test quality audit
  • /codeprobe framework <path>
    — Framework best practices
  • /codeprobe quick <path>
    — Top 5 issues
This applies to:
diff
,
report
.

当用户调用指向未实现功能的命令时,回复:
尚未可用。 此功能将在第三阶段推出。当前可用命令:
  • /codeprobe audit <path>
    — 全面代码审计
  • /codeprobe solid <path>
    — SOLID原则检查
  • /codeprobe security <path>
    — 安全审计
  • /codeprobe smells <path>
    — 代码异味检测
  • /codeprobe architecture <path>
    — 架构分析
  • /codeprobe patterns <path>
    — 设计模式分析
  • /codeprobe performance <path>
    — 性能审计
  • /codeprobe errors <path>
    — 错误处理审计
  • /codeprobe tests <path>
    — 测试质量审计
  • /codeprobe framework <path>
    — 框架最佳实践检查
  • /codeprobe quick <path>
    — 前5个问题
此回复适用于:
diff
report

11. Execution Flow Summary

11. 执行流程摘要

When
/codeprobe
is invoked, execute this sequence:
  1. Parse command: Extract subcommand and target path from user input.
  2. Validate command: Check routing table. If Phase 3 stub, respond with stub message.
  3. Resolve target path: Use provided path or default to current working directory.
  4. Load config: Check for
    .codeprobe-config.json
    at project root. Apply defaults if absent.
  5. Auto-detect stack: Scan target path for technology signals. Load matching references.
  6. Apply config overrides: If
    framework
    is set in config, adjust detection. Apply
    skip_categories
    and
    skip_rules
    .
  7. Execute sub-skills: Route to appropriate sub-skills based on command and mode.
  8. Collect findings: Aggregate all findings in the output contract format.
  9. Deduplicate findings: Apply the cross-category deduplication procedure (Section 7A). Adjust severity of duplicates to
    suggestion
    . Recount severity totals per category.
  10. Compute scores: Calculate per-category and overall scores using the post-deduplication severity counts and the formulas in Section 7.
  11. Render report: Format output using the appropriate template or inline format. Use the tiered output format for
    /codeprobe audit
    .
  12. Present to user: Display the final report.
Remember: This entire process is READ-ONLY. At no point do we modify any user files.
当调用
/codeprobe
时,执行以下流程:
  1. 解析命令:从用户输入中提取子命令和目标路径。
  2. 验证命令:检查路由表。若为第三阶段占位功能,回复占位消息。
  3. 解析目标路径:使用提供的路径或默认使用当前工作目录。
  4. 加载配置:检查项目根目录下的
    .codeprobe-config.json
    。若不存在则应用默认值。
  5. 自动检测技术栈:扫描目标路径以获取技术信号。加载匹配的参考文档。
  6. 应用配置覆盖项:若配置中设置了
    framework
    ,调整检测结果。应用
    skip_categories
    skip_rules
  7. 执行子技能:根据命令和模式路由到相应的子技能。
  8. 收集问题结果:以输出约定格式聚合所有问题结果。
  9. 问题结果去重:应用跨分类去重流程(第7A节)。将重复项的严重程度改为
    suggestion
    。重新统计各分类的严重程度总数。
  10. 计算评分:使用去重后的严重程度统计结果和第7节的公式计算各分类评分和整体评分。
  11. 渲染报告:使用相应模板或直接格式输出。
    /codeprobe audit
    使用分层输出格式。
  12. 展示给用户:显示最终报告。
请记住:整个流程均为只读模式。任何时候都不得修改用户文件。