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

c4-code

它能做什么

这个工具分析代码文件夹,生成详细文档,说明函数和类如何组织、使用哪些数据以及彼此如何连接。它有助于理解程序的内部结构。

适用场景

  • ✓当你开始处理代码的新部分时。
  • ✓当你需要理解某段特定代码如何工作时。
  • ✓当你为其他开发者记录项目文档时。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“为项目的 'utils' 文件夹生成文档,展示其中的函数、参数和依赖关系。”

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

工作原理

这个工具会检查指定文件夹中的代码文件,识别函数、类、它们的参数、返回值,以及它们调用了代码中的哪些其他部分。然后把这些信息清晰地整理出来。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

C4 Code Level: [Directory Name]

Use this skill when

  • Working on c4 code level: [directory name] tasks or workflows
  • Needing guidance, best practices, or checklists for c4 code level: [directory name]

Do not use this skill when

  • The task is unrelated to c4 code level: [directory name]
  • 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

  • Name: [Descriptive name for this code directory]
  • Description: [Short description of what this code does]
  • Location: [Link to actual directory path]
  • Language: [Primary programming language(s)]
  • Purpose: [What this code accomplishes]

Code Elements

Functions/Methods

  • functionName(param1: Type, param2: Type): ReturnType
    • Description: [What this function does]
    • Location: [file path:line number]
    • Dependencies: [what this function depends on]

Classes/Modules

  • ClassName
    • Description: [What this class does]
    • Location: [file path]
    • Methods: [list of methods]
    • Dependencies: [what this class depends on]

Dependencies

Internal Dependencies

  • [List of internal code dependencies]

External Dependencies

  • [List of external libraries, frameworks, services]

Relationships

Optional Mermaid diagrams for complex code structures. Choose the diagram type based on the programming paradigm. Code diagrams show the internal structure of a single component.

Object-Oriented Code (Classes, Interfaces)

Use classDiagram for OOP code with classes, interfaces, and inheritance:

---
title: Code Diagram for [Component Name]
---
classDiagram
    namespace ComponentName {
        class Class1 {
            +attribute1 Type
            +method1() ReturnType
        }
        class Class2 {
            -privateAttr Type
            +publicMethod() void
        }
        class Interface1 {
            <<interface>>
            +requiredMethod() ReturnType
        }
    }

    Class1 ..|> Interface1 : implements
    Class1 --> Class2 : uses

### Functional/Procedural Code (Modules, Functions)

For functional or procedural code, you have two options:

**Option A: Module Structure Diagram** - Use `classDiagram` to show modules and their exported functions:

```mermaid
---
title: Module Structure for [Component Name]
---
classDiagram
    namespace DataProcessing {
        class validators {
            <<module>>
            +validateInput(data) Result~Data, Error~
            +validateSchema(schema, data) bool
            +sanitize(input) string
        }
        class transformers {
            <<module>>
            +parseJSON(raw) Record
            +normalize(data) NormalizedData
            +aggregate(items) Summary
        }
        class io {
            <<module>>
            +readFile(path) string
            +writeFile(path, content) void
        }
    }

    transformers --> validators : uses
    transformers --> io : reads from
```

**Option B: Data Flow Diagram** - Use `flowchart` to show function pipelines and data transformations:

```mermaid
---
title: Data Pipeline for [Component Name]
---
flowchart LR
    subgraph Input
        A[readFile]
    end
    subgraph Transform
        B[parseJSON]
        C[validateInput]
        D[normalize]
        E[aggregate]
    end
    subgraph Output
        F[writeFile]
    end

    A -->|raw string| B
    B -->|parsed data| C
    C -->|valid data| D
    D -->|normalized| E
    E -->|summary| F
```

**Option C: Function Dependency Graph** - Use `flowchart` to show which functions call which:

```mermaid
---
title: Function Dependencies for [Component Name]
---
flowchart TB
    subgraph Public API
        processData[processData]
        exportReport[exportReport]
    end
    subgraph Internal Functions
        validate[validate]
        transform[transform]
        format[format]
        cache[memoize]
    end
    subgraph Pure Utilities
        compose[compose]
        pipe[pipe]
        curry[curry]
    end

    processData --> validate
    processData --> transform
    processData --> cache
    transform --> compose
    transform --> pipe
    exportReport --> format
    exportReport --> processData
```

### Choosing the Right Diagram


…
常见问题

什么是 'C4 代码级别'?

这是一种通过关注函数和类等内部细节来记录代码的方式,有助于理解某个组件的结构。

它能生成哪些类型的图表?

根据代码风格,它可以为面向对象的代码生成类图,为函数式或过程式代码生成流程图或模块结构图。

使用这个工具需要了解 C4 模型吗?

不一定。这个工具关注代码细节,这是 C4 模型中的一个层次,但你不需要成为该模型的专家也能使用。

详情

作者的原始描述

Expert C4 Code-level documentation specialist. Analyzes code directories to create comprehensive C4 code-level documentation including function signatures, arguments, dependencies, and code structure.

repo: sickn33/agentic-awesome-skills

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能