agentleFS
Hive-AcademyHive-Academy/PtahCode/.claude/skills/resilient-nestjs-patterns/SKILL.md

resilient-nestjs-patterns

Skill34 starsChanged 10 days agoMITView on GitHub

NestJS service decomposition and resilience. Use when splitting an orchestrator service into layers, adding retries or fallbacks, wiring EventEmitter events or SSE, or designing forRoot/forTesting dynamic modules. Persistence, auth, RBAC and repositories are nestjs-backend-patterns. Webhook plumbing is webhook-architecture. A task that both persists and retries may load both skills.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use during a Stage B module task when the module needs orchestration, reliability, events, or configurable wiring.

    line 10
  2. Distinctive:

    Keep controllers at the HTTP boundary, domain services responsible for business rules, and database services responsible for persistence …

    line 11

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Resilient NestJS Patterns

Apply

  • Use during a Stage B module task when the module needs orchestration, reliability, events, or configurable wiring.
  • Keep controllers at the HTTP boundary, domain services responsible for business rules, and database services responsible for persistence and transactions.
  • Retry only transient external failures with a bounded policy; make fallback behavior explicit. Keep side effects behind events when they should not block the core transaction.
  • Expose configuration through a dynamic module when provider choices vary by environment or tests.
  • When patterns compose, a thin controller calls a business orchestrator; it delegates persistence to a DbService, external calls to a resilient adapter, and emits a domain event only after the transaction succeeds. Event listeners handle email or SSE; the module exports the orchestrator and supplies production and test providers through forRoot and forTesting.

Selection and adoption

Current problemRoute
Controller calls Prisma, owns transactions, or mixes HTTP mapping with business rulesDomain service layering first
Service has unrelated method clusters or too many collaborators to testService orchestration after layering
Transient provider errors, a local fallback, or provider downtimeRetry and fallback; this can be adopted independently
Email, cache invalidation, audit work, or SSE coupled to the core methodEvent-driven architecture after service boundaries are clear
Repeated provider setup, environment choices, or test substitutesDynamic modules once the module structure is stable

Adopt only patterns justified by a current problem; do not decompose a small cohesive service just to fit this sequence.

Failure patterns

SymptomCorrect route
Fat controller with business logicDomain service layering
God service spanning unrelated concernsService orchestration
Silent failure from an empty catch around an external callRetry and fallback with explicit failure handling
Synchronous email or other side effect blocking the responseEvent-driven architecture
Copy-pasted provider arrays across modulesDynamic modules
Premature decomposition of a small serviceKeep it cohesive (YAGNI)

Load by task

  • For a domain service coordinating several collaborators, load service orchestration.
  • For controller, business, and database boundaries, load domain service layering.
  • For external provider failures, load retry and fallback.
  • For decoupled side effects or SSE, load event-driven architecture.
  • For configurable provider wiring and test substitutes, load dynamic modules.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.