improve-codebase-architecture

improve-codebase-architecture is a skill for Claude Code, Codex from devcxl/mattpocock-skills-zh. It costs 34 tokens per session (1,595 once invoked), scanned A, original, MIT.

A codebase review process that looks for architecture changes—ways to organize code—that could make future work easier. It presents possible improvements in an HTML report and examines the options you choose.

In plain words
What is it for?
Use it to inspect frequently changed areas, assess module boundaries and testability, identify refactoring opportunities, and review selected recommendations against project documentation.
Why use it?
It helps reveal code that is hard to understand, test, or change because related behavior is scattered or modules are poorly organized.

Skill for Claude CodeCodex

Written for Claude Code and Codex: disable-model-invocation in frontmatter, but also agents/openai.yaml present.

Part of the mattpocock-skills plugin — 37 skills shipped together

Good fit Use it to inspect frequently changed areas, assess module boundaries and testability, identify refactoring opportunities, and review selected recommendations against project documentation.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add devcxl/mattpocock-skills-zh --skill improve-codebase-architecture
Clone the repo
git clone --depth 1 https://github.com/devcxl/mattpocock-skills-zh

Made for: Claude Code, Codex.

Or install mattpocock-skills, the plugin that ships this one along with the rest of its 37 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for improve-codebase-architecture

README.md
[![agentmods](https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture/github.svg)](https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture)
Your own site
<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for improve-codebase-architecture

Your own site · 80×15
<a href="https://agentmods.dev/skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture"><img src="https://agentmods.dev/badge/skills/devcxl/mattpocock-skills-zh/improve-codebase-architecture.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,595 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00034 $0.01595
Opus 5 $0.00017 $0.00797
Sonnet 5 $0.00007 $0.00319
Haiku 4.5 $0.00003 $0.00160

Measured 9d ago against content hash d3d3400f7c04, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

improve-codebase-architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/engineering/improve-codebase-architecture/SKILL.md · 72 lines

How it starts

The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.

改进代码库架构

揭示架构摩擦点并提出深化机会——将浅层 module 转变为深层 module 的重构。目标是可测试性和 AI 可导航性。

本命令参考项目的领域模型,并基于共享的设计词汇:

  • 调用 Skill 工具并传入 "codebase-design" 获取架构词汇(moduleinterfacedepthseamadapterleveragelocality)及其原则(deletion test、"interface 就是 test surface"、"一个 adapter = 假设性 seam,两个 = 真实的")。在每个建议中严格使用这些术语——不要偏离到 "component"、"service"、"API" 或 "boundary"。
  • CONTEXT.md 中的领域语言为好的 seam 提供了命名;docs/adr/ 中的 ADR 记录了本命令不应重新讨论的决策。

流程

1. 探索

先确定范围再扫描——YAGNI。 加深一个模块的回报在于使未来对该模块的修改更容易,因此对最近变更的代码区域给予额外权重。在查看之前先决定看哪里

  • 如果用户指定了方向——一个模块、一个子系统、一个痛点——就采用它,并跳过下面的推断步骤。
  • 否则,回顾一段较长的提交历史(git log --oneline)来找到代码库的热点——那些反复出现的文件和区域——让这些路径首先吸引你的注意力。如果变更分散,没有明确的热点,就扩大范围。

首先阅读项目的领域术语表(CONTEXT.md)以及你将要接触的区域内任何 ADR。

然后生成一个子代理来遍历代码库。不要遵循僵化的启发式规则——有机地探索,并记录你在哪里遇到了摩擦:

  • 在哪些地方,理解一个概念需要在多个小模块之间来回跳转?
  • 哪些 module 是shallow的——interface 几乎和 implementation 一样复杂?
  • 哪些地方纯粹为了可测试性而提取了纯函数,但真正的 bug 却隐藏在它们的调用方式中(缺乏 locality)?
  • 哪些紧密耦合的 module 跨越了它们的 seam?
  • 代码库的哪些部分未经测试,或难以通过当前 interface 进行测试?

对你怀疑是 shallow 的任何内容应用deletion test:删除它会集中复杂性,还是仅仅移动它?"集中了"就是你想要的信号。

2. 将候选方案呈现为 HTML 报告

编写一个自包含的 HTML 文件到 OS 临时目录,这样不会在仓库中留下任何文件。从 $TMPDIR 解析临时目录,回退到 /tmp(在 Windows 上为 %TEMP%),并写入 <tmpdir>/architecture-review-<timestamp>.html,这样每次运行都会得到一个新文件。为用户打开它——Linux 上使用 xdg-open <path>,macOS 上使用 open <path>,Windows 上使用 start <path>——并告知用户绝对路径。

报告使用 Tailwind(通过 CDN) 进行布局和样式,并使用 Mermaid(通过 CDN) 绘制图表,在图形/流程/序列能可靠传达结构的地方使用。将 Mermaid 与手工制作的 CSS/SVG 视觉元素混合使用——当关系是图形形状时(调用图、依赖关系、序列)使用 Mermaid,当你想要更具编辑性的效果时(mass 图、截面图、折叠动画)使用手工构建的 div/SVG。每个候选方案都要有前后对比可视化。要有视觉冲击力。

每个候选方案渲染一张卡片,包含:

  • 文件——涉及哪些文件/module
  • 问题——当前架构为何造成摩擦
  • 方案——用通俗语言描述会发生什么变化
  • 收益——用 locality 和 leverage 的术语解释,以及测试会如何改进
  • 前后对比图——并排展示,自定义绘制,说明 shallowness 和 deepening 效果
  • 推荐强度——Strong(强烈推荐)、Worth exploring(值得探索)、Speculative(推测性),渲染为 badge

报告以最佳推荐部分结尾:你会先处理哪个候选方案以及原因。

对 CONTEXT.md 使用领域词汇,对架构使用 /codebase-design 词汇。 如果 CONTEXT.md 定义了 "Order",就说 "Order intake module"——而不是 "FooBarHandler",也不是 "Order service"。

Read the full file on GitHub · 72 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 72 lines · 34 tokens per session scan A d3d3400f7c04

Subscribe to this mod's changes

improve-codebase-architecture is a skill published in the GitHub repository devcxl/mattpocock-skills-zh (329 stars, last pushed 4d ago), licensed MIT. It adds 34 tokens to every session and 1,595 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.