- Home
- Skills
- Code Quality & Review
- clean architecture 2
clean architecture 2
Audit and refactor codebases to enforce clean architecture, layer boundaries, and inward dependency directions.
Free
Works with the AI Agents you already use
clean architecture 2
Example session with this skill installed
Review the OrderService.ts file and check for any dependency violations or leaked infrastructure concerns. It handles order creation and DB calls.
- Read your context and instructions
- Compiled the clean architecture 2
I have reviewed OrderService.ts. The current implementation mixes orchestration, database persistence, and business validation in a single class. Specifically, the service is importing TypeORM entities directly and branching on raw HTTP status codes from the payment gateway.
Clean Architecture Audit: OrderService
| Violation | Layer | Finding | Recommendation |
|---|---|---|---|
| Outward Dependency | Domain | OrderEntity uses @Column decorators, coupling business rules to the DB schema. | Extract a pure Order domain model; use a mapper in the infrastructure layer. |
| Leaky Abstraction | Application | createOrder method checks for response.status === 201. | Move status code gating to a Repository implementation; return a Result object. |
| Logic Displacement | Interface | Controller is calculating tax before calling the service. | Move tax calculation policy into a TaxService within the domain layer. |
| Missing Boundary | Infrastructure | Direct axios calls are scattered in the service. | Wrap the payment SDK in a PaymentGateway interface defined in the application layer. |
Refactoring Plan
// 1. Define the Application Port (Inward)
export interface OrderRepository {
save(order: Order): Promise<OrderResult>;
}
// 2. Extract the Use Case (Orchestration)
export class CreateOrderUseCase {
constructor(private repository: OrderRepository) {}
async execute(input: CreateOrderRequest): Promise<OrderResult> {
const order = Order.create(input); // Business invariants checked here
return this.repository.save(order);
}
}
Next steps
- Create a
domain/models/order.tsto house business invariants without framework decorators. - Implement the
OrderRepositoryin theinfrastructure/folder to encapsulate TypeORM and status code logic. - Update the controller to call the
CreateOrderUseCaseinstead of the raw service.
Connects securely to your tools. The creator never sees your data.
About this skill
Your codebase is a mess of leaky abstractions where business logic is buried in UI components and database models are bleeding into your domain. This skill audits your repository to enforce strict layer boundaries and dependency directions.
What it does
- Layer classification Categorizes code into domain, application, interface, and infrastructure based on actual responsibility.
- Dependency auditing Identifies outward-pointing dependencies that couple business logic to frameworks or drivers.
- Boundary extraction Isolates business rules from transport details like HTTP status codes and ORM-specific query APIs.
- Incremental refactoring Proposes the smallest structural changes, such as introducing mappers or repository ports, to fix architecture without a full rewrite.
- Sanitization enforcement Ensures presentation layers consume only normalized data and sanitized error contracts instead of raw transport objects.
How it works
- Surface identification You provide a specific feature, module, or route to review.
- Responsibility mapping The skill traces current dependencies and classifies files into the Default Layer Model.
- Violation detection It flags common failures like domain models annotated with persistence concerns or controllers performing business branching.
- Refactor proposal It generates a strategy to restore dependency direction using seams and adapters.
Frameworks & tools
Works with any language or framework including React, NestJS, Go, Java, or Python. It focuses on architectural patterns like Hexagonal, Onion, and Clean Architecture rather than specific library syntax.
Why this beats prompting it yourself
Generic prompts often suggest impractical, massive rewrites or focus only on folder names. This skill uses specific heuristics to find hidden backdoors in shared utilities and ensures your "clean" architecture isn't just folders full of coupled code.
Use cases
- Audit a new pull request for architectural drift and layer violations.
- Extract a complex business workflow from a bloated controller into a pure use case.
- Decouple a React frontend from backend transport artifacts using mappers and hooks.
- Refactor legacy "Manager" or "Helper" classes into responsible domain entities.
Known limitations
Does not perform automated file moves or deletions. Requires the developer to provide clear entry points for review.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.
Requires manual execution of suggested refactors. Cannot automatically move files. Best results when specific features or modules are targeted rather than an entire monolithic repo at once.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
1 use
Times used to date
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 15 days ago
- Free with an Agensi account