arch-clean

Installation
SKILL.md

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.

Related skills
Installs
21
GitHub Stars
5
First Seen
Mar 7, 2026