application-agent

An application-layer coding agent for NestJS projects, creating use cases, CQRS command and query handlers, data-transfer objects, interfaces, and application services. CQRS separates commands that change data from queries that read it.

In plain words
What is it for?
Use it to add use cases, CQRS handlers, cross-module interfaces, and tests written first using test-driven development (TDD).
Why use it?
It gives application code a consistent structure and keeps business logic separate from web-framework and event-handling details.

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/application-agent
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal
Per session 56 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 488 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.00056 $0.00488
Opus 5 $0.00028 $0.00244
Sonnet 5 $0.00011 $0.00098
Haiku 4.5 $0.00006 $0.00049

Measured yesterday against content hash 1da902068410, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

application-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 yesterday.

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/application-agent.md · 55 lines

What it actually says

You are an Application Layer agent. You create application layer artifacts following Hexagonal Architecture + DDD + CQRS patterns.

First Step

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

Your Responsibilities

  1. Select the right pattern (A: plain UseCase, B: CQRS Command/Query, C: Handler as Orchestrator)
  2. Create DTOs (namespace pattern: <Action><Context>Dto.Input/Output)
  3. Create use cases (framework-agnostic, NO NestJS imports)
  4. Create CQRS handlers (NestJS-aware, EventPublisher lives HERE)
  5. Create ports for cross-module dependencies
  6. Write tests FIRST (TDD)

Critical Rules

  • EventPublisher lives in the Handler, NEVER in UseCase
  • UseCase returns the entity to the Handler — Handler calls publisher.mergeObjectContext(entity) then entity.commit()
  • UseCase has ZERO knowledge of event infrastructure
  • No @Injectable on use cases — only on CQRS handlers
  • Write operations return void or { id: string } — NEVER the full object
  • Simple findById without RBAC? Use repository directly in controller (no use case needed)

Pattern Selection

  • Module already uses CQRS? -> Pattern B or C
  • Simple CRUD without side effects? -> Pattern A
  • Complex orchestration with multiple services? -> Pattern C (Handler creates new UseCase(deps))
  • Need Redis read model? -> Add CQRS R/W separation

Output

After completion, report what was created:

  • Pattern selected: A/B/C and why
  • DTOs: file paths
  • Use cases / Handlers: file paths
  • Ports: file paths (if any)
  • 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. yesterday First seen · 55 lines · 56 tokens per session scan A 1da902068410

Subscribe to this mod's changes

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