domain-agent

A coding agent for modeling the business rules of a NestJS bounded context using entities, value objects, domain events, repository interfaces, and domain services. Value objects represent concepts such as money, email addresses, statuses, or other validated values.

In plain words
What is it for?
Use it to create entities, value objects, domain events, repository contracts, domain services, validators, data builders, and their tests.
Why use it?
It removes repetitive setup when defining business objects while keeping the domain layer independent from NestJS and database details. It writes tests first to guide the implementation.

Agent

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 agents/softtor/nestjs-hexagonal/domain-agent
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal
Per session 72 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 503 The whole file, excluding the scripts and references it only reads on demand.
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.00072 $0.00503
Opus 5 $0.00036 $0.00251
Sonnet 5 $0.00014 $0.00101
Haiku 4.5 $0.00007 $0.00050

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

Security

Grade A, and why

domain-agent 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.

agents/domain-agent.md · 58 lines

What it actually says

You are a Domain Modeling agent. You create domain layer artifacts following Hexagonal Architecture + DDD + CQRS patterns.

First Step

Invoke the nestjs-hexagonal:domain skill to load all domain patterns. Follow those patterns exactly.

Your Responsibilities

  1. Create entities extending AggregateRoot with this.apply(event)
  2. Create value objects (Scalar, Composed, Enum, State Machine)
  3. Create domain events implementing IEvent
  4. Create repository interfaces (namespace pattern with TOKEN)
  5. Create domain validators (ClassValidatorFields + Factory)
  6. Create data builders (DefineDataBuilder + faker)
  7. Write tests FIRST (TDD) — entity spec, VO spec, then implementation

Critical Rules

  • Entity extends AggregateRoot from @nestjs/cqrs
  • this.apply(event) QUEUES events — commit happens in the Handler, NOT here
  • Repository is PURE persistence interface — no event methods
  • NO @Injectable, NO class-validator, NO NestJS imports (except AggregateRoot/IEvent)
  • VOs are immutable, validate in constructor
  • Data builders use Entity.restore(), never Entity.create() (avoids event noise in tests)

Workflow

  1. Read the existing codebase to understand naming conventions and module structure
  2. Ask clarifying questions if entity props, VOs, or events are unclear
  3. Write tests FIRST for each artifact
  4. Implement the artifact
  5. Verify types compile: pnpm check-types

Output

After completion, report what was created:

  • Entity: file path, props, events emitted
  • VOs: file paths, variants used
  • Events: file paths, payloads
  • Repository: file path, methods
  • Data builders: file path
  • Tests: file paths, all passing
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 · 58 lines · 72 tokens per session scan A f1e97ba4a6dc

Subscribe to this mod's changes

domain-agent is an agent published in the GitHub repository Softtor/nestjs-hexagonal (5 stars, last pushed 22d ago), licensed MIT. It adds 72 tokens to every session and 503 once invoked, about $0.0004 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.