codeprobe
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Review Orchestrator
代码审查编排器
READ-ONLY CONSTRAINT
只读约束
THIS SKILL IS STRICTLY READ-ONLY WITH RESPECT TO THE CODEBASE BEING REVIEWED. NEVER modify, write, edit, or delete any file in the user's source tree. NEVER run commands with side effects on the reviewed project (no , no , no git commits, no database mutations). If a fix is needed, generate a copy-pasteable fix prompt that the user can run separately.
npm installpip installOne documented exception — report artifact: after finishes, the orchestrator writes a single markdown report to in the current working directory (e.g. ). This is the skill's own output, not modification of reviewed code. No other writes are permitted anywhere.
/codeprobe audit./codeprobe-reports/<project>-<cmd>-<timestamp>.md./codeprobe-reports/growth-engine-audit-2026-04-23-221047.mdViolations of this constraint are NEVER acceptable, regardless of user request.
本技能针对所审查的代码库严格为只读模式。 绝不能修改、写入、编辑或删除用户源码树中的任何文件。绝不能对所审查项目执行有副作用的命令(如、、git提交、数据库变更)。若需要修复,生成可复制粘贴的修复提示,由用户单独执行。
npm installpip install唯一有记录的例外情况——生成报告 artifact: 在完成后,编排器会在当前工作目录下的路径写入一份唯一的Markdown报告(例如)。这是本技能自身的输出,不属于修改审查代码的操作。除此之外,不允许在任何位置进行其他写入操作。
/codeprobe audit./codeprobe-reports/<project>-<cmd>-<timestamp>.md./codeprobe-reports/growth-engine-audit-2026-04-23-221047.md无论用户提出何种请求,违反此约束的行为都是绝对不被允许的。
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
路由表
| Command | Behavior | Sub-skills Invoked |
|---|---|---|
| Full audit — visual health dashboard (category scores, codebase stats, hot spots) followed by detailed P0-P3 findings with fix prompts | All available sub-skills + |
| SOLID principles analysis only | |
| Security audit only | |
| Code smells detection only | |
| Architecture analysis only | |
| Design patterns analysis only | |
| Performance audit only | |
| Error handling audit only | |
| Test quality audit only | |
| Framework best practices only | |
| Top 5 issues — run all sub-skills in scan mode, then generate full detail for top 5 | All available |
| PR-style review on changed files vs branch (default: | All relevant (Phase 3) |
| Generate report from last audit | (Phase 3 — TBD) |
| 命令 | 行为 | 调用的子技能 |
|---|---|---|
| 完整审计——先展示可视化健康仪表盘(分类评分、代码库统计信息、热点),再提供带有修复提示的详细P0-P3级问题结果 | 所有可用子技能 + |
| 仅进行SOLID原则分析 | |
| 仅进行安全审计 | |
| 仅检测代码异味 | |
| 仅进行架构分析 | |
| 仅进行设计模式分析 | |
| 仅进行性能审计 | |
| 仅进行错误处理审计 | |
| 仅进行测试质量审计 | |
| 仅检查框架最佳实践 | |
| 显示TOP 5问题——以扫描模式运行所有子技能,然后生成TOP 5问题的完整详情 | 所有可用子技能 |
| 针对变更文件与指定分支(默认: | 所有相关子技能(Phase 3) |
| 根据上次审计生成报告 | (Phase 3 — 待开发) |
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 or
diff, respond: "This feature is coming in Phase 3. Available now: audit, solid, security, smells, architecture, patterns, performance, errors, tests, framework, quick."report
- 未指定子命令:询问用户需求,展示可用命令列表。
- 未指定路径:使用当前工作目录。
- Phase 3占位命令:若用户调用或
diff,回复:“此功能将在Phase 3推出。当前可用命令:audit, solid, security, smells, architecture, patterns, performance, errors, tests, framework, quick。”report
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
检测流程
- Use Glob to scan file extensions at the target path (recursive, reasonable depth).
- Apply the following detection rules — multiple stacks can match simultaneously:
| Signal | Stack Detected | Reference to Load |
|---|---|---|
| PHP / Laravel | |
| JavaScript / TypeScript | |
| Python | |
| React / Next.js | |
| SQL / Database | |
| API Design | |
- For each detected stack, attempt to load the corresponding reference file using Read. If the file does not exist yet (Phase 2+), skip silently.
- Collect all loaded references into a context bundle to pass to sub-skills.
- 使用Glob工具递归扫描目标路径下的文件扩展名(扫描深度合理)。
- 应用以下检测规则——可同时匹配多个技术栈:
| 识别信号 | 检测到的技术栈 | 加载的参考文档 |
|---|---|---|
存在 | PHP / Laravel | |
存在 | JavaScript / TypeScript | |
存在 | Python | |
存在 | React / Next.js | |
存在 | SQL / 数据库 | |
存在 | API设计 | |
- 对于每个检测到的技术栈,尝试使用Read工具加载对应的参考文件。若文件尚未存在(Phase 2及以后版本),则静默跳过。
- 将所有加载的参考文档收集到上下文包中,传递给子技能。
Reference Loading
参考文档加载
References are loaded from the 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/references/{reference-file}.md(This resolves to the folder next to this SKILL.md file.)
references/If a reference file does not exist, continue without it. Never fail the review because a reference is missing.
参考文档从本技能目录下的目录加载。路径相对于本SKILL.md文件的位置,而非用户项目的位置。使用Read工具加载:
references/references/{reference-file}.md(此路径指向本SKILL.md文件旁的文件夹。)
references/若参考文档不存在,继续执行审查流程,不会因缺少参考文档而终止。
3. Config Loading
3. 配置加载
Check for a file in the project root (the target path or its ancestor directories).
.codeprobe-config.json检查项目根目录(目标路径或其上级目录)下是否存在文件。
.codeprobe-config.jsonConfig 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.
- : Pass to sub-skills so they adjust thresholds accordingly.
severity_overrides - : Do not invoke the listed sub-skills, even in
skip_categoriesorauditmode.quick - : Pass to sub-skills so they suppress findings with matching IDs.
skip_rules - : If set, skip auto-detection for that framework and force-load the corresponding reference. Other auto-detection still proceeds.
framework - : Additional reference file paths to load and pass to sub-skills.
extra_references - : Output format preference (default:
report_format).markdown
- 配置不存在:应用所有默认值,不会报错。
- :传递给子技能,使其相应调整阈值。
severity_overrides - :不调用列出的子技能,即使在
skip_categories或audit模式下也不调用。quick - :传递给子技能,使其屏蔽匹配ID的问题结果。
skip_rules - :若已设置,跳过该框架的自动检测,强制加载对应的参考文档。其他技术栈的自动检测仍会进行。
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:
-
Read the shared preamble from(in this skill's directory). This contains the output contract, execution modes, and constraints shared by all sub-skills.
shared-preamble.md -
Read all source files at the target path:
- Use Glob to find all source files (,
.ts,.tsx,.js,.jsx,.py,.php,.vue,.sql,.cssand config files like.scss,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}
- Use Glob to find all source files (
-
Read all applicable reference files (already loaded during stack detection in Section 2). Store the content.
在调用任何子技能之前,编排器必须预加载所有共享上下文:
-
读取共享前置内容:从本技能目录下的读取。其中包含所有子技能共享的输出约定、执行模式和约束条件。
shared-preamble.md -
读取目标路径下的所有源文件:
- 使用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}
- 使用Glob工具查找所有源文件(
-
读取所有适用的参考文档(已在第2节的技术栈检测阶段加载)。存储文档内容。
Invocation Protocol
调用协议
For each sub-skill to run, spawn an Agent with a prompt that includes:
- The shared preamble (from ) — output contract, modes, constraints.
shared-preamble.md - The sub-skill name to invoke (e.g., ).
codeprobe-security - The mode — one of or
full.scan - Pre-loaded source files — the full content of every source file, formatted as:
=== FILE: {filepath} === {content} === END FILE === - Pre-loaded references — the content of all applicable reference files.
- Config overrides — severity overrides and skip rules from .
.codeprobe-config.json - Target path — so the sub-skill knows the project root for any targeted lookups.
- Sub-skill-specific pre-loaded script output (when applicable):
- For : before spawning the agent, run
codeprobe-architecturevia Bash and capture the JSON output. Pass it as an additional context block labeledpython3 scripts/dependency_mapper.py <target_path>. The sub-skill uses this as the ground truth for cycle detection. If Python 3 is unavailable or the script fails, omit the block — the sub-skill falls back to LLM-based import tracing.=== DEPENDENCY_GRAPH === ... === END DEPENDENCY_GRAPH === - For : if
codeprobe-performanceoutput is available (optional), pass it asscripts/complexity_scorer.py.=== COMPLEXITY_SCORES === ... === END COMPLEXITY_SCORES ===
- For
The sub-skill's own SKILL.md contains only its domain-specific detection logic. All shared context (output format, modes, source code, references, pre-computed script data) comes from the orchestrator's prompt.
Collect findings returned by each sub-skill in the standard output contract format (Section 5).
对于每个要运行的子技能,生成一个Agent,其提示信息包含:
- 共享前置内容(来自)——输出约定、模式、约束条件。
shared-preamble.md - 要调用的子技能名称(例如)。
codeprobe-security - 执行模式——或
full之一。scan - 预加载的源文件——所有源文件的完整内容,格式如下:
=== FILE: {filepath} === {content} === END FILE === - 预加载的参考文档——所有适用参考文档的内容。
- 配置覆盖项——来自的严重程度覆盖项和跳过规则。
.codeprobe-config.json - 目标路径——让子技能知晓项目根目录,以便进行针对性查找。
- 子技能专属的预加载脚本输出(如适用):
- 对于:在生成Agent之前,通过Bash运行
codeprobe-architecture并捕获JSON输出。将其作为附加上下文块传递,标记为python3 scripts/dependency_mapper.py <target_path>。子技能将此作为循环检测的基准。若Python 3不可用或脚本执行失败,则省略该块——子技能将回退到基于LLM的导入追踪。=== DEPENDENCY_GRAPH === ... === END DEPENDENCY_GRAPH === - 对于:若
codeprobe-performance的输出可用(可选),将其作为scripts/complexity_scorer.py传递。=== COMPLEXITY_SCORES === ... === END COMPLEXITY_SCORES ===
- 对于
子技能自身的SKILL.md仅包含其领域特定的检测逻辑。所有共享上下文(输出格式、模式、源代码、参考文档、预计算的脚本数据)均来自编排器的提示信息。
收集结果:收集每个子技能返回的符合标准输出约定格式(第5节)的问题结果。
Execution Modes
执行模式
| Mode | Used By | Behavior |
|---|---|---|
| | Run complete analysis, return all findings |
| | Count violations, identify top issues, return only counts + top 5 candidates |
| 模式 | 使用场景 | 行为 |
|---|---|---|
| | 执行完整分析,返回所有问题结果 |
| | 统计违规数量,识别主要问题,仅返回统计数量+TOP 5候选问题 |
Execution Order
执行顺序
- : Run sub-skills sequentially in this order:
/codeprobe audit,codeprobe-security,codeprobe-error-handling,codeprobe-solid,codeprobe-architecture,codeprobe-patterns,codeprobe-performance,codeprobe-code-smells,codeprobe-testing— all incodeprobe-frameworkmode. Before invokingfull, pre-compute the dependency graph viacodeprobe-architectureand pass the JSON to the sub-skill as described in the Invocation Protocol (step 8). 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 runscripts/dependency_mapper.pyfor codebase stats (skip gracefully if Python 3 unavailable).scripts/file_stats.py - : Run all 9 sub-skills in
/codeprobe quickmode. Collect candidate issues from all. Rank by severity (critical > major > minor > suggestion), then select top 5. Re-run relevant sub-skills inscanmode for just those 5 findings to get complete detail.full
- :按以下顺序依次运行子技能:
/codeprobe audit、codeprobe-security、codeprobe-error-handling、codeprobe-solid、codeprobe-architecture、codeprobe-patterns、codeprobe-performance、codeprobe-code-smells、codeprobe-testing——全部以codeprobe-framework模式运行。在调用full之前,通过codeprobe-architecture预计算依赖图,并按照调用协议(步骤8)将JSON传递给子技能。收集所有问题结果。执行去重操作(第7A节)。根据严重程度统计结果得出分类评分。通过按文件聚合问题结果并按标记的不同分类数量排序,计算热点文件。同时运行scripts/dependency_mapper.py获取代码库统计信息(若Python 3不可用则优雅跳过)。scripts/file_stats.py - :以
/codeprobe quick模式运行所有9个子技能。收集所有子技能返回的候选问题。按严重程度排序(critical > major > minor > suggestion),然后选择TOP 5。针对这5个问题,重新以scan模式运行相关子技能以获取完整详情。full
Available Sub-Skills
可用子技能
- — Security vulnerability detection
codeprobe-security - — Error handling & resilience
codeprobe-error-handling - — SOLID principles analysis
codeprobe-solid - — Architecture analysis
codeprobe-architecture - — Design patterns advisor
codeprobe-patterns - — Performance & scalability
codeprobe-performance - — Code smell detection
codeprobe-code-smells - — Test quality & coverage
codeprobe-testing - — Framework-specific best practices
codeprobe-framework
- — 安全漏洞检测
codeprobe-security - — 错误处理与韧性检查
codeprobe-error-handling - — SOLID原则分析
codeprobe-solid - — 架构分析
codeprobe-architecture - — 设计模式建议
codeprobe-patterns - — 性能与可扩展性检查
codeprobe-performance - — 代码异味检测
codeprobe-code-smells - — 测试质量与覆盖率检查
codeprobe-testing - — 框架专属最佳实践检查
codeprobe-framework
5. Output Contract
5. 输出约定
Every finding from every sub-skill MUST include these fields:
| Field | Required | Description |
|---|---|---|
| Yes | Unique identifier in format |
| Yes | One of: |
| Yes | File path + line range (e.g., |
| Yes | One sentence describing the issue |
| Yes | Concrete proof from the code — quote the relevant lines |
| Yes | What to do to fix it |
| Yes | A copy-pasteable prompt the user can give to Claude Code to apply the fix |
| No | Optional code snippet showing the improved version |
每个子技能返回的每个问题结果必须包含以下字段:
| 字段 | 是否必填 | 描述 |
|---|---|---|
| 是 | 唯一标识符,格式为 |
| 是 | 取值范围: |
| 是 | 文件路径+行范围(例如 |
| 是 | 用一句话描述问题 |
| 是 | 来自代码的具体证据——引用相关代码行 |
| 是 | 修复建议 |
| 是 | 可复制粘贴的提示,用户可将其提供给Claude Code以应用修复 |
| 否 | 可选的代码片段,展示优化后的版本 |
Finding Format Example
问题结果格式示例
undefinedundefinedSRP-001 | Major | src/UserService.php:45-67
src/UserService.php:45-67SRP-001 | Major | src/UserService.php:45-67
src/UserService.php:45-67Problem: UserService violates Single Responsibility — handles authentication, email sending, and database queries in one class.
Evidence:
Lines 45-50:Lines 52-60:public function authenticate($credentials) { ... }Lines 62-67:public function sendWelcomeEmail($user) { ... }public function findByUsername($name) { ... }
Suggestion: Extract email logic into a dedicated service and database queries into a .
UserMailerUserRepositoryFix prompt:
Refactorto follow Single Responsibility Principle: extractsrc/UserService.phpinto a newsendWelcomeEmail()class andUserMailerinto afindByUsername()class. KeepUserRepositoryinauthenticate()and inject the new dependencies.UserService
---问题: UserService违反单一职责原则——在一个类中同时处理认证、邮件发送和数据库查询。
证据:
第45-50行:第52-60行:public function authenticate($credentials) { ... }第62-67行:public function sendWelcomeEmail($user) { ... }public function findByUsername($name) { ... }
建议: 将邮件逻辑提取到专门的服务中,将数据库查询提取到中。
UserMailerUserRepository修复提示:
重构以遵循单一职责原则:将src/UserService.php提取到新的sendWelcomeEmail()类中,将UserMailer提取到findByUsername()类中。保留UserRepository在authenticate()中,并注入新的依赖。UserService
---6. Severity Levels
6. 严重程度等级
| Level | Priority | Meaning | Examples |
|---|---|---|---|
| Critical | P0 | Confirmed bugs, exploitable security vulnerabilities, or data loss/corruption risks that would cause harm in production | SQL 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 | P1 | Significant maintainability, reliability, or scalability problem that increases risk but is not an immediate production defect | Missing tests for critical business logic, large classes, code duplication, missing error handling on external calls, N+1 queries, missing input validation |
| Minor | P2 | Code smell, low risk, worth addressing for long-term health | Magic numbers, deep nesting, poor naming, missing edge case tests, verbose error details |
| Suggestion | P3 | Improvement idea, nice to have, no real risk if ignored | Pattern opportunities, style improvements, speculative generality |
| 等级 | 优先级 | 含义 | 示例 |
|---|---|---|---|
| Critical | P0 | 已确认的bug、可利用的安全漏洞或数据丢失/损坏风险,会在生产环境中造成危害 | 用户输入导致的SQL注入、数据变更端点缺少认证、导致数据损坏的竞态条件、核心路径上未处理的崩溃、多步骤写入缺少数据库事务 |
| Major | P1 | 严重的可维护性、可靠性或可扩展性问题,会增加风险但并非即时生产缺陷 | 关键业务逻辑缺少测试、大型类、代码重复、外部调用缺少错误处理、N+1查询、缺少输入验证 |
| Minor | P2 | 代码异味,低风险,为了长期健康值得修复 | 魔法数字、深层嵌套、命名不佳、缺少边缘情况测试、冗长的错误详情 |
| Suggestion | P3 | 改进建议,有则更好,忽略也无实际风险 | 设计模式应用机会、风格改进、过度设计 |
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
分类权重
| Category | Weight |
|---|---|
| Security | 20% |
| SOLID | 15% |
| Architecture | 15% |
| Error Handling | 12% |
| Performance | 12% |
| Test Quality | 10% |
| Code Smells | 8% |
| Design Patterns | 4% |
| Framework | 4% |
All 9 categories are active. Weights sum to 100%.
| 分类 | 权重 |
|---|---|
| Security | 20% |
| SOLID | 15% |
| Architecture | 15% |
| Error Handling | 12% |
| Performance | 12% |
| Test Quality | 10% |
| Code Smells | 8% |
| Design Patterns | 4% |
| Framework | 4% |
所有9个分类均生效,权重总和为100%。
Overall Score
整体得分
overall = sum(category_score_i * weight_i for each active category)If in excludes some categories, normalize by dividing by the sum of active weights:
skip_categories.codeprobe-config.jsonoverall = 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.jsonskip_categoriesoverall = sum(category_score_i * weight_i for each active category) / sum(weight_i for each active category)将结果限制在[0, 100]范围内。
Score Interpretation
得分解读
| Range | Status |
|---|---|
| 80-100 | Healthy |
| 60-79 | Needs Attention |
| 0-59 | Critical |
| 范围 | 状态 |
|---|---|
| 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
去重流程
-
Group findings by location. Normalize each finding'sto
location. 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).{file}:{start_line} -
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 field:
problemand change its severity to[Duplicate of {primary_id} — counted there]so it does not affect the score of its own category. c. Cross-reference the primary. Append to the primary finding'ssuggestionfield:suggestionAlso flagged by: {list of duplicate category:id pairs}
-
Recount severity totals per category after deduplication, then proceed to scoring.
-
按位置分组:将每个问题结果的标准化为
location。若两个问题结果的文件相同且行范围重叠(即start_line_A <= end_line_B 且 start_line_B <= end_line_A),则视为重叠。{file}:{start_line} -
针对来自不同分类的重叠问题组: a. 选择主问题结果:按照以下优先级顺序选择:
- 涉及认证、注入或数据泄露的Security问题(SEC)优先
- 涉及异常/验证的Error Handling问题(ERR)优先
- 涉及查询/缓存的Performance问题(PERF)优先
- 涉及结构违规的SOLID问题(SRP/OCP/LSP/ISP/DIP)优先
- 涉及层/边界违规的Architecture问题(ARCH)优先
- 若仍存在歧义,选择权重更高的分类(第7节)对应的问题结果
b. 标记重复项:对于组中的每个非主问题结果,在其字段后追加:
problem,并将其严重程度改为[重复项,对应主问题ID:{primary_id} — 已在该分类中统计],使其不影响自身分类的得分。 c. 交叉引用主问题结果:在主问题结果的suggestion字段后追加:suggestion同时被以下分类标记:{重复分类:ID列表}
-
去重后重新统计每个分类的严重程度总数,然后进行评分。
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/codeprobe audit
— 完整审计报告
/codeprobe auditUse the template at (loaded via Read) to assemble the markdown for the saved report file. The terminal output is a summary — the user MUST see a visual summary in the terminal, not only the "Report saved" line.
templates/full-audit-report.mdTerminal vs saved-file split (MANDATORY):
| Surface | What it shows | How it's produced |
|---|---|---|
| Terminal | Dashboard + executive summary + critical findings (full detail) + prioritized fix order (top 5) + "Report saved" line | Streamed markdown sections in the assistant response |
Saved file ( | Everything: dashboard, exec summary, all critical/major findings, minor/suggestion counts, full prioritized fix order | Plain markdown written via |
The terminal must never be empty or reduced to just a save confirmation. If Claude only emitted the save line in a past run, that was a bug in how these instructions were followed — fix it by executing the flow below in order.
使用模板(通过Read工具加载)组装要保存的报告文件的Markdown内容。终端输出为摘要——用户必须在终端中看到可视化摘要,不能仅显示“报告已保存”的提示。
templates/full-audit-report.md终端与保存文件的内容划分(强制要求):
| 展示渠道 | 内容 | 生成方式 |
|---|---|---|
| 终端 | 仪表盘 + 执行摘要 + Critical级问题结果(完整详情) + 优先修复顺序(TOP 5) + “报告已保存”提示 | 在助手响应中流式输出Markdown章节 |
保存文件 ( | 全部内容:仪表盘、执行摘要、所有Critical/Major级问题结果、Minor/Suggestion级问题数量统计、完整的优先修复顺序 | 使用 |
终端绝不能为空或仅显示保存确认信息。如果Claude在之前的运行中仅输出了保存提示,说明未正确遵循本指令——请按照以下流程修复,按顺序执行。
Step-by-step flow
分步流程
A. Compute data (shared by both surfaces)
- Run sub-skills per Section 4, collect findings, deduplicate per Section 7A.
- Derive category scores, overall score, hot spots, codebase stats.
- Assemble an in-memory "report bundle": .
{dashboard_data, exec_summary, critical[], major[], minor_counts[], suggestion_counts[], fix_order[]}
B. Render to terminal (user-facing — emit these directly as markdown in the assistant response, in order)
Do NOT pipe the dashboard through the Bash tool. The Bash tool collapses its output by default in Claude Code's UI (), which hides the dashboard behind a fold. Emit the dashboard as ordinary assistant-response markdown so the user sees it immediately. Modern terminals (Ghostty, iTerm2, etc.) will apply their own markdown styling — bold, inline-code highlighting, emphasis — which is the only coloring available on this path. If no coloring shows, plain text is fine; do not try to force ANSI escapes into the response.
+N lines (ctrl+r to expand)( exists for users running the audit directly from their own shell outside Claude Code, where its stdout is a real TTY. Do NOT invoke it from within the flow.)
scripts/render_dashboard.py/codeprobe audit- Dashboard (markdown) — emit the dashboard block inline. Include: title line (),
## Code Health Report — {project}, the 9-row Category Scores markdown table with columns**Overall Health:** {score}/100 [{status_label}](bar wrapped in backticks, 20-char UnicodeCategory | Score | Bar | Status/█proportional to score), codebase stats block (files, LOC, backend/frontend split, largest file, test ratio, comment ratio), and a hot-spots list (up to 3 entries). Status labels plain text in the Status column, no emoji, no brackets inside the table.░ - Executive Summary — 2-3 sentences covering the most important findings.
- Critical findings — full detail — for each critical finding: ID, location, problem, evidence, suggestion, fix prompt. This is the highest-signal section; always show in the terminal.
- Prioritized Fix Order (top 5) — the first 5 entries from the full prioritized fix order. Reference the saved file for the complete list.
- Save confirmation line — (no emoji; ASCII arrow). This is the LAST line in the terminal output.
--> Report saved to ./codeprobe-reports/{project}-{cmd}-{YYYY-MM-DD-HHMMSS}.md
Do NOT also stream the major-findings table, minor/suggestion counts, or the full fix order to the terminal — those would duplicate content that the saved file already carries and bloat the terminal output. The user can open the saved file for the complete picture.
C. Write saved-file markdown
- Build the full markdown using placeholders — this includes sections that are NOT streamed to the terminal (major findings table, minor/suggestion counts, full prioritized fix order).
templates/full-audit-report.md - Derive the filename as :
{project}-{cmd}-{YYYY-MM-DD-HHMMSS}.md- — resolve the target path to an absolute path (use the current working directory if the user passed no path); take its basename; if that basename points to a file, strip the extension; slugify it (lowercase; replace any run of
{project}with a single[^a-z0-9]+; trim leading/trailing-); fall back to-if the slug ends up empty.unknown - — the subcommand routed in Section 1 (
{cmd},audit,quick,security,solid,architecture,performance,errors,tests,smells,patterns), lowercased.framework - — current local time.
{YYYY-MM-DD-HHMMSS}
- Ensure exists (
./codeprobe-reports/via Bash if missing).mkdir -p ./codeprobe-reports - Write to using the
./codeprobe-reports/{project}-{cmd}-{YYYY-MM-DD-HHMMSS}.mdtool.Write - If the write fails (read-only filesystem, permission denied, etc.), surface a short inline note in the terminal but do not re-emit the summary.
D. Terminal-output contract (hard requirements)
- The terminal MUST include (in this order): dashboard → exec summary → critical findings → top 5 fix order → "Report saved" line.
- If there are zero critical findings, show the dashboard, exec summary, a one-line "No critical issues found" note, top 5 fix order (will be major-only), and save confirmation — still non-empty.
- If the report save fails, still emit the full terminal summary — do not block the summary on the file write.
- If the template file is missing, render inline following the same section ordering; the save step (C) still applies.
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 layout (major as table, minor/suggestion as counts only — all in the saved file) targets ~8,000-12,000 tokens on disk (vs ~40,000 with full detail for all findings). The terminal summary is much tighter because only the dashboard, exec summary, critical findings, and top 5 fix order are streamed there. The user can drill into specific categories with etc. for full detail on any one category.
/codeprobe security .A. 计算数据(两个渠道共享)
- 按照第4节运行子技能,收集问题结果,按照第7A节进行去重。
- 得出分类得分、整体得分、热点文件、代码库统计信息。
- 组装内存中的“报告包”:。
{dashboard_data, exec_summary, critical[], major[], minor_counts[], suggestion_counts[], fix_order[]}
B. 渲染到终端(面向用户——按顺序直接在助手响应中输出这些Markdown内容)
不要通过Bash工具渲染仪表盘。Bash工具在Claude Code的UI中默认会折叠输出(),导致仪表盘被隐藏在折叠区域后。将仪表盘作为普通助手响应的Markdown内容输出,让用户立即看到。现代终端(Ghostty、iTerm2等)会自行应用Markdown样式——加粗、行内代码高亮、强调——这是此渠道唯一可用的着色方式。如果没有着色显示,纯文本也可以;不要尝试在响应中强制使用ANSI转义符。
+N lines (ctrl+r to expand)(适用于用户在Claude Code之外的自有Shell中直接运行审计的场景,其stdout为真实TTY。请勿在流程中调用它。)
scripts/render_dashboard.py/codeprobe audit- 仪表盘(Markdown):内联输出仪表盘块。包含:标题行()、
## 代码健康报告 — {project}、9行的分类评分Markdown表格(列:**整体健康状况:** {score}/100 [{status_label}],进度条用反引号包裹,20字符的Unicode分类 | 得分 | 进度条 | 状态/█按得分比例显示)、代码库统计信息块(文件数、行数、前后端拆分、最大文件、测试比例、注释比例)、热点文件列表(最多3条)。状态列使用纯文本标签,无表情符号,表格内无括号。░ - 执行摘要:2-3句话,涵盖最重要的问题结果。
- Critical级问题结果——完整详情:每个Critical级问题结果包含ID、位置、问题、证据、建议、修复提示。这是信号最强的部分,必须在终端中显示。
- 优先修复顺序(TOP 5):完整优先修复顺序中的前5项。提示用户查看保存的文件获取完整列表。
- 保存确认行:(无表情符号;使用ASCII箭头)。这是终端输出的最后一行。
--> 报告已保存至 ./codeprobe-reports/{project}-{cmd}-{YYYY-MM-DD-HHMMSS}.md
不要在终端中流式输出Major级问题结果表格、Minor/Suggestion级问题数量统计或完整优先修复顺序——这些内容已包含在保存的文件中,会导致终端输出冗余。用户可以打开保存的文件查看完整内容。
C. 写入保存文件的Markdown内容
- 使用模板中的占位符构建完整Markdown内容——包含未流式输出到终端的部分(Major级问题结果表格、Minor/Suggestion级问题数量统计、完整优先修复顺序)。
templates/full-audit-report.md - 生成文件名::
{project}-{cmd}-{YYYY-MM-DD-HHMMSS}.md- :将目标路径解析为绝对路径(若用户未指定路径则使用当前工作目录);取其basename;若basename指向文件则去掉扩展名;将其转换为slug格式(小写;将任何
{project}替换为单个[^a-z0-9]+;去除首尾的-);若slug为空则回退为-。unknown - :第1节中路由的子命令(
{cmd}、audit、quick、security、solid、architecture、performance、errors、tests、smells、patterns),小写。framework - :当前本地时间。
{YYYY-MM-DD-HHMMSS}
- 确保目录存在(若不存在则通过Bash执行
./codeprobe-reports/)。mkdir -p ./codeprobe-reports - 使用工具将内容写入
Write。./codeprobe-reports/{project}-{cmd}-{YYYY-MM-DD-HHMMSS}.md - 若写入失败(只读文件系统、权限不足等),在终端中显示简短的内联提示,但不要重新输出摘要。
D. 终端输出约定(硬性要求)
- 终端必须包含(按顺序):仪表盘 → 执行摘要 → Critical级问题结果 → TOP 5修复顺序 → “报告已保存”提示。
- 若没有Critical级问题结果,显示仪表盘、执行摘要、一行“未发现严重问题”提示、TOP 5修复顺序(仅包含Major级问题)和保存确认——终端输出仍不能为空。
- 若报告保存失败,仍要输出完整的终端摘要——不要因文件写入失败而阻止摘要显示。
- 若模板文件缺失,按相同的章节顺序内联渲染;保存步骤(C)仍需执行。
状态阈值(适用于整体健康状况和每个分类得分):
- 80-100 = “健康”
- 60-79 = “需要关注”
- 0-59 = “严重”
Token预算指南: 对于包含约100个问题结果的代码库,分层展示问题结果的布局(Major级问题结果为表格,Minor/Suggestion级问题结果仅显示数量——均在保存文件中)目标是磁盘上占用约8000-12000个Token(若所有问题结果都显示完整详情则约为40000个Token)。终端摘要更简洁,因为仅流式输出仪表盘、执行摘要、Critical级问题结果和TOP 5修复顺序。用户可以使用等命令深入查看任意一个分类的完整详情。
/codeprobe security ./codeprobe quick
— Quick Review Summary
/codeprobe quick/codeprobe quick
— 快速审查摘要
/codeprobe quickUse the template at (loaded via Read). If the template does not exist yet, render inline:
templates/quick-review-summary.md- Header: Project name, "Quick Review — Top 5 Issues".
- Top 5 Findings: Full detail for the 5 most impactful issues, each with fix prompt.
- Summary Counts: Total issues found by severity across all categories.
- Next Step: Suggest running for the complete picture.
/codeprobe audit
使用模板(通过Read工具加载)。若模板尚未存在,则内联渲染:
templates/quick-review-summary.md- 标题:项目名称,“快速审查 — TOP 5问题”。
- TOP 5问题结果:5个影响最大的问题结果的完整详情,每个都包含修复提示。
- 摘要统计:所有分类中按严重程度统计的总问题数量。
- 下一步建议:建议运行获取完整分析结果。
/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:
- Switch to degraded mode: Analyze only the in-context code provided.
- Execute sub-skills sequentially on the pasted code (no parallel agents).
- Skip ,
file_stats.py, and all script-dependent steps (sub-skills fall back to LLM-only analysis — architecture loses deterministic cycle detection).dependency_mapper.py - Skip ,
/codeprobe diff, the Codebase Stats row of the audit dashboard, and the report-save step (no filesystem write). Still render scores, hot spots, and findings to the terminal./codeprobe report - 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."
- Still produce findings in the standard output contract format.
- Still compute scores based on findings from available sub-skills.
检测是否具备文件系统访问权限。若用户粘贴或上传代码而非提供文件路径,或Read/Glob/Grep工具不可用:
- 切换到降级模式:仅分析上下文提供的代码。
- 依次执行子技能:对粘贴的代码依次执行子技能(不使用并行Agent)。
- 跳过、
file_stats.py以及所有依赖脚本的步骤(子技能回退到仅基于LLM的分析——架构分析将失去确定性循环检测能力)。dependency_mapper.py - 跳过、
/codeprobe diff、审计仪表盘的代码库统计行以及报告保存步骤(无法写入文件系统)。仍要在终端中渲染得分、热点文件和问题结果。/codeprobe report - 告知用户:“当前运行在Claude.ai模式下——部分功能如代码库统计、差异审查和多文件分析不可用。正在直接分析提供的代码。”
- 仍要按照标准输出约定格式生成问题结果。
- 仍要基于可用子技能返回的问题结果计算得分。
10. Phase 3 Stubs
10. Phase 3占位命令
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:
— Full code audit/codeprobe audit <path> — SOLID principles check/codeprobe solid <path> — Security audit/codeprobe security <path> — Code smells detection/codeprobe smells <path> — Architecture analysis/codeprobe architecture <path> — Design patterns analysis/codeprobe patterns <path> — Performance audit/codeprobe performance <path> — Error handling audit/codeprobe errors <path> — Test quality audit/codeprobe tests <path> — Framework best practices/codeprobe framework <path> — Top 5 issues/codeprobe quick <path>
This applies to: , .
diffreport当用户调用指向未开发功能的命令时,回复:
暂不可用。 此功能将在Phase 3推出。当前可用命令:
— 完整代码审计/codeprobe audit <path> — SOLID原则检查/codeprobe solid <path> — 安全审计/codeprobe security <path> — 代码异味检测/codeprobe smells <path> — 架构分析/codeprobe architecture <path> — 设计模式分析/codeprobe patterns <path> — 性能审计/codeprobe performance <path> — 错误处理审计/codeprobe errors <path> — 测试质量审计/codeprobe tests <path> — 框架最佳实践检查/codeprobe framework <path> — TOP 5问题/codeprobe quick <path>
此回复适用于:、。
diffreport11. Execution Flow Summary
11. 执行流程摘要
When is invoked, execute this sequence:
/codeprobe- Parse command: Extract subcommand and target path from user input.
- Validate command: Check routing table. If Phase 3 stub, respond with stub message.
- Resolve target path: Use provided path or default to current working directory.
- Load config: Check for at project root. Apply defaults if absent.
.codeprobe-config.json - Auto-detect stack: Scan target path for technology signals. Load matching references.
- Apply config overrides: If is set in config, adjust detection. Apply
frameworkandskip_categories.skip_rules - Execute sub-skills: Route to appropriate sub-skills based on command and mode.
- Collect findings: Aggregate all findings in the output contract format.
- Deduplicate findings: Apply the cross-category deduplication procedure (Section 7A). Adjust severity of duplicates to . Recount severity totals per category.
suggestion - Compute scores: Calculate per-category and overall scores using the post-deduplication severity counts and the formulas in Section 7.
- Render report: Format output using the appropriate template or inline format. Use the tiered output format for .
/codeprobe audit - Present to user: Display the final report.
Remember: This entire process is READ-ONLY. At no point do we modify any user files.
当被调用时,执行以下流程:
/codeprobe- 解析命令:从用户输入中提取子命令和目标路径。
- 验证命令:检查路由表。若为Phase 3占位命令,回复占位提示信息。
- 解析目标路径:使用提供的路径或默认使用当前工作目录。
- 加载配置:检查项目根目录下的。若不存在则应用默认值。
.codeprobe-config.json - 自动检测技术栈:扫描目标路径查找技术栈信号。加载匹配的参考文档。
- 应用配置覆盖项:若配置中设置了,调整检测结果。应用
framework和skip_categories。skip_rules - 执行子技能:根据命令和模式路由到相应的子技能。
- 收集问题结果:聚合所有符合输出约定格式的问题结果。
- 问题结果去重:执行跨分类去重流程(第7A节)。将重复项的严重程度改为。重新统计每个分类的严重程度总数。
suggestion - 计算得分:使用去重后的严重程度统计结果和第7节中的公式计算每个分类的得分和整体得分。
- 渲染报告:使用相应的模板或内联格式格式化输出。对于使用分层输出格式。
/codeprobe audit - 展示给用户:显示最终报告。
请记住:整个流程是只读的。任何时候都不得修改用户文件。