Layered Monolith to Hexagonal / Clean Architecture Refactor
Refactor tangled MVC controllers and service layers into Clean Architecture (Ports & Adapters).
Isolate core domain entities and business rules from web frameworks and database drivers using Clean Architecture (Ports & Adapters).
Execution Workflow Procedure
Ordered steps the coding agent executes when performing this skill.
Extract Pure Domain Entities
Create pure domain entities containing business logic with zero framework, web, or ORM annotations.
Define Inbound & Outbound Ports
Declare use case interfaces (Inbound Ports) and repository/gateway interfaces (Outbound Ports).
Implement Infrastructure Adapters
Implement REST controllers and JPA/SQL repositories as adapters implementing port interfaces.
Agent Safety Guardrails & Anti-Hallucination Rules
- DO NOT allow domain models to depend on ORM or web controller classes.
- DO NOT put business logic inside controllers or database repositories.
Expected Output Format
Domain entities, use cases, ports, and adapters.
Domain Verification Checks
Example Agent Invocations
Install / Configure This Skill
# Place in .cursorrules or create .cursor/rules/hexagonal-clean-architecture-refactor.mdc # Trigger: Whenever you perform layered monolith to hexagonal / clean architecture refactor --- name: hexagonal-clean-architecture-refactor description: Decouple domain logic from web frameworks and databases using Ports & Adapters (Hexagonal Architecture). version: 1.0.0 compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity] --- # Layered Monolith to Hexagonal / Clean Architecture Refactor ## Objective Decouple business domain logic from databases and frameworks using Clean Architecture and Ports & Adapters. ## Workflow 1. **Pure Domain**: Extract domain entities containing business rules with zero framework dependencies. 2. **Ports Definition**: Declare Inbound (Use Case) and Outbound (Repository/Client) interfaces. 3. **Adapters Implementation**: Implement REST controllers and persistence repositories as interchangeable adapters.
Need a quick one-time prompt for chat?
Try the Monolith to Clean / Hexagonal Architecture Refactor — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.
SprintKit Workflow Integrations
Complementary tools and checklists to pair with this agent workflow.
Related Agent Skills
Explore related procedural workflows in this discipline.
God Class & Monolithic Method Decomposition (SOLID)
Decompose monolithic 1,000+ line classes into Single Responsibility components using SOLID design patterns.
Safe Legacy Code Modernization with Golden Master Tests
Safely modernize fragile legacy codebases using Martin Fowler refactoring patterns and characterization tests.
Spring Boot Service & JPA Code Review
Rigorous code review workflow for Spring Boot services examining transactions, JPA queries, concurrency, and validation.