clean architecture 2

    1

    Audit and refactor codebases to enforce clean architecture, layer boundaries, and inward dependency directions.

    Free

    1 useSecurity scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    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

    ViolationLayerFindingRecommendation
    Outward DependencyDomainOrderEntity uses @Column decorators, coupling business rules to the DB schema.Extract a pure Order domain model; use a mapper in the infrastructure layer.
    Leaky AbstractionApplicationcreateOrder method checks for response.status === 201.Move status code gating to a Repository implementation; return a Result object.
    Logic DisplacementInterfaceController is calculating tax before calling the service.Move tax calculation policy into a TaxService within the domain layer.
    Missing BoundaryInfrastructureDirect 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

    1. Create a domain/models/order.ts to house business invariants without framework decorators.
    2. Implement the OrderRepository in the infrastructure/ folder to encapsulate TypeORM and status code logic.
    3. Update the controller to call the CreateOrderUseCase instead 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

    1. Surface identification You provide a specific feature, module, or route to review.
    2. Responsibility mapping The skill traces current dependencies and classifies files into the Default Layer Model.
    3. Violation detection It flags common failures like domain models annotated with persistence concerns or controllers performing business branching.
    4. 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.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    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 forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 15 days ago

    • Free with an Agensi account

    Permissions

    Read Files
    Network Access
    Listed15 days ago

    What's inside

    Frequently Asked Questions

    This skill enforces the "Dependency Rule," ensuring your core business logic never depends on external factors like databases, UI frameworks, or third-party APIs by identifying and correcting outward-pointing dependencies.

    It is framework-agnostic and works with any language, including TypeScript, Go, and Python, by focusing on universal architectural patterns like Hexagonal and Onion rather than language-specific syntax.

    The skill functions as a logic-heavy plugin for LLM-based agents; it requires a developer to provide specific entry points or modules for review rather than performing a blind full-repo scan.

    You receive the architectural heuristic logic and a suite of specialized prompts designed to trace dependencies, map layer responsibilities, and generate refactoring strategies for your agent to execute.

    Unlike generic prompts that often suggest impossible full-scale rewrites, this skill identifies specific 'seams' and 'adapters' to allow for incremental, low-risk refactoring of existing production code.

    New in Code Quality & Review