node-architecture

node-architecture is a cursor rule for Cursor from adonai-labs/agent-runway. It costs 0 tokens per session (589 once invoked), scanned A, original, MIT.

A set of architecture guidelines for Node.js services. It explains how to separate business rules, application logic, external adapters, and HTTP or queue entry points, while validating configuration at startup.

In plain words
What is it for?
Use it when structuring Node.js APIs, background workers, or services that have multiple entry points such as HTTP requests and queue messages.
Why use it?
It helps prevent business logic from becoming tied to a web framework or external service. That makes services easier to test, change, and operate.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when structuring Node.js APIs, background workers, or services that have multiple entry points such as HTTP requests and queue messages.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/adonai-labs/agent-runway/node-architecture
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.

Clone the repo
git clone --depth 1 https://github.com/adonai-labs/agent-runway

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for node-architecture

README.md
[![agentmods](https://agentmods.dev/badge/rules/adonai-labs/agent-runway/node-architecture/github.svg)](https://agentmods.dev/rules/adonai-labs/agent-runway/node-architecture)
Your own site
<a href="https://agentmods.dev/rules/adonai-labs/agent-runway/node-architecture"><img src="https://agentmods.dev/badge/rules/adonai-labs/agent-runway/node-architecture/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for node-architecture

Your own site · 80×15
<a href="https://agentmods.dev/rules/adonai-labs/agent-runway/node-architecture"><img src="https://agentmods.dev/badge/rules/adonai-labs/agent-runway/node-architecture.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 589 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00000 $0.00589
Opus 5 $0.00000 $0.00295
Sonnet 5 $0.00000 $0.00118
Haiku 4.5 $0.00000 $0.00059

Measured 7d ago against content hash 9e2c1f3809d5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

node-architecture 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 7d 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.

src/stacks/node/node-architecture.mdc · 68 lines

How it starts

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

Node.js Architecture Guidelines

Applied when working with Node.js service architecture. Australian English spelling throughout.


Project Structure

  • Separate concerns into domain/, application/, infrastructure/, api/, and shared/ — dependency flow is always inward
  • Keep business rules (domain and application) independent of Express, Fastify, or any HTTP framework
  • Centralise all process.env access in a typed config module; validate at startup with Zod

Layer Rules

  • Domain: no external dependencies; entities, value objects, port interfaces
  • Application: depends on domain only; defines port interfaces infrastructure must implement
  • Infrastructure: implements ports; contains DB adapters, queue clients, HTTP clients
  • API: depends on application; maps HTTP to use cases and results to responses
  • Shared: cross-cutting utilities; imports nothing from domain, application, or infrastructure

Multiple Entry Points (Hexagonal)

When a service has both HTTP and queue consumers, treat each as an independent adapter calling the same application use cases. The core (domain + application) never knows which adapter triggered it.


Config

  • Use Zod to validate and type all environment variables at startup — fail fast on missing config
  • Export a single typed config object; never read process.env directly outside the config module
  • Do not default-fill secrets; a missing secret at startup is safer than silent misconfiguration

Process Entry Point

  • Compose the application from the outside in: validate config → create infrastructure → wire use cases → start server/workers → register shutdown handlers
  • Handle SIGTERM and SIGINT for graceful shutdown
  • Exit with non-zero code on startup failure via an uncaught rejection handler on main()

Module System

  • Prefer ESM ("type": "module") for new projects
  • Use node: prefix for built-in imports — explicit and avoids naming conflicts
  • Avoid barrel index.ts files in large codebases — they slow type-checking and break tree-shaking

Read the full file on GitHub · 68 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. 7d ago First seen · 68 lines · 0 tokens per session scan A 9e2c1f3809d5

Subscribe to this mod's changes

node-architecture is a cursor rule published in the GitHub repository adonai-labs/agent-runway (2 stars, last pushed 21d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 589 tokens. 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-09-03.