arch-clean
Clean/hexagonal architecture: ports/adapters, dependency inversion, use cases, entities, testability
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o arch-clean.zip https://jpskill.com/download/22266.zip && unzip -o arch-clean.zip && rm arch-clean.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22266.zip -OutFile "$d\arch-clean.zip"; Expand-Archive "$d\arch-clean.zip" -DestinationPath $d -Force; ri "$d\arch-clean.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
arch-clean.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
arch-cleanフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Claude が読む原文 SKILL.md(中身を展開)
この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。
arch-clean
Purpose
This skill implements Clean Architecture principles in codebases, focusing on hexagonal patterns with ports/adapters, dependency inversion, use cases, entities, and testability. It refactors or generates code to enforce separation of concerns, making systems modular and easier to test.
When to Use
Use this skill when refactoring monolithic apps to improve maintainability, starting new projects requiring high testability, or integrating external dependencies without tight coupling. Apply it in scenarios with complex business logic, such as e-commerce backends, or when adapting legacy code to modern architectures like microservices.
Key Capabilities
- Generate port interfaces for adapters, ensuring dependency inversion (e.g., defines contracts like
interface UserPort { fetchUser(id: string): User; }). - Create use case classes that orchestrate entities and ports, promoting single responsibility.
- Invert dependencies by wrapping external libraries in adapters, e.g., converting a direct database call to a port implementation.
- Enforce testability by structuring code for unit testing, such as mocking ports in use cases.
- Validate architecture rules, like checking that inner layers don't depend on outer ones, via static analysis.
Usage Patterns
Invoke this skill via OpenClaw's CLI for quick refactoring or through API for automated pipelines. Start by analyzing the codebase with a scan command, then apply transformations. For scripts, pipe outputs to build tools like Make or Gradle. Always specify the target directory and language (e.g., TypeScript or Java) to avoid defaults. Use in CI/CD for pre-commit hooks to enforce architecture.
Common Commands/API
Use the OpenClaw CLI with subcommands prefixed by arch-clean. Authentication requires setting $OPENCLAW_API_KEY as an environment variable.
-
Generate a port interface:
openclaw arch-clean generate-port --name UserPort --methods "fetchUser(id: string)" --lang tsThis creates a file like
UserPort.tswith the interface. -
Invert dependencies in a module:
openclaw arch-clean invert-dep --path src/services --adapter DatabaseAdapterScans the specified path and wraps dependencies, e.g., replacing direct imports with adapter calls.
-
Create a use case:
openclaw arch-clean create-usecase --name FetchUser --ports UserPort --entities UserGenerates a class like
FetchUserUseCase.tswith injected ports.
API endpoints for programmatic use:
- POST /api/arch-clean/generate: Body { "type": "port", "name": "UserPort", "methods": ["fetchUser(id: string)"] }, requires
$OPENCLAW_API_KEYin headers. - PUT /api/arch-clean/invert: Body { "path": "src/services", "adapter": "DatabaseAdapter" }.
Config formats: Use JSON files for custom rules, e.g., .openclaw-arch.json with { "layers": { "domain": ["entities", "usecases"], "adapters": ["http", "db"] } }.
Integration Notes
Integrate by adding OpenClaw as a dependency in your project (e.g., npm install openclaw or via Docker image). Set $OPENCLAW_API_KEY for authenticated requests. For IDE plugins, configure via settings like { "arch-clean": { "defaultLang": "ts", "excludePaths": ["tests/**"] } }. Combine with linters like ESLint by piping output, e.g., openclaw arch-clean scan | eslint --fix. Ensure your codebase uses a supported structure, such as folders for "domain", "application", and "infrastructure", to match hexagonal patterns.
Error Handling
Check command outputs for errors; CLI returns non-zero exit codes with JSON error messages, e.g., { "error": "Dependency not inverted: invalid path" }. For API, expect HTTP 4xx/5xx responses with bodies like { "code": 400, "message": "Missing required field: methods" }. Handle by wrapping calls in try-catch blocks, e.g.:
try {
const response = await fetch('/api/arch-clean/generate', { headers: { 'X-API-Key': process.env.OPENCLAW_API_KEY } });
if (!response.ok) throw new Error(response.statusText);
} catch (error) {
console.error('Arch error:', error.message);
}
Retry transient errors (e.g., network issues) up to 3 times with exponential backoff.
Usage Examples
-
Refactor a simple service to use ports: For a Node.js app, run
openclaw arch-clean invert-dep --path src/userService.js --adapter HttpAdapter. This transforms a direct HTTP call into a port, e.g., changingaxios.get('/user')tothis.userPort.fetchUser(id), improving testability by allowing mocks. -
Generate a use case for business logic: In a Java project, execute
openclaw arch-clean create-usecase --name OrderProcessor --ports PaymentPort --entities Order. This producesOrderProcessor.javawith a method likepublic void process(Order order) { this.paymentPort.charge(order); }, enabling dependency injection for better architecture.
Graph Relationships
- Related to: se-architecture cluster (e.g., links to skills like code-refactor for broader refactoring).
- Depends on: ports-adapters tag (connects to hexagonal-architecture for adapter implementations).
- Conflicts with: monolithic patterns (avoids tight couplings in legacy systems).