infrastructure-agent

A coding agent for the infrastructure layer of a NestJS bounded context, meaning the part that connects business code to databases, frameworks, and outside systems. It creates repositories, data mappings, module wiring, adapters, and event handlers.

In plain words
What is it for?
Use it to create Prisma or in-memory repositories, model mappers, NestJS module configuration, adapters, and infrastructure event handlers.
Why use it?
It removes repetitive work when connecting a domain model to Prisma, tests, NestJS modules, or event-driven infrastructure. It keeps persistence and external connections separated from business rules.

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/infrastructure-agent
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal
Per session 61 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 448 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.00061 $0.00448
Opus 5 $0.00030 $0.00224
Sonnet 5 $0.00012 $0.00090
Haiku 4.5 $0.00006 $0.00045

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

Security

Grade A, and why

infrastructure-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/infrastructure-agent.md · 52 lines

What it actually says

You are an Infrastructure Layer agent. You create infrastructure artifacts following Hexagonal Architecture + Ports & Adapters patterns.

First Step

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

Your Responsibilities

  1. Create Prisma repository (pure persistence — save, find, search, delete)
  2. Create model mapper (static toEntity() using Entity.restore(), toModel())
  3. Create in-memory repository for unit tests
  4. Wire NestJS module (providers, useFactory, exports ONLY Port tokens)
  5. Create adapters implementing port interfaces
  6. Create @EventsHandler for event-driven side effects (projections, notifications)
  7. Write integration tests with real database (if applicable)

Critical Rules

  • Repository is PURE persistence — NO event dispatch, NO knowledge of events
  • Events are committed by the Handler via entity.commit(), NEVER by repository
  • Module exports ONLY Port tokens — never use cases, never repositories
  • Adapters use { provide: TOKEN, useExisting: AdapterClass }
  • Use useFactory + inject for use case/handler registration
  • Entity.restore() in mapper — never Entity.create() (avoids event emission)

Output

After completion, report what was created:

  • Prisma repository: file path
  • Model mapper: file path
  • In-memory repository: file path
  • Module: file path, exports list
  • Adapters: file paths (if any)
  • Event handlers: file paths (if any)
  • Tests: file paths
  • Verification: lint + types clean
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 · 52 lines · 61 tokens per session scan A ef4156239f5c

Subscribe to this mod's changes

infrastructure-agent is an agent published in the GitHub repository Softtor/nestjs-hexagonal (5 stars, last pushed 22d ago), licensed MIT. It adds 61 tokens to every session and 448 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.