From nestjs-hexagonal
Orchestrates creation of a NestJS bounded context by dispatching specialized agents per layer (domain, application, infrastructure, presentation). Uses Opus for domain modeling, Sonnet for execution layers. Compatible with GSD workflow (usable as phase execution). Follows TDD, Hexagonal Architecture, DDD, and CQRS.
How this skill is triggered — by the user, by Claude, or both
Slash command
/nestjs-hexagonal:create-subdomainThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Orchestrator that dispatches specialized agents per architectural layer. Each agent loads its corresponding skill and follows TDD.
Orchestrator that dispatches specialized agents per architectural layer. Each agent loads its corresponding skill and follows TDD.
Agent Dispatch: The dispatch blocks below are conceptual templates. In Claude Code, dispatch agents using the
Agenttool with apromptstring that includes "Load skill nestjs-hexagonal: for patterns." The agent's model and tools are defined in the agent.mdfile frontmatter, not in the tool call.
Compatible with GSD: each phase maps to a GSD execution step.
Ask the user via AskUserQuestion. Collect all answers before dispatching agents.
organizationId or companyId)After answers, create the directory structure:
<context>/
├── domain/
│ ├── entities/__tests__/
│ ├── value-objects/__tests__/
│ ├── events/
│ ├── repositories/
│ ├── services/
│ └── testing/helpers/
├── application/
│ ├── dtos/
│ ├── commands/ # Pattern B/C
│ ├── queries/ # Pattern B/C
│ ├── usecases/ # Pattern A/C
│ └── ports/
└── infrastructure/
├── <context>.module.ts
├── controllers/dtos/
├── database/prisma/repositories/
├── database/prisma/models/
├── database/in-memory/repositories/
├── adapters/
└── listeners/
domain-agent (Opus 4.6)Dispatch the domain-agent with context from Phase 1:
Agent tool:
subagent_type: "nestjs-hexagonal:domain-agent"
model: opus
prompt: |
Create domain layer for "<context>" at "<path>".
Entity: <name>, Props: <list>
VOs: <list>, Events: <list>
Multi-tenant: <field>
TDD: tests first. Load skill nestjs-hexagonal:domain.
The agent will create: entity + tests, VOs + tests, events, repository interface, data builders. Verify types compile.
Wait for completion before Phase 3.
application-agent (Sonnet 4.6)Agent tool:
subagent_type: "nestjs-hexagonal:application-agent"
model: sonnet
prompt: |
Create application layer for "<context>" at "<path>".
Pattern: <A/B/C>, Operations: <list>
Ports: <list>, Read model: <yes/no>
Domain layer at "<path>/domain/".
TDD: tests first. Load skill nestjs-hexagonal:application.
Creates: DTOs, use cases/handlers, ports, tests.
Wait for completion before Phase 4.
infrastructure-agent (Sonnet 4.6)Agent tool:
subagent_type: "nestjs-hexagonal:infrastructure-agent"
model: sonnet
prompt: |
Create infrastructure layer for "<context>" at "<path>".
Pattern: <A/B/C>, Ports to implement: <list>
Event handlers: <list side effects>
Load skill nestjs-hexagonal:infrastructure.
Creates: Prisma repo, model mapper, in-memory repo, adapters, event handlers, module wiring.
Wait for completion before Phase 5.
presentation-agent (Sonnet 4.6)Skip if no HTTP endpoints needed.
Agent tool:
subagent_type: "nestjs-hexagonal:presentation-agent"
model: sonnet
prompt: |
Create presentation layer for "<context>" at "<path>".
Pattern: <A/B/C>, Endpoints: <CRUD list>
RBAC: <yes/no>
Load skill nestjs-hexagonal:presentation.
Creates: controller, request DTOs, Swagger, module registration.
Wait for completion before Phase 6.
Run directly, no agent needed:
pnpm check-types
pnpm lint
pnpm test --filter <module-name>
pnpm build
All must exit 0. Fix root causes, no suppression.
architecture-reviewer (Sonnet 4.6)Agent tool:
subagent_type: "nestjs-hexagonal:architecture-reviewer"
model: sonnet
prompt: |
Review bounded context at "<path>".
Check all 6 dimensions. Produce Pass/Warning/Fail report.
Address every FAIL. Report to user: structure, pattern, decisions, deferred warnings.
This workflow maps directly to GSD phases:
| GSD Phase | create-subdomain Phase | Agent |
|---|---|---|
| Research | Phase 1 (requirements) | inline |
| Execute task 1 | Phase 2 (domain) | domain-agent (Opus) |
| Execute task 2 | Phase 3 (application) | application-agent (Sonnet) |
| Execute task 3 | Phase 4 (infrastructure) | infrastructure-agent (Sonnet) |
| Execute task 4 | Phase 5 (presentation) | presentation-agent (Sonnet) |
| Verify | Phase 6 (verification) | inline |
| Review | Phase 7 (review) | architecture-reviewer (Sonnet) |
When used within GSD, each phase can be a separate GSD task tracked in the plan.
| Anti-pattern | Correction |
|---|---|
Use case for simple findById without RBAC | Repository directly in controller |
EventPublisher in UseCase | Only in the CQRS Handler |
| Exporting repositories from module | Export only Port token Symbols |
class-validator in domain VOs | Manual validate() with InvalidArgumentError |
| Repository dispatching events | Repository is pure persistence |
| Circular module dependencies | Ports in consumer, adapter in provider |
| Mixing patterns A/B/C in one BC | Choose one, apply consistently |
| Creating abstractions for one-time use | YAGNI — 3 lines > premature abstraction |
@Injectable in domain or UseCase | Only in infrastructure + CQRS handlers |
Entity.create() in mapper | Use Entity.restore() to avoid event emission |
organizationId from request body | Always from @CurrentOrganization() auth context |
| Writing implementation before test | TDD: red -> green -> refactor |
| File | Content |
|---|---|
references/tdd-workflow.md | Test templates and TDD sequence per layer |
references/checklist.md | 30+ item delivery checklist grouped by layer |
references/bc-organization.md | When and how to split a BC into sub-modules |
npx claudepluginhub softtor/nestjs-hexagonal --plugin nestjs-hexagonalImplements Clean Architecture, DDD, and Hexagonal Architecture patterns in NestJS/TypeScript apps for complex backend structuring, domain layers with entities/aggregates, ports/adapters, use cases, and refactoring anemic models.
Guides applying Clean Architecture, Hexagonal Architecture, and Domain-Driven Design to structure systems with isolated business logic, layer boundaries, and dependency rules.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.