← 返回 Skills 市场
sipoon

Architecture Review

作者 Sipoon · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
23
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install sipoon-architecture-review
功能描述
定期扫描代码库架构质量,识别循环依赖、死代码、过大模块和高圈复杂度,生成报告指导重构优先级。
使用说明 (SKILL.md)

architecture-review

借鉴来源:improve-codebase-architecture + CodeGraphContext 死代码检测

定期对代码库做架构质量扫描,识别腐烂信号(泥球、反循环依赖、死代码、圈复杂度超标)。

核心理念:架构问题不会一夜发生,但会日积月累。定期扫描比一次性重构便宜10倍。


触发条件

满足以下任一场景时激活:

  • 用户要求"审计一下这个项目"、"看看代码有没有问题"
  • 进入一个陌生的代码库
  • 代码库超过 6 个月没做架构审查
  • 用户要求重构但没明确范围
  • 大版本发布前的质量检查

扫描维度

1. 模块结构(高优先级)

检查项

  • 模块之间是否有明确的层次关系(Domain → Application → Infrastructure)
  • 是否存在循环依赖(A→B→C→A)
  • 是否有超大的 God Module(>3000 行)

工具

# 检查循环依赖
npm run list:deps 2>/dev/null || npx madge --circular src/

# 统计模块行数
Get-ChildItem -Recurse src/**/*.ts | Get-Content | Measure-Object -Line

2. 死代码检测(高优先级)

检查项

  • 未被调用的函数/方法
  • 未被使用的变量/常量
  • 已被注释掉的代码(长期积累)
  • 旧的 API 端点(无人调用但仍在暴露)

工具

# TypeScript/JavaScript
npx ts-prune 2>/dev/null || npx madge --not --extensions ts,tsx

# Python
vulture . --min-confidence 80

# Go
staticcheck ./... 2>/dev/null | grep "is never used"

# 通用(基于 tree-sitter 调用图)
# codegraph-index skill 已构建调用图,孤立的叶子节点 = 潜在死代码

3. 圈复杂度检测(中优先级)

检查项

  • 函数/方法圈复杂度 > 10(难以测试,容易出 bug)
  • 圈复杂度 > 20 的函数必须拆分

工具

# TypeScript/JavaScript
npx complexity-report --dest ./complexity-report.html 2>/dev/null

# Python
radon cc -a -s src/

# 通用(Python 脚本)
python3 -c "
import os, ast
def cyclomatic(func_def):
    score = 1
    for node in ast.walk(func_def):
        if isinstance(node, (ast.If, ast.While, ast.For, ast.ExceptHandler)):
            score += 1
        elif isinstance(node, ast.BoolOp):
            score += len(node.values) - 1
    return score
# 输出复杂度超标的函数
"

4. 接口设计(边界清晰性)

检查项

  • 模块间接口是否有清晰的契约(类型定义/文档)
  • 是否存在隐式依赖(全局状态、Singleton 滥用)

工具

# 检查全局状态滥用
grep -r "global\." src/ --include="*.ts" | head -20
grep -r "window\." src/ --include="*.ts" | head -20

5. 技术债务可视化(长期追踪)

检查项

  • 过期的依赖包(有安全漏洞或已废弃)
  • 过时的 API 用法(如 Vue 2 Options API 项目中发现大量 Composition API)

工具

# 依赖检查
npm outdated 2>/dev/null
npx npm-check-updates 2>/dev/null

输出格式

## 架构审查报告

### 模块结构
| 问题 | 位置 | 严重度 |
|------|------|--------|
| 循环依赖 A→B→C→A | src/a/, src/b/ | 🔴 高 |
| God Module | src/core.js (3500行) | 🟡 中 |

### 死代码
| 函数/变量 | 位置 | 建议 |
|-----------|------|------|
| unusedFunc | lib/utils.ts:42 | 删除 |
| oldAPI | api/routes.js:15 | 移除端点 |

### 圈复杂度超标
| 函数 | 位置 | 复杂度 | 建议 |
|------|------|--------|------|
| processPayment | services/pay.ts:88 | 18 | 拆分为3个函数 |

### 技术债务
| 类型 | 描述 | 建议 |
|------|------|------|
| 过期依赖 | [email protected] | 升级到 4.x |
| 废弃 API | /api/v1/legacy | 移除或迁移 |

### 优先级排序
1. [立即处理] 循环依赖(影响所有新功能开发)
2. [本周处理] God Module 重构
3. [本月处理] 死代码清理
4. [下季度] 依赖升级

与其他 Skill 的配合

  • codegraph-index:先做索引,再查调用图和符号关系
  • refactoring:发现架构问题后,用 refactoring skill 执行重构
  • skill-compounding:如果某类架构问题反复出现,提取为检查清单 Skill

下一跳(Skill 链式调用)

architecture-review 是架构质量审查技能,审查完成后按以下路径调用:

  • 发现循环依赖、God Module 等架构问题 → 调用 refactoring 做重构
  • 同时需要安全/性能/代码质量等专项审查 → 调用 agent-teams
  • 只有轻微问题 → 直接输出报告,进入下一阶段

触发命令

"审计一下这个项目"、"看看代码有没有问题"、"做一次架构审查"、"检查死代码"

安全使用建议
Install this if you want an architecture-audit workflow. Before using it, confirm the review scope and approve any follow-on refactoring or agent-team actions, especially in private repositories or when npx tools may be downloaded and executed.
能力评估
Purpose & Capability
The skill's stated purpose is to review codebase architecture quality, and its suggested checks for cyclic dependencies, dead code, complexity, interfaces, and technical debt align with that purpose.
Instruction Scope
Some trigger phrases are broad, including general project audit language and activation when entering an unfamiliar repository; this could cause unexpected review behavior but is disclosed in the skill text.
Install Mechanism
The artifact contains only SKILL.md and _meta.json, with no executable install scripts or declared dependencies; static scan and VirusTotal telemetry were clean.
Credentials
The skill recommends normal code-analysis commands, including npx-based tools and local repository scanning, which are proportionate for architecture review but should be user-directed in private or large repositories.
Persistence & Privilege
No persistence mechanism, privilege escalation, credential/session handling, background worker, or automatic data exfiltration behavior was found.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install sipoon-architecture-review
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /sipoon-architecture-review 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Initial release of architecture-review skill for periodic codebase architecture quality scans. - Identifies architecture decay signals: ball of mud, cyclic dependencies, dead code, excessive complexity. - Scans for issues in module structure, dead code, code complexity, API design, and technical debt. - Provides recommended tools and output report format for actionable auditing. - Can be triggered automatically or by user request in specified scenarios. - Designed for integration with code indexing, refactoring, and skill-chaining workflows.
元数据
Slug sipoon-architecture-review
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Architecture Review 是什么?

定期扫描代码库架构质量,识别循环依赖、死代码、过大模块和高圈复杂度,生成报告指导重构优先级。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 23 次。

如何安装 Architecture Review?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install sipoon-architecture-review」即可一键安装,无需额外配置。

Architecture Review 是免费的吗?

是的,Architecture Review 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Architecture Review 支持哪些平台?

Architecture Review 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Architecture Review?

由 Sipoon(@sipoon)开发并维护,当前版本 v0.1.0。

💬 留言讨论