Skip to content
Agentmart
Submit a tool

architecture-patterns

架构模式 - 后端架构模式,用于构建可维护、可测试的系统:整洁架构、六边形架构和领域驱动设计。适用于设计新后端系统、重构单体、建立架构标准、创建可测试代码库或规划微服务分解。

Skill by lza6

IndexedApache-2.0★ 8
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/lza6-architecture-patterns

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

架构模式 - 后端架构模式,用于构建可维护、可测试的系统:整洁架构、六边形架构和领域驱动设计。适用于设计新后端系统、重构单体、建立架构标准、创建可测试代码库或规划微服务分解。

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Python package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/architecture-patterns

What's inside

Skill name
architecture-patterns
Description
架构模式 - 后端架构模式,用于构建可维护、可测试的系统:整洁架构、六边形架构和领域驱动设计。适用于设计新后端系统、重构单体、建立架构标准、创建可测试代码库或规划微服务分解。
License
Apache-2.0
Instructions
351 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts

Files (22)

  • origin.json · .clawhub/
  • README.md
  • SKILL.md
  • _meta.json
  • patterns.csv · data/
  • clean-architecture-guide.md · references/
  • ddd-tactical-patterns.md · references/
  • hexagonal-architecture-guide.md · references/
  • search.py · scripts/
  • README.md · templates/clean-architecture/
  • user.controller.ts · templates/clean-architecture/src/adapters/controllers/
  • user.entity.ts · templates/clean-architecture/src/domain/entities/
  • repository.interface.ts · templates/clean-architecture/src/domain/interfaces/
  • create-user.use-case.ts · templates/clean-architecture/src/use-cases/
  • README.md · templates/ddd/
  • order.aggregate.ts · templates/ddd/src/domain/aggregates/
  • order-submitted.event.ts · templates/ddd/src/domain/events/
  • money.value-object.ts · templates/ddd/src/domain/value-objects/
  • README.md · templates/hexagonal/
  • stripe-payment.adapter.ts · templates/hexagonal/src/adapters/secondary/
  • order.service.ts · templates/hexagonal/src/domain/
  • payment-gateway.port.ts · templates/hexagonal/src/ports/outbound/

SKILL.md (first lines)

# 架构模式

## 是什么
用于构建可维护、可测试系统的后端架构模式:整洁架构(Clean Architecture)、六边形架构(Hexagonal Architecture)和领域驱动设计(Domain-Driven Design)。

## 何时使用
- 从零设计新的后端系统
- 重构单体以提高可维护性
- 为团队建立架构标准
- 创建可测试、可模拟的代码库
- 规划微服务拆分

## 关键词
clean architecture, hexagonal, ports and adapters, DDD, domain-driven design, layers, entities, use cases, repositories, aggregates, bounded contexts

---

## 决策框架:选择哪种模式?

| 场景 | 推荐模式 |
|-----------|---------------------|
| 简单的 CRUD 应用 | 不需要(过度设计) |
| 中等复杂度,团队标准化 | 整洁架构 |
| 多个频繁变化的外部集成 | 六边形架构(端口与适配器) |
| 具有大量业务规则的复杂业务领域 | 领域驱动设计 |
| 多团队的大型系统 | DDD + 限界上下文 |

## 快速参考

### 整洁架构分层

```
┌──────────────────────────────────────┐
│      框架与驱动层(UI、DB)           │  ← 最外层:可以变更
├──────────────────────────────────────┤
│      接口适配器层                     │  ← 控制器、网关
├──────────────────────────────────────┤
│      用例层                          │  ← 应用逻辑
├──────────────────────────────────────┤
│      实体层                          │  ← 核心业务规则
└──────────────────────────────────────┘
```

**依赖规则**:依赖只能指向内层。内层永远不能导入外层。

### 六边形架构

```
         ┌─────────────┐
    ┌────│   适配器     │────┐    (REST API)
    ▼                       ▼
┌──────┐              ┌──────────┐
│ 端口  │◄────────────►│   领域    │
└──────┘              └──────────┘
    ▲                       ▲
    │    ┌─────────────┐    │
    └────│   适配器     │────┘    (数据库)
         └─────────────┘
```

**端口**:定义领域需要的接口
**适配器**:具体实现(可替换以进行测试)

---

## 目录结构

```
app/
├── domain/           # 实体与业务规则(最内层)
│   ├── entities/
│   │   └── user.py
│   ├── value_objects/
│   │   └── email.py
│   └── interfaces/   # 端口
│       └── user_repository.py
├── use_cases/        # 应用业务规则
│   └── create_user.py
├── adapters/         # 接口实现
│   ├── repositories/
│   │   └── postgres_user_repository.py
│   └── controllers/
│       └── user_controller.py
└── infrastructure/   # 框架与外部关注点
    ├── database.py
    └── config.py
```

---

## 模式 1:整洁架构

### 实体(领域层)

```python
from dataclasses import dataclass
from datetime import datetime

@dataclass
class User:
    """核心实体 - 无框架依赖。"""
    id: str
    email: str
    name: str
    created_at: datetime
    is_active: bool = True

    def deactivate(self):
        """实体中的业务规则。"""
        self.is_active = False

    def can_place_order(self) -> bool:
        return self.is_active
```

### 端口(接口)

```python
from abc import ABC, abstractmethod

From lza6/Claude-code-cli-config, Apache-2.0.

More from lza6/Claude-code-cli-config

Signals

Stars
8
Forks
1
Open issues
0
Last commit (this folder)
Apr 13, 2026 (6 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from lza6

Cite this page

architecture-patterns skill. Agent Mart. https://agentmart.dev/skills/lza6-architecture-patterns (last updated 2026-10-24)