清洁架构 logo

清洁架构

Organization
microwind
清洁架构

通过依赖规则将系统分为同心圆层次,内层不依赖外层,实现业务逻辑与技术细节的完全分离。

Overview

Publishermicrowind
Repositoryai-skills
Skill name清洁架构
Stars
93
Forks
25
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by microwind on GitHub. Read the source before you install it.

Installation

Install the 清洁架构 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/microwind/ai-skills/tree/main/domain-driven-design/clean-architecture
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/microwind/ai-skills.git /tmp/ai-skills
mkdir -p .claude/skills
cp -r /tmp/ai-skills/domain-driven-design/clean-architecture .claude/skills/microwind-59
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable 清洁架构 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads 清洁架构 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so 清洁架构 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

清洁架构 (Clean Architecture)

概述

清洁架构由 Robert C. Martin(Uncle Bob)提出,核心是依赖规则:源码依赖只能指向内层。

┌─────────────────────────────────────────┐
│  Frameworks & Drivers (最外层)           │
│  Web框架、数据库、UI                      │
│  ┌─────────────────────────────────┐    │
│  │  Interface Adapters              │    │
│  │  控制器、Gateway、Presenter       │    │
│  │  ┌─────────────────────────┐    │    │
│  │  │  Application (Use Cases) │    │   │
│  │  │  应用业务规则             │    │    │
│  │  │  ┌─────────────────┐    │    │    │
│  │  │  │  Entities        │    │    │   │
│  │  │  │  企业业务规则     │    │    │    │
│  │  │  └─────────────────┘    │    │    │
│  │  └─────────────────────────┘    │    │
│  └─────────────────────────────────┘    │
└─────────────────────────────────────────┘

依赖方向:外 → 内(箭头永远指向中心)

代码示例

java
// ===== 最内层:Entities(领域模型) =====
public class Order {
    private OrderId id;
    private List<OrderItem> items;
    private OrderStatus status;

    public void place() {
        if (items.isEmpty()) throw new DomainException("订单不能为空");
        this.status = OrderStatus.PLACED;
    }
}

// ===== Use Cases 层 =====
// 输入端口
public interface PlaceOrderUseCase {
    PlaceOrderOutput execute(PlaceOrderInput input);
}

// 输出端口
public interface OrderGateway {
    Order findById(String id);
    void save(Order order);
}

// 用例实现
public class PlaceOrderInteractor implements PlaceOrderUseCase {
    private final OrderGateway orderGateway;

    @Override
    public PlaceOrderOutput execute(PlaceOrderInput input) {
        Order order = orderGateway.findById(input.getOrderId());
        order.place();
        orderGateway.save(order);
        return new PlaceOrderOutput(order.getId(), order.getStatus());
    }
}

// ===== Interface Adapters 层 =====
@RestController
public class OrderController {
    private final PlaceOrderUseCase placeOrder;

    @PostMapping("/orders/{id}/place")
    public ResponseEntity<?> place(@PathVariable String id) {
        var output = placeOrder.execute(new PlaceOrderInput(id));
        return ResponseEntity.ok(OrderResponse.from(output));
    }
}

// ===== Frameworks 层 =====
@Repository
public class JpaOrderGateway implements OrderGateway {
    @Override
    public Order findById(String id) { /* JPA 实现 */ }
    @Override
    public void save(Order order) { /* JPA 实现 */ }
}

依赖规则

✅ 合法依赖:
Controller → UseCase → Entity
JpaGateway → OrderGateway(interface) ← UseCase

❌ 非法依赖:
Entity → JpaRepository(内层依赖外层)
UseCase → Spring annotation(业务依赖框架)
Entity → HttpClient(领域依赖基础设施)

与六边形架构的对比

维度清洁架构六边形架构
层次4层同心圆内外两区(核心 + 适配器)
重点依赖规则端口与适配器
Entity层独立的最内层包含在核心中
本质相同理念,不同表达相同理念,不同表达

最佳实践

  1. Entity 层零依赖 — 纯 Java/Python 对象,不引入任何框架
  2. Use Case 通过接口访问外部 — Gateway 接口定义在 Use Case 层
  3. 数据跨层传递用 DTO — 不让 Entity 泄漏到外层
  4. 框架是细节 — Spring、Django 等都在最外层

与其他DDD概念的关系

概念关系
六边形架构同源理念,清洁架构更细化层次
领域模型Entity 层对应领域模型
应用服务Use Case 层对应应用服务
仓储Gateway 对应仓储模式

总结

核心:依赖只能从外向内,业务逻辑在最内层,不依赖任何技术细节。

实践:Entity → Use Case → Adapter → Framework,每层通过接口与外层通信。

Frequently asked questions

What does the 清洁架构 AI skill do?

通过依赖规则将系统分为同心圆层次,内层不依赖外层,实现业务逻辑与技术细节的完全分离。

Why use 清洁架构 on TypingMind?

Because you install it once and use it with any model. 清洁架构 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install 清洁架构 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/microwind/ai-skills/tree/main/domain-driven-design/clean-architecture. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use 清洁架构?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with 清洁架构?

As many as you like. As long as a model supports skills, you can use 清洁架构 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the 清洁架构 AI skill free?

It is published on GitHub by microwind. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇