{"id":"a15e3673-7a70-414c-b04a-a53a82ab42a2","slug":"skill-layered-domain-architecture","kind":"skill","name":"skill-layered-domain-architecture","summary":"Agent Skill for Layered Domain Architecture and TDD workflow across software projects","owner":"abbasjaber","repoUrl":"https://github.com/abbasjaber/skill-layered-domain-architecture","license":"MIT","licenseTier":"permissive","trust":"community","stars":3,"match":null,"fewStars":true,"format":"skill","createdAt":"2026-10-22T08:55:07.000Z","addedAt":"2026-11-01T02:03:27.151Z","logoUrl":"https://avatars.githubusercontent.com/u/9704724?u=90c9fb02ecafcfa9aed768f1a556d3d9affc65d0&v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["writing"],"tags":["backend","clean-architecture","layered-architecture","tdd"],"runtime":"node","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-11-01T02:03:43.928Z","sample":false,"url":"https://conduits.dev/tools/skill-layered-domain-architecture","language":"JavaScript","transports":["stdio"],"install":{"npm":"skill-layered-domain-architecture"},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# Layered Domain Architecture Skill\n\n<p align=\"center\">\n  <img src=\"assets/banner.jpg\" alt=\"Layered Domain Architecture Skill Banner\" width=\"100%\">\n</p>\n\nAn Agent Skill providing production-grade guidelines, design patterns, and testing protocols for building backend systems using **Layered Domain Architecture** and **Test-Driven Development (TDD)**.\n\nDesigned for AI coding assistants (Google Antigravity, Claude Code, Cursor, GitHub Copilot CLI, Codex) and human engineering teams.\n\n---\n\n## ⚡ Instant One-Line Installation with `npx`\n\nNo cloning or manual copying needed! Anyone can install the skill with one command:\n\n### 1. Install into Current Project (Recommended)\nRun this inside any project root to add the skill to `.agents/skills/layered-domain-architecture`:\n```bash\nnpx github:abbasjaber/skill-layered-domain-architecture\n```\n*Then commit `.agents/skills` to Git so your entire team and their AI agents have it automatically.*\n\n### 2. Install Globally (For All Projects on Machine)\nInstalls into `~/.gemini/config/skills` and `~/.agents/skills`:\n```bash\nnpx github:abbasjaber/skill-layered-domain-architecture --global\n```\n\n### 3. Install Everywhere (Current Project + Globally)\n```bash\nnpx github:abbasjaber/skill-layered-domain-architecture --all\n```\n\n---\n\n## 🎯 Architecture Blueprint\n\n```\n[ HTTP / Transport Layer ]      Controllers / Handlers / Resolvers\n           │\n           ▼\n[ Domain / Application Layer ]  Services / Use Cases (Interfaces & Implementations)\n           │\n           ▼\n[ Data Access Layer ]          Repositories / Data Mappers (Interfaces & Implementations)\n           │\n           ▼\n[ Serialization Layer ]        Resources / DTOs / Serializers\n```\n\n### Key Principles\n\n- **Separation of Concerns**: Controllers handle transport only; Services handle business rules; Repositories handle database persistence; Resources handle API response contracts.\n- **Dependency Inversion**: Code to interfaces. Services and Repositories expose explicit contracts bound via IoC containers.\n- **Strict TDD Verification**: Every endpoint must pass tests for **401** (Unauthenticated), **403** (Unauthorized/RBAC), **400/422** (Validation & boundary limits), **200/201/204** (Success), and database transaction rollback integrity.\n- **Database Safety**: All migrations must be strictly reversible (`up` and `down`), use UUID/ULID primary keys, and enforce referential integrity.\n\n---\n\n## 🌐 Supported Projects & Frameworks\n\nThis skill is designed for **any backend API or server-side application** that handles business logic, databases, and authentication, regardless of the language or framework.\n\n### 1. Ideal Project Types\n\n| Project Type | Why It Works Well |\n| :--- | :--- |\n| **SaaS & Enterprise Platforms** | Keeps large applications organized with strict domain boundaries (`Staff/`, `Client/`, `Billing/`, `Auth/`). |\n| **REST & GraphQL Web APIs** | Ensures clean separation between request parsing, business rules, queries, and JSON response envelopes. |\n| **B2B / Multi-Audience Portals** | Naturally separates different user interfaces (e.g., Client Portal vs. Staff/Admin Portal). |\n| **Fintech, Legal & Healthcare** | Enforces auditability, strict RBAC security tests (401/403), and transactional database rollback guarantees. |\n| **Monoliths & Microservices** | Works equally well inside a modular monolith or inside individual microservices. |\n\n### 2. How the 4 Layers Map Across Frameworks\n\nThe pattern (`Transport` &rarr; `Service` &rarr; `Repository` &rarr; `Resource`) translates seamlessly into any backend stack:\n\n| Framework / Language | Transport Layer | Domain Service Layer | Data Access Layer | Serialization Layer |\n| :--- | :--- | :--- | :--- | :--- |\n| **Laravel / PHP** | Controllers | Services (`*Service.php`) | Repositories (`*Repository.php`) | API Resources (`*Resource.php`) |\n| **NestJS / TypeScript** | `@Controller()` | `@Injectable()` Services | TypeORM / Prisma Repositories | DTOs with `class-transformer` |\n| **FastAPI / Python** | Routers (`@router.get`) | Domain Services / Use Cases | SQLAlchemy / SQLModel Repositories | Pydantic Schemas |\n| **Go** | HTTP Handlers / Gin / Fiber | Use Case / Service structs | Storage / Repository interfaces | Response structs |\n| **Spring Boot / Java** | `@RestController` | `@Service` classes | `@Repository` (JPA/Hibernate) | DTO records |\n| **ASP.NET Core / C#** | `ControllerBase` | Application Services | EF Core Repositories | ViewModels / DTOs |\n\n### 3. When NOT to Use It\n\n- **Pure Frontend Projects**: Static websites, simple React/Vue SPA apps without a backend.\n- **Micro-Lambdas / Simple Webhooks**: A simple 10-line cloud function that just resizes an image or sends an alert doesn't need 4 architectural layers.\n- **Data Science / ML Training Pipelines**: Jupyter notebooks or Python data processing scripts (Pandas/PyTorch) don't follow web API layer patterns.\n\n---\n\n## 💡 How to Use\n\nAI agents will automatically load this skill whenever tasks match triggering conditions such as:\n- Designing or implementing new backend features, APIs, or domain modules.\n- Refactoring fat controllers or extracting repositories.\n- Setting up TDD feature test suites or endpoint verification.\n- Writing reversible database migrations.\n\nYou can also prompt your agent explicitly:\n```text\n/layered-domain-architecture\n```\nor\n```text\nFollow the layered-domain-architecture skill to design the billing module.\n```\n\n---\n\n## 📦 Manual Installation (Git Clone Alternative)\n\n#### Globally\n```bash\ngit clone https://github.com/abbasjaber/skill-layered-domain-architecture.git ~/.gemini/config/skills/layered-domain-architecture\n```\n\n#### Inside a Project\n```bash\nmkdir -p .agents/skills\ngit clone https://github.com/abbasjaber/skill-layered-domain-architecture.git .agents/skills/layered-domain-architecture\n```\n\n---\n\n## 📄 License\n\nMIT License. See [LICENSE](LICENSE) for details.\n"}