improve-codebase-architecture

A code-architecture review process that finds places where a codebase can be reorganized into clearer modules with simpler interfaces. A module is a piece of code with an outside-facing way to use it, such as a function, class, package, or subsystem.

In plain words
What is it for?
It helps inspect a codebase, identify shallow or pass-through modules, propose ways to combine or separate them, improve testing boundaries, and design and implement an approved refactoring.
Why use it?
It helps locate tightly connected, hard-to-test, or hard-to-understand code before changing it, and requires the developer to choose and approve a refactoring opportunity first.

Skill for Claude CodeCodexCursor

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.

agentmods
npx agentmods add skills/programmeranthony/expert-coding-harness/improve-codebase-architecture
Any agent
npx skills add ProgrammerAnthony/Expert-Coding-Harness --skill improve-codebase-architecture
Clone the repo
git clone --depth 1 https://github.com/ProgrammerAnthony/Expert-Coding-Harness

Made for: Claude Code, Codex, Cursor.

Per session 114 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 999 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00114 $0.00999
Opus 5 $0.00057 $0.00500
Sonnet 5 $0.00023 $0.00200
Haiku 4.5 $0.00011 $0.00100

Measured 2d ago against content hash d97445fcb6e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 2d 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.

.cursor/skills/improve-codebase-architecture/SKILL.md · 67 lines

What it actually says

改进代码库架构

发现架构摩擦点,提出深化机会——将浅模块变为深模块的重构。目标:可测试性与 AI 可导航性。

使用 references/LANGUAGE.md 中的词汇表,所有建议中严格使用这些术语。

核心词汇(速查)

  • 模块(Module):有接口和实现的任何东西(函数、类、包、切片)。
  • 接口(Interface):调用者需要了解的一切:类型、不变量、错误模式、顺序、配置。不只是类型签名。
  • 深度(Depth):接口背后的杠杆——大量行为隐藏在小接口后面是,接口复杂度接近实现复杂度是
  • 接缝(Seam):可以不编辑内部代码而改变行为的地方。
  • 适配器(Adapter):在接缝处满足接口的具体实现。
  • 删除测试(Deletion test):想象删掉这个模块。复杂度消失了?那它是透传层。复杂度在 N 个调用者处重新出现?那它值得存在。

流程

1. 探索

先读取项目的领域词汇表(CONTEXT.md、UBIQUITOUS_LANGUAGE.md 等)和相关 ADR。

使用 Explore 子代理遍历代码库。有机探索,记录摩擦点:

  • 理解一个概念需要在多个小模块间来回跳转的地方?
  • 接口复杂度接近实现的模块?
  • 为可测试性提取出来的纯函数,但真正的 Bug 隐藏在调用方式中(无局部性)?
  • 紧耦合模块跨接缝泄漏的地方?
  • 未测试或难以通过当前接口测试的代码?

对可疑的浅模块做删除测试:删掉它会集中复杂度,还是只是移动了它?"集中"是你要找的信号。

2. 提出候选项

呈现编号的深化机会列表。每个候选项包含:

  1. 模块标识:名称 + 文件路径
  2. 浅度诊断:为什么它是浅的(接口太多、散布在 N 个调用者、透传层、测试只能通过实现细节)
  3. 深化思路:合并哪些模块、接缝放哪里、哪些依赖需要端口
  4. 可测试性收益:深化后如何改善测试(更少 Mock、直接可测接口、局部性更好)
  5. 工作量估算:小/中/大(不做具体行数预估)

在提出候选项时停下,等待用户选择。 不要直接开始重构。

3. 为选定候选项设计接口(可选)

若用户想要对选定候选项探索多种接口设计,使用并行子代理模式——详见 references/INTERFACE-DESIGN.md

4. 实施

用户选定候选项并批准接口设计后:

  1. 参考 references/DEEPENING.md 制定具体深化策略
  2. 编写新的集成测试,通过新接口测试行为
  3. 合并模块,删掉旧的浅层测试(它们已成废代码)
  4. 确认所有测试通过,删除任何遗留的原型代码

参考文档

Files

What ships with it

3 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. 2d ago First seen · 67 lines · 114 tokens per session scan A d97445fcb6e7

Subscribe to this mod's changes

improve-codebase-architecture is a skill published in the GitHub repository ProgrammerAnthony/Expert-Coding-Harness (235 stars, last pushed 3mo ago), licensed MIT. It adds 114 tokens to every session and 999 once invoked, about $0.0006 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.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens