Communitygithub.com

cdcoonce/优化代码库架构

像AI一样探索代码库,发现架构摩擦点,寻找改善可测试性的机会,并将模块深化重构提议作为GitHub issue RFC提出。

优化代码库架构 是什么?

该技能旨在帮助开发者以AI的视角系统地分析和改进代码库架构。其核心概念源于John Ousterhout的《软件设计哲学》中的“深度模块”——即拥有小接口但实现复杂、隐藏大量内部细节的模块。深度模块更具可测试性,更易于AI导航。技能通过一个七个步骤的结构化流程工作:首先自由探索代码库,记录下理解困难或模块耦合严重等认知摩擦点;然后列出候选的模块深化机会,并与用户协商优先级;接着由用户在后台并行启动多个子代理,为同一个模块设计出多个截然不同的接口方案(例如最小接口、最大灵活性、优化常见调用场景等);最后汇总方案、给出推荐,并由用户确认后自动生成一个GitHub issue作为重构RFC。该技能支持所有代码库平台(通过GitHub集成),特别适合需要提升代码质量、减少集成风险或为AI工具清理代码路径的场景。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/cdcoonce/Portfolio_Website/tree/HEAD/.claude/skills/improve-codebase-architecture

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

改善代码库架构

以AI的方式探索代码库,发现架构中的摩擦点,寻找改善可测试性的机会,并将模块深化重构提议作为GitHub issue RFC提出。

一个深度模块(John Ousterhout,《软件设计哲学》)的特点是:接口小而实现复杂。深度模块更易于测试,更利于AI导航,并且允许你在边界处而不是内部进行测试。

流程

1. 探索代码库

使用 Agent 工具,并设置 subagent_type=Explore 来自如地导航代码库。不要遵循僵化的启发式规则——而是有机地探索,并记录下你遇到摩擦的地方:

  • 哪里需要你在多个小文件之间来回跳转才能理解一个概念?
  • 哪些模块的接口和实现几乎一样复杂,显得过于“浅薄”?
  • 哪些纯函数仅仅为了可测试性而被提取出来,但真正的bug却隐藏在它们的调用方式中?
  • 哪些紧密耦合的模块在它们之间的接缝处带来了集成风险?
  • 代码库的哪些部分未被测试,或者难以测试?

你所遇到的摩擦本身就是信号。

2. 呈现候选方案

列出一个编号的深化机会列表。对于每个候选方案,展示:

  • 集群:涉及哪些模块/概念
  • 耦合原因:共享的类型、调用模式、对某个概念的共同所有权
  • 依赖类别:参见 REFERENCE.md 中的四个类别
  • 测试影响:哪些现有测试将被边界测试所取代

不要在此阶段提出接口。询问用户:“你想深入探讨这些中的哪一个?”

3. 用户选择一个候选方案

4. 勾勒问题空间

在生成子代理之前,为用户撰写一份关于所选候选方案的问题空间说明:

  • 任何新接口必须满足的约束条件
  • 它需要依赖的依赖项
  • 一个粗略的、用于说明约束的代码草图——这并非提案,只是让约束具体化的方式

向用户展示这些内容,然后立即进入第5步。用户在阅读、思考问题的同时,子代理们会并行工作。

5. 设计多种接口

使用 Agent 工具并行生成3个或以上的子代理。每个子代理都必须为深化后的模块设计一个完全不同的接口。

为每个子代理提供一个独立的技术简报(包含文件路径、耦合细节、依赖类别、以及要隐藏的内容)。这个简报与第4步中面向用户的说明无关。为每个代理指定不同的设计约束:

  • 代理1:“最小化接口——目标是最多1-3个入口点”
  • 代理2:“最大化灵活性——支持多种用例和扩展”
  • 代理3:“为最常见的调用方优化——让默认情况变得简单明了”
  • 代理4(如适用):“围绕端口与适配器模式设计跨边界依赖”

每个子代理输出:

  1. 接口签名(类型、方法、参数)
  2. 使用示例,展示调用方如何使用
  3. 它内部隐藏的复杂性
  4. 依赖策略(如何处理依赖项——参见 REFERENCE.md)
  5. 权衡取舍

将设计方案依次呈现,然后用文字进行比较。

比较之后,给出你自己的推荐:你认为哪个设计最强,以及原因。如果不同设计的元素可以很好地组合,提出一个混合方案。要有主见——用户想要的是一个有力的观点,而不仅仅是一个菜单供选择。

6. 用户选择一个接口(或接受推荐)

7. 创建GitHub issue

使用 gh issue create 创建一个重构RFC作为GitHub issue。使用 REFERENCE.md 中的模板。不要在创建之前要求用户审核——直接创建并分享URL。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cdcoonce/Portfolio_Website

Git commit workflow with enforced conventional commit style. Use when Claude needs to stage and commit changes, craft commit messages, or the user asks to commit, make a commit, or save their work. Ensures consistent commit message format, proper scoping, and atomic commits across the project.

cdcoonce/Portfolio_Website

AI-powered code quality analysis for Python, Markdown, and Mermaid diagrams. Use this skill when: (1) reviewing code for quality issues, (2) checking Python files for PEP8 violations, unused code, missing type hints, docstring problems, complexity issues, or potential runtime errors, (3) validating Markdown documentation for broken links, heading structure, or formatting issues, (4) validating Mermaid diagram syntax, (5) the user asks for a "code review" or "quality check", (6) analyzing code snippets pasted in conversation, or (7) suggesting and applying fixes for code quality issues.

cdcoonce/Portfolio_Website

Deploy the portfolio chat agent Lambda function to AWS. Use when the user asks to deploy, redeploy, push to Lambda, update the chat agent, or after updating context files or lambda_function.py. Rebuilds the knowledge base, packages dependencies, and deploys to AWS Lambda.

cdcoonce/Portfolio_Website

Generate multiple radically different interface designs for a module using parallel sub-agents. Use when user wants to design an API, explore interface options, compare module shapes, or mentions "design it twice".

cdcoonce/Portfolio_Website

Orchestrate the full GitHub-issues-driven development lifecycle. 7-phase pipeline from brainstorm through PR with state tracking and cross-conversation resume. Use when user says "dev cycle", "development workflow", "full development pipeline", or invokes /dev-cycle.

cdcoonce/Portfolio_Website

Production Python coding standards with automatic version detection (3.10-3.13). Use when writing, reviewing, or refactoring Python to ensure adherence to modern type syntax, LBYL exception handling, pathlib operations, ABC-based interfaces, and production-tested patterns. Not Dagster-specific - applies to any Python project.

cdcoonce/Portfolio_Website

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.

cdcoonce/Portfolio_Website

GitHub CLI (gh) integration for managing issues, pull requests, branches,

cdcoonce/Portfolio_Website

Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".

cdcoonce/Portfolio_Website

CEO/founder-mode plan review. Rethink the problem, find the 10-star product, challenge premises, expand scope when it creates a better product. Three modes: SCOPE EXPANSION (dream big), HOLD SCOPE (maximum rigor), SCOPE REDUCTION (strip to essentials). Use when the user asks for a plan review, CEO review, mega review, or wants a plan challenged/stress-tested before implementation.

cdcoonce/Portfolio_Website

Break a PRD into independently-grabbable GitHub issues using tracer-bullet vertical slices. Use when user wants to convert a PRD to issues, create implementation tickets, or break down a PRD into work items.

cdcoonce/Portfolio_Website

Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved as a local Markdown file in docs/plans/. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".

cdcoonce/Portfolio_Website

Generate or update the `.claude/docs/project.md` file that gives Claude project-specific context. Use this skill when the user asks to create, update, regenerate, or refresh project context, or says things like "update project.md", "generate project context", "this repo needs a project.md", or "Claude doesn't know about this project". Also trigger when onboarding Claude to a new repository for the first time.

cdcoonce/Portfolio_Website

Generate comprehensive, high-quality README.md files for code repositories. Use this skill whenever the user asks to create, write, generate, update, or improve a README for any project or repository. Also trigger when the user says things like "document this project", "write docs for this repo", "this repo needs a README", "help me onboard developers to this codebase", or asks for project documentation in markdown. Even if the user just says "README" or "readme" in the context of a codebase, use this skill.

cdcoonce/Portfolio_Website

Create a detailed refactor plan with tiny commits via user interview, then file it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.

cdcoonce/Portfolio_Website

Set up pre-commit hooks for the current repo. Use when user wants to add pre-commit hooks, configure commit-time linting, formatting, type checking, or testing. Triggers on "pre-commit", "git hooks", "linting hooks", or /setup-pre-commit.

cdcoonce/Portfolio_Website

Test-driven development with red-green-refactor loop. Use when user wants to build features or fix bugs using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.

cdcoonce/Portfolio_Website

Triage a bug or issue by exploring the codebase to find root cause, then create a GitHub issue with a TDD-based fix plan. Use when user reports a bug, wants to file an issue, mentions "triage", or wants to investigate and plan a fix for a problem.

cdcoonce/Portfolio_Website

Rewrites the prose sections of wiki pages in-place. Reads source files to understand current context, then updates only the content inside <!-- claude:prose --> ... <!-- claude:prose:end --> markers. Never touches <!-- generated:start --> ... <!-- generated:end --> blocks. Supports targeting a single page with /update-wiki {PageName}.

cdcoonce/Portfolio_Website

Create a PRD through user interview, codebase exploration, and module design, then submit as a GitHub issue. Use when user wants to write a PRD, create a product requirements document, or plan a new feature.

相关技能