improve-codebase-architecture

A review method for finding places where a DGame codebase can be reorganised into clearer, more self-contained modules. A module is a piece of code with an interface that others use and an internal implementation.

In plain words
What is it for?
Use it to identify refactoring opportunities, bring scattered resource, configuration, event, and module access into one place, improve layer placement, and make pure game logic easier to test.
Why use it?
It helps expose tightly connected code and concentrate changes, bugs, and knowledge in fewer places, making the project easier to maintain and navigate.

Skill for Claude CodeCodex

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/amanidawn/dgame/improve-codebase-architecture
Any agent
npx skills add AmaniDawn/DGame --skill improve-codebase-architecture
Clone the repo
git clone --depth 1 https://github.com/AmaniDawn/DGame

Made for: Claude Code, Codex.

Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,577 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.00090 $0.02577
Opus 5 $0.00045 $0.01288
Sonnet 5 $0.00018 $0.00515
Haiku 4.5 $0.00009 $0.00258

Measured 3d ago against content hash fd0b8a681045, 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 3d 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.

.claude/skills/improve-codebase-architecture/SKILL.md · 92 lines

How it starts

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

Improve Codebase Architecture

暴露 DGame 架构摩擦并提出加深机会——把浅模块变为深模块。DGame 是热更手游工程,没有普遍的单元测试文化,所以加深的主要收益是:分层局部性(变更、bug、知识集中在一处)、AI 可导航性(少跳转即可理解一个概念)、以及 DGame 特有的收口(资源、配置、事件、模块访问、纯逻辑)。可测试性作为收益仅在逻辑能下沉到 GameBattle 纯逻辑域时才成立。

术语表

在每个建议中精确使用这些术语。一致的语言是关键——不要滑向"component"、"service"、"API"或"boundary"。完整定义见 LANGUAGE.md

  • Module(模块) — 任何具有接口和实现的东西(函数、类、程序集、模块门面项)。
  • Interface(接口) — 调用者使用模块所需知道的一切:类型、不变量、错误模式、顺序、配置。不仅仅是类型签名。
  • Implementation(实现) — 内部的代码。
  • Depth(深度) — 接口处的杠杆:少量接口背后的大量行为。Deep(深) = 高杠杆。Shallow(浅) = 接口几乎与实现一样复杂。
  • Seam(接缝) — 接口所在的位置;一个可以在不原地编辑的情况下改变行为的地方。(用这个词,不是"boundary"。)
  • Adapter(适配器) — 在接缝处满足接口的具体实现。
  • Leverage(杠杆) — 调用者从深度中获得的收益。
  • Locality(局部性) — 维护者从深度中获得的收益:变更、bug、知识集中在一个地方。

关键原则(完整列表见 LANGUAGE.md):

  • 删除测试(思想实验,非真删代码):想象删除该模块。如果复杂性消失了,它就是传递模块。如果复杂性重新出现在 N 个调用者身上,它就在发挥价值。
  • 接口就是收口面。 在 DGame,一个好接缝是资源/配置/事件/模块访问被收口的那一点。
  • 一个适配器 = 假设的接缝。两个适配器 = 真正的接缝。

本技能依据 DGame 的分层规范与编码红线,不重新争论它们。dgame-dev skill 的 references 为好接缝命名并界定落位;CLAUDE.md 的核心原则是不可违背的红线;ADR 记录已定的决策。

流程

1. 探索

先加载 DGame 的分层约束与红线——这是本技能与项目对齐的关键,不可跳过

  • 触发 dgame-dev skill 获取相关主题(分层落位 → project-map.md;四层单向依赖、程序集边界、启动链路、GameModule 门面、ConfigMgr 封装 → client-architecture-claude.md / client-modules-claude.md;再按涉及主题拉取 UI、事件、资源、红点、Luban 等 reference)。这些是命名接缝、判断分层归属、识别 GameModule.XXX 访问约定的权威来源。
  • 阅读 CLAUDE.md 的核心原则(编码红线):分层落位、优先复用 TEngine 二次封装、GameModule 访问、异步优先(UniTask)、资源必须成对释放、事件解耦(GameEventDriver/EEventGroup)。违背这些红线的浅性,是最高优先的加深目标。
  • 阅读你将涉及区域中的任何 ADR(docs/adr/,若存在)。

然后用 Agent 工具配合 subagent_type=Explore 遍历代码库。有机地探索,记录你感受到摩擦的地方。DGame 中特别值得留意的浅模块形态:

  • GameModule 门面里只做一次静态转发、几乎无逻辑的入口——它是杠杆点,也是浅性容易堆积的地方。
  • ConfigMgr 封装里只透传 TbXXX / ConfigSystem.Instance.Tables 的方法,或反过来:本该收口到 ConfigMgr 的配置访问却散落在多个 UI/模块里(配置跨接缝泄漏)。
  • UI 层UIWindow/UIWidget/子页面只做透传的薄壳;或 UI 直接读配置表、直接加载资源,把本该在下层的知识拉进窗口脚本。
  • 资源加载/卸载散落:加载与释放不成对、分散在多处,没有一个模块持有资源生命周期(无局部性)。
  • 事件封装单调用点IEvent 里只有一个发送者一个接收者的封装,删除它复杂性并不集中。
  • 可下沉的纯逻辑:混在 GameLogic(依赖 Unity/UI/资源)里的纯计算,本可下沉到 GameBattle 成为进程内可测深模块,却因和表现层缠绕而无法测试。
  • 红点树:节点定义、聚合与业务判断散落,未收口到 RedDotModule 现有入口。

Read the full file on GitHub · 92 lines

Files

What ships with it

4 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. 3d ago First seen · 92 lines · 90 tokens per session scan A fd0b8a681045

Subscribe to this mod's changes

improve-codebase-architecture is a skill published in the GitHub repository AmaniDawn/DGame (149 stars, last pushed 9d ago), licensed MIT. It adds 90 tokens to every session and 2,577 once invoked, about $0.0005 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

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 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