Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
alphaonedev avatar

Arch Clean

  • 50 installs
  • 6 repo stars
  • Updated March 13, 2026
  • alphaonedev/openclaw-graph

arch-clean is a skill that refactors code into clean/hexagonal architecture with ports, adapters, use cases, and dependency inversion for testability.

About

This skill implements Clean Architecture and hexagonal patterns in a codebase: generating port interfaces, use-case classes, and adapters that enforce dependency inversion and separation of concerns. It runs via the openclaw CLI to scan and transform code for improved testability. A developer uses it when refactoring a monolith or starting a project that needs high testability. It requires the OPENCLAW_API_KEY environment variable.

  • Refactors code to hexagonal ports/adapters and dependency inversion
  • Generates use-case classes and port interfaces for testability

Arch Clean by the numbers

  • 50 all-time installs (skills.sh)
  • Ranked #576 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

arch-clean capabilities & compatibility

Capabilities
arch · arch patterns · arch api · refactoring
Use cases
refactoring · testing
Pricing
Bring your own API key
From the docs

What arch-clean says it does

This skill implements Clean Architecture principles in codebases, focusing on hexagonal patterns with ports/adapters, dependency inversion, use cases, entities, and testability.
SKILL.md
Enforce testability by structuring code for unit testing, such as mocking ports in use cases.
SKILL.md
npx skills add https://github.com/alphaonedev/openclaw-graph --skill arch-clean

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs50
repo stars6
Last updatedMarch 13, 2026
Repositoryalphaonedev/openclaw-graph

What it does

Refactor code to clean/hexagonal architecture with ports, adapters, and use cases for testability.

When should I use this skill?

When refactoring a monolith or enforcing hexagonal architecture and testability.

What you get

Modular code with ports, adapters, and use cases that is easier to unit-test.

  • port interface
  • use-case class
  • adapter wrapper

By the numbers

  • validates that inner layers do not depend on outer layers

Files

SKILL.mdMarkdownGitHub ↗

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 ts

This creates a file like UserPort.ts with the interface.

  • Invert dependencies in a module:
  openclaw arch-clean invert-dep --path src/services --adapter DatabaseAdapter

Scans 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 User

Generates a class like FetchUserUseCase.ts with injected ports.

API endpoints for programmatic use:

  • POST /api/arch-clean/generate: Body { "type": "port", "name": "UserPort", "methods": ["fetchUser(id: string)"] }, requires $OPENCLAW_API_KEY in 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

1. 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., changing axios.get('/user') to this.userPort.fetchUser(id), improving testability by allowing mocks.

2. Generate a use case for business logic: In a Java project, execute openclaw arch-clean create-usecase --name OrderProcessor --ports PaymentPort --entities Order. This produces OrderProcessor.java with a method like public 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).

Related skills

FAQ

What does arch-clean generate?

Port interfaces, use-case classes, and adapters that enforce dependency inversion.

How does it improve testability?

It structures code for unit testing, such as mocking ports in use cases.

Code Review & Qualitybackendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.