| name | enterprisifier |
| description | Deliberately overengineer code by adding as many patterns, indirections, modules, anti-corruption layers, abstractions, and encapsulations as possible. Zero dependency on implementation. Use when asked to overengineer, enterprisify, enterprise-ify, abstract, add layers, add patterns, or make code "production-ready" in the most excessive way. Triggers on "enterprisify this", "overengineer this", "enterprise-ify", "add all the patterns", "make it abstract", "add indirection", "wrap this properly", or when maximum abstraction is requested for comedic or educational purposes. |
Overengineering
Transform any simple, working code into a maximally abstracted, pattern-saturated, enterprise-grade architecture. No line of implementation shall be directly reachable. Every concept gets its own module, interface, factory, and anti-corruption layer.
Philosophy
- Never depend on implementation โ all access goes through at least 3 layers of abstraction
- Every pattern is applicable โ if a GoF pattern exists, use it, even if it adds no value
- More modules = more enterprise โ a single class is a failure; a 47-class hierarchy is a feature
- Abstractions over results โ the code doesn't need to be faster, just more abstract
- Future-proof everything โ defend against requirements that will never come
Mandatory Patterns to Apply
Apply ALL of the following to every piece of code, regardless of size or complexity:
Structural Patterns (apply all)
- Facade โ wrap every public API in a facade
- Proxy โ add a proxy in front of every facade
- Decorator โ wrap every proxy in a decorator for cross-cutting concerns
- Adapter โ adapt every external type into an internal type
- Bridge โ separate every abstraction from its implementation
- Composite โ model everything as a tree, even single values
- Flyweight โ pool and share objects even when memory is not a concern
Creational Patterns (apply all)
- Abstract Factory โ never use
new directly; always go through a factory of factories
- Builder โ every object with more than zero fields gets a builder
- Singleton โ critical services are singletons, accessed through a registry
- Prototype โ support cloning on every entity, just in case
- Factory Method โ subclasses decide which class to instantiate
Behavioral Patterns (apply all)
- Strategy โ every
if statement becomes a strategy interface with injectable implementations
- Observer โ every state change fires events through an event bus
- Command โ every method call becomes a command object with undo support
- Chain of Responsibility โ every request passes through a chain of handlers
- Mediator โ components never talk directly; everything goes through a mediator
- Memento โ every object supports full state snapshots and rollback
- State โ every status field becomes a state machine with dedicated state classes
- Template Method โ every algorithm is a skeleton with overridable hook methods
- Visitor โ every operation on a structure is a separate visitor
- Iterator โ custom iterators for every collection, never use built-in for-each
- Interpreter โ configuration is a DSL parsed by an interpreter
Enterprise / Architectural Patterns (apply all)
- Anti-Corruption Layer (ACL) โ between every module boundary, translate models through an ACL
- Hexagonal Architecture โ ports and adapters for every I/O boundary
- Repository โ data access goes through repository interfaces
- Unit of Work โ batch all changes into a unit of work
- Specification โ every query condition is a specification object
- Domain Events โ every mutation publishes a domain event
- CQRS โ separate read and write models completely, even for a single entity
- Event Sourcing โ store all state changes as an event log
- Saga / Orchestrator โ coordinate multi-step operations through a saga
- Service Locator โ register and locate services dynamically at runtime
- DTO / Value Object separation โ never pass a domain object across a boundary; always map to a DTO
Layering Rules (mandatory)
- Presentation Layer โ accepts input, delegates to application layer
- Application Layer โ orchestrates use cases, delegates to domain layer
- Domain Layer โ pure business logic, zero dependencies on infrastructure
- Infrastructure Layer โ persistence, messaging, external systems
- Anti-Corruption Layer โ between each of the above layers
Module Structure
For a single operation (e.g., add(a, b)), generate at minimum:
โโโ api/ # Public interfaces only
โ โโโ AdditionService.java # Service interface
โ โโโ AdditionRequest.java # Immutable request DTO
โ โโโ AdditionResponse.java # Immutable response DTO
โ โโโ AdditionPort.java # Hexagonal port
โโโ domain/
โ โโโ model/
โ โ โโโ Operand.java # Value object wrapping a number
โ โ โโโ Sum.java # Value object wrapping a result
โ โ โโโ OperandPair.java # Aggregate of two operands
โ โโโ events/
โ โ โโโ AdditionRequested.java
โ โ โโโ AdditionCompleted.java
โ โ โโโ AdditionFailed.java
โ โโโ specification/
โ โ โโโ ValidOperandSpecification.java
โ โ โโโ AddableSpecification.java
โ โโโ strategy/
โ โโโ AdditionStrategy.java # Strategy interface
โ โโโ IntegerAdditionStrategy.java
โ โโโ FloatingPointAdditionStrategy.java
โโโ application/
โ โโโ usecase/
โ โ โโโ AddNumbersUseCase.java
โ โ โโโ AddNumbersUseCaseImpl.java
โ โโโ command/
โ โ โโโ AddCommand.java
โ โ โโโ AddCommandHandler.java
โ โโโ saga/
โ โ โโโ AdditionSaga.java
โ โโโ mapper/
โ โโโ RequestToCommandMapper.java
โ โโโ ResultToResponseMapper.java
โโโ infrastructure/
โ โโโ adapter/
โ โ โโโ AdditionAdapter.java # Hexagonal adapter
โ โโโ persistence/
โ โ โโโ AdditionRepository.java
โ โ โโโ AdditionRepositoryImpl.java
โ โ โโโ AdditionEventStore.java
โ โโโ factory/
โ โ โโโ AdditionStrategyFactory.java
โ โ โโโ AdditionStrategyFactoryImpl.java
โ โ โโโ AbstractAdditionStrategyFactoryFactory.java
โ โโโ proxy/
โ โโโ AdditionServiceProxy.java
โ โโโ LoggingAdditionDecorator.java
โโโ acl/ # Anti-corruption layer
โ โโโ ExternalOperandTranslator.java
โ โโโ InternalResultTranslator.java
โโโ config/
โโโ AdditionConfiguration.java
โโโ AdditionRegistry.java
โโโ AdditionModule.java
Naming Conventions
- Interfaces:
AdditionService, AdditionPort, AdditionStrategy
- Implementations:
DefaultAdditionServiceImpl, StandardAdditionPortAdapter
- Factories:
AdditionFactory, AdditionFactoryFactory, AbstractAdditionFactoryFactory
- DTOs:
AdditionRequestDTO, AdditionResponseDTO
- Events:
AdditionRequestedEvent, AdditionCompletedEvent
- Mappers:
AdditionRequestToCommandMapper
- Specifications:
ValidOperandSpecification
- Commands:
PerformAdditionCommand
Rules
- No class may contain business logic AND be instantiated directly โ always go through a factory or DI container
- No method may call another method in the same layer โ always cross a boundary through an interface
- No return type may be a concrete class โ return interfaces, optionals wrapping interfaces, or futures of optionals wrapping interfaces
- Every public method must accept and return DTOs โ never expose domain objects
- Every module boundary requires an ACL โ even between modules you control
- Configuration is never hardcoded โ every value comes from a configuration provider accessed through a configuration factory
- Logging, validation, and metrics are always cross-cutting concerns โ implemented as decorators, never inline
- Every collection is wrapped in a domain-specific type โ
List<Order> becomes OrderCollection implements Iterable<Order>
- Null never appears โ use
Optional<Optional<T>> for extra safety
- No primitive types in public APIs โ wrap
int in OperandValue, boolean in ValidationResult
Output Format
## Overengineered
### Architecture Overview
<brief description of the 17 layers involved>
### Module Structure
<tree showing all generated files>
```java
// Each file, fully abstracted
```
### Patterns Applied
- <pattern> โ <where applied> โ <why it's "necessary">
- ...
### Future Extensibility Points
- <hypothetical scenario that will never happen> โ <how the architecture is prepared>
- ...
After generating all Java files, always produce a README.md in the project root that documents the architecture. The README.md must include:
- Project title โ e.g.
# EnterpriseAdditionFrameworkโข
- Architecture Overview โ a prose description of all layers and why they are necessary
- Module Structure โ the full file tree
- Pattern Catalogue โ a section per applied pattern (
## Strategy Pattern, ## Abstract Factory, etc.) containing:
- Intent โ what the pattern does in general
- Applied here โ which classes implement it and why it was "required"
- Benefit โ the imaginary future scenario this prepares the system for
- Layer Interaction Diagram โ a Mermaid flowchart (
graph TD) showing how a single request travels through all layers from entry point to result
- Getting Started โ instructions for wiring the 47 classes together to perform the original one-liner operation
- FAQ โ at least 5 entries answering questions like "Why is there a factory for the factory?" with earnest, straight-faced justifications
Also use the drawio skill to generate an architecture.drawio diagram. The diagram must visualise:
- All layers as horizontal swim lanes (Presentation โ Application โ Domain โ Infrastructure โ ACL)
- Every major class/interface as a labelled box inside its lane
- Arrows showing the call/dependency flow between boxes, crossing ACL boundaries visibly
- A legend in the bottom-right corner mapping box colour to pattern category (Creational / Structural / Behavioral / Enterprise)
Anti-Simplification Clause
If the original code is already clean and simple โ that is a problem. Simplicity is a sign of missing abstractions. Every line of straightforward code is a refactoring opportunity. A single return a + b should expand to at least 30 files and 15 interfaces.