Programming & Dev
Advanced
Core Architectural Concept
Clean Architecture, popularized by Robert C. Martin (Uncle Bob), is designed to isolate the core business rules of an application from databases, frameworks, and web clients. This prompt acts as a Lead Architect to refactor coupled, messy legacy code into independent, highly testable layers.
How to Utilize This Prompt
1. Copy the prompt and insert your coupled code into [Insert Codebase Snippet].
2. Run the prompt. The AI will output a clean folder hierarchy followed by the decoupled code modules.
Advanced Optimization Tips
- Specify Language Features: If you want specific language features (like React Hooks, Node.js controllers, NestJS modules, or Go interfaces), add a line specifying the framework details.
- Address External DBs: State which database (e.g., PostgreSQL, MongoDB) or APIs you are using, so the repository layer interfaces are designed correctly.
Customize Prompt Parameters
AI Prompt Blueprint
Act as a Lead Software Architect. Analyze the following codebase snippet: [Insert Codebase Snippet]. Refactor it to strictly follow Clean Architecture principles. Your output must include: 1. A detailed structural directory tree showing the separation of layers (Domain, Use Cases, Interfaces, Infrastructure). 2. Refactored code separating core business logic (entities and use cases) from external concerns (frameworks, database clients, UI libraries). 3. Implementation of the Dependency Inversion Principle using TypeScript interfaces or equivalent dependency injection patterns. 4. A brief explanation of the architectural benefits of this refactoring, focusing on testability and system coupling.