Complete Clean Architecture methodology with 4-layer system, Context Package information hiding, sub-agent orchestration, PM workflows, and contract management. Use for any CA project development including feature planning, architectural decisions, layer management, contract changes, and major reworks. Triggers on: "clean architecture", CA project work, layer management, context package, contract management, feature development, change management, major rework, requirements definition, "plan feature", "design system", "refactor layer"
Infrastructure -> Interface -> UseCase -> Domain
(外層) (内層)
| Layer | Responsibility | Dependencies |
|---|---|---|
| Domain | Entities, Value Objects, Domain Services, Repository Interfaces | None (innermost) |
| UseCase | Application logic, Input/Output Ports, DTOs | Domain only |
| Interface | Controllers, Presenters, Gateways | UseCase only |
| Infrastructure | Repository impl, DB, External APIs, Config | All (via DIP) |
Dependency Rule: Inner layers NEVER know about outer layers. When inner needs outer, apply DIP (define interface in inner, implement in outer).
Agents do not explore outside Allowed Paths. "Just in case grep the whole thing" is PROHIBITED. If needed, request PM for Allowed Paths expansion.
| Role | Access |
|---|---|
| PM | All |
| Sub-agents | Own layer only |
Domain Layer:
docs/contracts/dtos.md, docs/layers/domain/*src/domain/**, tests/unit/domain/**Usecase Layer:
docs/contracts/ports.md, docs/contracts/dtos.md, docs/layers/usecase/*src/usecase/**, tests/unit/usecase/**src/domain/** (dependency reference only)Interface Layer:
docs/contracts/api.md, docs/contracts/dtos.md, docs/layers/interface/*src/interface/**, tests/unit/interface/**src/usecase/** (dependency reference only)Infra Layer:
docs/contracts/ports.md, docs/layers/infra/*src/infra/**, tests/unit/infra/**Sub-Agent概念をスキルとして運用。場面に応じてClaudeが適切なモードに切り替える。
When: 複雑な機能の実装計画が必要な時 Principle: Planning is docs-based - NO src access by default
Process:
Output format:
# Implementation Plan: [Feature Name]
## Overview / Requirements / Architecture Changes
## Implementation Steps (Phase 1, 2, ...)
## Testing Strategy / Risks & Mitigations / Success Criteria
When: アーキテクチャ判断、システム設計が必要な時
Principle: docs-based design; PM must grant Allowed Exception: src/[path]/** for src access
Process:
Architecture Decision Records (ADR):
## ADR-XXX: [Title]
- Status: proposed/accepted/deprecated
- Context: [Why this decision is needed]
- Decision: [What was decided]
- Consequences: [What changes as a result]
When: デッドコード削除、コード整理が必要な時
Process:
When: ドキュメント更新が必要な時
Access: Read all files, Write only docs/**, README.md, CLAUDE.md
Process:
PMはユーザーと直接つながるセッション。サブエージェント統合・契約管理・Context Package配布を担当。
[ROLE] を起動。
Layer: <domain|usecase|interface|infra>
Allowed Paths:
- docs/contracts/*
- docs/layers/[layer]/*
- src/[layer]/**
- tests/unit/[layer]/**
Goal: [具体的なタスク]
Done: [完了条件]
| Resource | PM | Sub-agents |
|---|---|---|
| All MEMO.md | OK | Own layer only |
| contracts/* edit | OK | Proposals only |
| Allowed Paths exceptions | OK | Request only |
| Cross-layer reference | OK | NG |
ユーザーがアイデアや要件を語り始めた時に自動起動。
あなたは「要件定義コーチ」として振る舞う:
Requirements Document Format:
制約: 設計しない(DB/API/モジュール/クラス/技術選定は書かない)。ユーザー視点の仕様のみ確定。
1. Planner Mode (対象レイヤ) → 設計ドキュメント作成
2. Architect Mode → 契約整合性確認、提案検討
3. [PMが契約変更を承認]
4. /tdd-guide → テスト作成 → 実装
5. /build-resolver → (ビルドエラー時のみ)
6. /code-review-excellence → コードレビュー
7. /security-review → (リリース前)
8. Documentation Mode → ドキュメント更新
仕様変更/修正依頼時に起動。順序: 契約→受け入れ条件→設計→実装→監査/QA
大規模リワーク(構造変更)時。段階移行で進行。
Phase 0: Freeze - 現行の契約・受け入れ条件・主要フローを整理。回帰テスト追加 Phase 1: New Contract - 新旧契約を共存。v2用DESIGN.md更新。互換アダプタ方針決定 Phase 2: Migration - レイヤ単位に実装(domain→usecase→interface→infra)。旧新並行稼働 Phase 3: Cutover - 新経路へ完全切替。旧コード/契約削除。Refactor Mode + Documentation Mode
docs/contracts/
├── dtos.md # Data Transfer Objects (全レイヤ共通)
├── ports.md # Ports/Interfaces (Domain↔Infra)
├── api.md # API Contracts (Interface layer)
└── events.md # Domain Events (optional)
{Operation}{TargetDomain}{Role}{TargetDomain}{Category}Port| Task | Skill |
|---|---|
| Code review | /code-review-excellence |
| Bug investigation | /systematic-debugging |
| Cross-validation | /dual-agent-debug, /dual-agent-review |
| TDD implementation | /tdd-guide |
| Security audit | /security-review |
| Build errors | /build-resolver |
| Framework-specific | Prompt user to install (e.g., /vercel-react-best-practices) |