跳到正文
Skillpedia
技术文档48k · #4097

c4-architecture-c4-architecture

它能做什么

这个工具会为你的代码架构绘制一张详细的地图,展示程序各个部分之间的连接关系。它从最小的细节开始,自下而上地分析代码,逐步构建出全局视图。

适用场景

  • ✓当你开始一个新的软件项目,希望记录其结构时。
  • ✓当你需要理解现有软件系统的组织方式时。
  • ✓当你想向他人讲解代码架构时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/c4-architecture-c4-architecture/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/c4-architecture-c4-architecture/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“为我的代码仓库生成 C4 架构文档。”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具会检查代码的每个部分,记录函数和类。然后将这些部分分组为逻辑组件,再组合成容器(如应用程序或数据库),最后形成整个系统的上下文。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

C4 Architecture Documentation Workflow

Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.

[Extended thinking: This workflow implements a complete C4 architecture documentation process following the C4 model (Context, Container, Component, Code). It uses a bottom-up approach, starting from the deepest code directories and working upward, ensuring every code element is documented before synthesizing into higher-level abstractions. The workflow coordinates four specialized C4 agents (Code, Component, Container, Context) to create a complete architectural documentation set that serves both technical and non-technical stakeholders.]

Use this skill when

  • Working on c4 architecture documentation workflow tasks or workflows
  • Needing guidance, best practices, or checklists for c4 architecture documentation workflow

Do not use this skill when

  • The task is unrelated to c4 architecture documentation workflow
  • You need a different domain or tool outside this scope

Instructions

  • Clarify goals, constraints, and required inputs.
  • Apply relevant best practices and validate outcomes.
  • Provide actionable steps and verification.

Overview

This workflow creates comprehensive C4 architecture documentation following the official C4 model by:

  1. Code Level: Analyzing every subdirectory bottom-up to create code-level documentation
  2. Component Level: Synthesizing code documentation into logical components within containers
  3. Container Level: Mapping components to deployment containers with API documentation (shows high-level technology choices)
  4. Context Level: Creating high-level system context with personas and user journeys (focuses on people and software systems, not technologies)

Note: According to the C4 model, you don't need to use all 4 levels of diagram - the system context and container diagrams are sufficient for most software development teams. This workflow generates all levels for completeness, but teams can choose which levels to use.

All documentation is written to a new C4-Documentation/ directory in the repository root.

Phase 1: Code-Level Documentation (Bottom-Up Analysis)

1.1 Discover All Subdirectories

  • Use codebase search to identify all subdirectories in the repository
  • Sort directories by depth (deepest first) for bottom-up processing
  • Filter out common non-code directories (node_modules, .git, build, dist, etc.)
  • Create list of directories to process

1.2 Process Each Directory (Bottom-Up)

For each directory, starting from the deepest:

  • Use Task tool with subagent_type="c4-architecture::c4-code"

  • Prompt: | Analyze the code in directory: [directory_path]

    Create comprehensive C4 Code-level documentation following this structure:

    1. Overview Section:
      • Name: [Descriptive name for this code directory]
      • Description: [Short description of what this code does]
      • Location: [Link to actual directory path relative to repo root]
      • Language: [Primary programming language(s) used]
      • Purpose: [What this code accomplishes]
    2. Code Elements Section:
      • Document all functions/methods with complete signatures:
        • Function name, parameters (with types), return type
        • Description of what each function does
        • Location (file path and line numbers)
        • Dependencies (what this function depends on)
      • Document all classes/modules:
        • Class name, description, location
        • Methods and their signatures
        • Dependencies
    3. Dependencies Section:
      • Internal dependencies (other code in this repo)
      • External dependencies (libraries, frameworks, services)
    4. Relationships Section:
      • Optional Mermaid diagram if relationships are complex

    Save the output as: C4-Documentation/c4-code-[directory-name].md Use a sanitized directory name (replace / with -, remove special chars) for the filename.

    Ensure the documentation includes:

    • Complete function signatures with all parameters and types
    • Links to actual source code locations
    • All dependencies (internal and external)
    • Clear, descriptive names and descriptions
  • Expected output: c4-code-<directory-name>.md file in C4-Documentation/

  • Context: All files in the directory and its subdirectories

…

常见问题

什么是 C4 模型?

C4 模型是一种以四个层次描述软件架构的方法,分别是上下文(Context)、容器(Container)、组件(Component)和代码(Code)。它有助于可视化和沟通软件结构。

为什么要“自下而上”分析?

“自下而上”分析意味着从最细的细节(代码)开始,逐层向上。这样可以确保不遗漏任何内容,并让文档建立在详实的细节基础之上。

生成的文档会保存在哪里?

生成的文档会保存在仓库根目录下一个名为 `C4-Documentation/` 的新文件夹中。

详情

作者的原始描述

Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4097
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能