nestjs-hexagonal CLAUDE.md

A project guide for building NestJS applications with Hexagonal Architecture, Domain-Driven Design, and CQRS. NestJS is a TypeScript framework; these design approaches separate business rules, infrastructure, and different kinds of commands and queries.

In plain words
What is it for?
It is for routing NestJS tasks to the right skill or agent and enforcing rules for entities, repositories, events, modules, validation, and write operations.
Why use it?
It gives agents consistent architecture rules, such as keeping business code independent from NestJS and limiting what modules expose.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/softtor/nestjs-hexagonal/claude-md
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal
Per session 1,001 This file is loaded in full into every session.
When invoked 1,001 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01001 $0.01001
Opus 5 $0.00500 $0.00500
Sonnet 5 $0.00200 $0.00200
Haiku 4.5 $0.00100 $0.00100

Measured 2d ago against content hash f1d277122823, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

nestjs-hexagonal CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 76 lines

How it starts

The opening of the file, as written. The whole thing — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.

NestJS Hexagonal Plugin — Instructions

Plugin for building NestJS bounded contexts with Hexagonal Architecture + DDD + CQRS. Compatible with GSD workflow.

Entry Point

nestjs-hexagonal:using-nestjs-hexagonal — meta-skill that routes any NestJS task to the correct skill or agent. Check this FIRST when working in a hexagonal NestJS project.

Architecture Rules (enforced by all skills and agents)

  1. Entity extends AggregateRoot from @nestjs/cqrs — uses this.apply(event) for domain events
  2. Repository is PURE persistence — save, find, search, delete. NO event dispatch
  3. EventPublisher lives in the Handler, NEVER in UseCase — UseCase returns entity, Handler calls publisher.mergeObjectContext(entity) then entity.commit()
  4. No NestJS imports in domain — exception: AggregateRoot and IEvent from @nestjs/cqrs
  5. Module exports ONLY Port tokens — never use cases or repositories
  6. class-validator ONLY in presentation request DTOs — never in domain or application
  7. Write operations return void or { id: string } — CQRS strict
  8. No over-engineering — no use case for simple findById, no abstraction for single use, no generic relay patterns

Skills

Skill When
nestjs-hexagonal:domain Entity, VO, event, repository interface, data builder
nestjs-hexagonal:application Use case, CQRS handler, DTO, port, read model
nestjs-hexagonal:infrastructure Prisma repo, module wiring, adapter, event handler infra
nestjs-hexagonal:presentation Controller, request DTO, Swagger, error filter
nestjs-hexagonal:websocket-broadcasting Domain event -> WebSocket broadcast to frontend
nestjs-hexagonal:event-listeners Same-BC, cross-BC, and bridge listeners (WS, broker, email)
nestjs-hexagonal:create-subdomain Full BC orchestrator (dispatches agents per layer)
nestjs-hexagonal:review-subdomain Architecture compliance review

Agents (each loads its corresponding skill)

Read the full file on GitHub · 76 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 76 lines · 1,001 tokens per session scan A f1d277122823

Subscribe to this mod's changes

nestjs-hexagonal CLAUDE.md is an instructions file published in the GitHub repository Softtor/nestjs-hexagonal (5 stars, last pushed 23d ago), licensed MIT. It adds 1,001 tokens to every session, about $0.0050 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.