| name | improve-codebase-architecture |
| description | Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick. |
| 触发词 | 扫描代码库寻找深化机会,以可视化的 HTML 报告呈现,然后对你选择的任一方案进行追问。 |
| disable-model-invocation | true |
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
揭示架构摩擦并提出深化机会——将浅模块重构为深模块的重构方案。目标是可测试性和 AI 可导航性。
This command is informed by the project's domain model and built on a shared design vocabulary:
本命令受项目的领域模型启发,并建立在共享的设计词汇之上:
/codebase-design skill for the architecture vocabulary (module, interface, depth, seam, adapter, leverage, locality) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion — don't drift into "component," "service," "API," or "boundary."CONTEXT.md gives names to good seams; ADRs in docs/adr/ record decisions this command should not re-litigate./codebase-design 技能获取架构词汇(模块、接口、深度、接缝、适配器、杠杆收益、局部性)及其原则(删除测试、"接口即测试面"、"一个适配器 = 假设性接缝,两个 = 真实的")。在每个建议中精确使用这些术语——不要偏离到"组件""服务""API"或"边界"。CONTEXT.md 中的领域语言为好的接缝命名;docs/adr/ 中的 ADR 记录了本命令不应重新质疑的决策。Read the project's domain glossary (CONTEXT.md) and any ADRs in the area you're touching first.
首先阅读项目的领域词汇表(CONTEXT.md)以及你将要触及的区域内任何 ADR。
Then use the Agent tool with subagent_type=Explore to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
然后使用 subagent_type=Explore 的代理工具遍历代码库。不要遵循僵化的启发式方法——有机地探索,记下你遇到摩擦的地方:
Apply the deletion test to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
对任何你怀疑是浅的东西应用删除测试:删除它会集中复杂性,还是仅仅移动它?答案是"会集中"就是你要的信号。
Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from $TMPDIR, falling back to /tmp (or %TEMP% on Windows), and write to <tmpdir>/architecture-review-<timestamp>.html so each run gets a fresh file. Open it for the user — xdg-open <path> on Linux, open <path> on macOS, start <path> on Windows — and tell them the absolute path.
将独立的 HTML 文件写入操作系统临时目录,这样不会在仓库中留下痕迹。从 $TMPDIR 解析临时目录,回退到 /tmp(Windows 上为 %TEMP%),写入 <tmpdir>/architecture-review-<timestamp>.html,这样每次运行都获得新文件。为用户打开它——Linux 上用 xdg-open <path>,macOS 上用 open <path>,Windows 上用 start <path>——并告诉他们绝对路径。
The report uses Tailwind via CDN for layout and styling, and Mermaid via CDN for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a before/after visualisation. Be visual.
报告使用通过 CDN 加载的 Tailwind 进行布局和样式设置,使用通过 CDN 加载的 Mermaid 处理能用图形/流程/序列可靠传达结构的图表。将 Mermaid 与手工制作的 CSS/SVG 视觉元素混合使用——当关系是图形形状(调用图、依赖关系、序列)时使用 Mermaid,当想要更具编辑性的内容(体量图、剖面图、折叠动画)时使用手工构建的 div/SVG。每个候选方案都有前后对比可视化。要有视觉冲击力。
For each candidate, render a card with:
对每个候选方案,渲染一个包含以下内容的卡片:
Strong, Worth exploring, Speculative, rendered as a badgeStrong、Worth exploring、Speculative 之一,渲染为徽章End the report with a Top recommendation section: which candidate you'd tackle first and why.
以首选推荐部分结束报告:你会先处理哪个候选方案以及为什么。
Use CONTEXT.md vocabulary for the domain, and the /codebase-design vocabulary for the architecture. If CONTEXT.md defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
使用 CONTEXT.md 的词汇表描述领域,使用 /codebase-design 的词汇表描述架构。 如果 CONTEXT.md 定义了"Order",就说"Order intake 模块"——而不是"FooBarHandler"或"Order 服务"。
ADR conflicts: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: "contradicts ADR-0007 — but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.
ADR 冲突:如果某个候选方案与现有 ADR 矛盾,只有当摩擦足够真实、值得重新审视 ADR 时才提出。在卡片中清晰标记(例如警告提示:"与 ADR-0007 矛盾——但值得重新讨论,因为……")。不要列出 ADR 禁止的每一个理论上的重构。
See HTML-REPORT.md for the full HTML scaffold, diagram patterns, and styling guidance.
参见 HTML-REPORT.md 了解完整的 HTML 脚手架、图表模式及样式指南。
Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
暂不提出接口。文件写入后,询问用户:"你想探索哪一个?"
Once the user picks a candidate, run the /grilling skill to walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
用户选定候选方案后,运行 /grilling 技能与他们一起遍历设计树——约束条件、依赖关系、深化模块的形态、接缝背后的内容、哪些测试能存活。
Side effects happen inline as decisions crystallize — run the /domain-modeling skill to keep the domain model current as you go:
随着决策逐步明确,副作用会即时发生——运行 /domain-modeling 技能让领域模型在过程中保持最新:
CONTEXT.md? Add the term to CONTEXT.md. Create the file lazily if it doesn't exist.CONTEXT.md right there./codebase-design skill and use its design-it-twice parallel sub-agent pattern.CONTEXT.md 中未有的概念? 将该术语添加到 CONTEXT.md。如果文件不存在,懒加载创建。CONTEXT.md。/codebase-design 技能,使用其双重设计并行子代理模式。