Skip to content
Agentmart
Submit a tool

clean-architecture

4 層クリーンアーキテクチャ(domain / application / infrastructure / presentation)の依存方向・層ごとの責務・DI・Clock port・エラーハンドリングの原則。言語 / フレームワーク非依存の共通基準で、設計・実装・レビュー系エージェントが前提として読む。

Skill by jugeeem

IndexedMIT
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/jugeeem-clean-architecture

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

4 層クリーンアーキテクチャ(domain / application / infrastructure / presentation)の依存方向・層ごとの責務・DI・Clock port・エラーハンドリングの原則。言語 / フレームワーク非依存の共通基準で、設計・実装・レビュー系エージェントが前提として読む。

Use cases: presentations, devops

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

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/clean-architecture

What's inside

Skill name
clean-architecture
Description
4 層クリーンアーキテクチャ(domain / application / infrastructure / presentation)の依存方向・層ごとの責務・DI・Clock port・エラーハンドリングの原則。言語 / フレームワーク非依存の共通基準で、設計・実装・レビュー系エージェントが前提として読む。
License
MIT
Instructions
68 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# クリーンアーキテクチャの原則(スタック非依存)

> この原則は言語 / フレームワークに依存しない。具体的なライブラリ名・ディレクトリ・禁止 import はプロジェクトの `.claude/rules/` と `.claude/docs/` が定める。本スキルの原則とプロジェクトの rules が食い違う場合は **rules を優先**する。

## 4 層と依存方向

```
presentation  ──→  application (usecase)  ──→  domain
      │                     │                    ▲
      └──────→ infrastructure ───────────────────┘
               (domain / application の interface を実装)
```

| 層 | 責務 | 依存してよい対象 |
|---|---|---|
| **domain** | エンティティ、値オブジェクト、ドメインサービス、リポジトリ **interface**、ドメインエラー | **何にも依存しない**(純粋な言語機能のみ) |
| **application** | ユースケース(interactor)、入出力 DTO、外部能力の **port interface**(Clock / AuthService / Logger 等) | domain のみ |
| **infrastructure** | リポジトリ実装、外部サービスクライアント、Clock 実装、**DI コンポジションルート** | domain / application(interface を実装するため) |
| **presentation** | サーバの入口(RPC procedure / HTTP router 等)、入出力スキーマ、認証 / 認可 middleware、エラーマッピング | application(usecase)。infrastructure は DI 経由でのみ受け取る |

## 依存性のルール

1. **依存は常に内向き**。逆向きの import は違反。
2. domain は他のどの層・どのライブラリにも依存しない。ORM / フレームワーク / RPC / UI ライブラリを domain に import した時点で違反。
3. application は具象を知らない。必要な外部能力は **port interface** として application 内に定義し、infrastructure が実装する。
4. presentation はビジネスロジックを書かない。**入力検証 → usecase 呼び出し → 出力整形** のみ。
5. 層境界をまたぐデータは **DTO / プレーンオブジェクト**。ORM のモデル型を application / presentation / UI に漏らさない(infrastructure の mapper で変換)。

## DI / コンポジションルート

- 具象クラスの生成(`new` 相当)は **infrastructure の DI モジュール内だけ**で行う。usecase や presentation で ORM クライアント等を直接生成しない。
- presentation は DI から組み立て済みの usecase を受け取って呼ぶ。
- テストでは fake リポジトリ / port を注入して usecase を単体検証できる構成にする。

## 時刻

- 「現在時刻」は **`Clock` port 経由**で取得する。domain / application で `new Date()` / `datetime.now()` 相当を直接呼ばない。
- 永続化は UTC、表示 / 入力境界で基準タイムゾーンへ変換する(基準タイムゾーンはプロジェクトの rules が定める)。

## エラーハンドリング

- domain / application は **ドメインエラー**(`DomainError` 系)で失敗を表現する。HTTP ステータス / RPC エラーを知らない。
- presentation でドメインエラー → プロトコルのエラーへ **一元的に**マッピングする(マッピング表を 1 箇所に置く)。

## 認可

- 認可判定は presentation の middleware に集約する(`requireAuth` / `requireRole(...)`)。
- usecase 内に「このユーザーは admin か?」を散らさない。必要なら `actor` を usecase に渡し、ドメインの認可ルールとして表現する。
- 書き込み系の入口は **必ずサーバ側でロールを再検証**する。UI の出し分けに依存しない。

## 新規ユースケースの追加手順

1. domain にエンティティ / 値オブジェクト / リポジトリ interface / ドメインエラー(不足分)を追加。
2. application に usecase(`execute(input) -> output`)と入出力 DTO、必要な port を追加。
3. infrastructure にリポジトリ / port の実装を追加し、DI に配線。
4. presentation に入出力スキーマと入口(procedure / router)を追加し、登録。
5. usecase の単体テスト(fake 注入)を書く。

## レビューで弾く違反

- domain / application から ORM・フレームワーク・RPC・UI ライブラリを import。
- presentation に条件分岐の塊や永続化判断。
- ORM モデル型を usecase の戻り値や UI に直接渡す。
- usecase / domain で現在時刻を直接取得。
- リポジトリ実装を domain / application に置く。
- DI 以外の場所で具象を生成。

From jugeeem/sdd-harness, MIT.

More from jugeeem/sdd-harness

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Oct 15, 2026 (13 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from jugeeem

Cite this page

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