api

api is a cursor rule for Cursor from bayesimpact/bayes-platform. It costs 0 tokens per session (8,119 once invoked), scanned A, original, MIT.

Repository instructions for a NestJS API, including rules for imports used by its dependency-injection system. Dependency injection is how the framework supplies services and other objects to a class.

In plain words
What is it for?
Use them when changing API services, controllers, guards, interceptors, pipes, or data-transfer types.
Why use it?
They prevent runtime errors caused by treating required classes as type-only imports and clarify which import style to use.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: mentions Cursor.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import type { RequestPayload, ResponseData } from "../generic".

Good fit Use them when changing API services, controllers, guards, interceptors, pipes, or data-transfer types.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/bayesimpact/bayes-platform
agentmods
npx agentmods add rules/bayesimpact/bayes-platform/api

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 api

README.md
[![agentmods](https://agentmods.dev/badge/rules/bayesimpact/bayes-platform/api/github.svg)](https://agentmods.dev/rules/bayesimpact/bayes-platform/api)
Your own site
<a href="https://agentmods.dev/rules/bayesimpact/bayes-platform/api"><img src="https://agentmods.dev/badge/rules/bayesimpact/bayes-platform/api/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 api

Your own site · 80×15
<a href="https://agentmods.dev/rules/bayesimpact/bayes-platform/api"><img src="https://agentmods.dev/badge/rules/bayesimpact/bayes-platform/api.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 8,119 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.08119
Opus 5 $0.00000 $0.04059
Sonnet 5 $0.00000 $0.01624
Haiku 4.5 $0.00000 $0.00812

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

Security

Grade A, and why

api 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.

.cursor/rules/api.mdc · 907 lines

How it starts

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

Cursor Agent Rules for CaseAI Connect - API

NestJS Dependency Injection

Import Type Rule

When NestJS requires runtime access to classes for dependency injection (services, controllers, guards, etc.), you MUST use regular imports, not type-only imports.

Rule: If you get a NestJS DI error about a class being undefined at runtime, it means you used import type instead of import.

Solution:

  • Change import type { MyService } from './my.service' to import { MyService } from './my.service'
  • Add a biome-ignore comment: // biome-ignore lint/style/useImportType: Required at runtime for NestJS DI

When to use:

  • Services injected via @InjectRepository(), @Inject(), or constructor injection
  • Controllers, Guards, Interceptors, Pipes
  • Any class that needs to be available at runtime for NestJS DI

When type-only imports are OK:

  • DTOs, interfaces, types
  • Return types, parameter types
  • Anything not used for DI

Example:

// ❌ Wrong - will cause DI error
import type { UsersService } from "@/users/users.service"

// ✅ Correct
// biome-ignore lint/style/useImportType: Required at runtime for NestJS DI
import { UsersService } from "@/users/users.service"

DTO Organization

Domain-Based DTO Location

Rule: DTOs (Data Transfer Objects) MUST be co-located with their domain logic in packages/api-contracts/src/{domain}/ as a single consolidated file per domain.

Structure:

  • All DTOs for a domain MUST be consolidated into a single file: packages/api-contracts/src/{domain}/{domain}.dto.ts (e.g., packages/api-contracts/src/projects/projects.dto.ts, packages/api-contracts/src/me/me.dto.ts)
  • DO NOT create separate files for each DTO (e.g., create-project.dto.ts, list-projects.dto.ts, etc.)
  • All DTOs are exported from packages/api-contracts/src/index.ts for consumption by both API and frontend
  • Controllers and routes import DTOs from @caseai-connect/api-contracts

Why this pattern?

  • Reduced file proliferation: Avoids having many small DTO files that are hard to navigate
  • Better organization: All related DTOs for a domain are in one place
  • Easier maintenance: Related types are easier to find and update together
  • Cohesion: DTOs are tightly coupled to domain logic and API contracts
  • Single source of truth: DTOs live in a shared package accessible to all consumers
  • No circular dependencies: API-contracts is a separate package that API and frontend both depend on
  • Frontend integration: Frontend imports directly from @caseai-connect/api-contracts

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

Subscribe to this mod's changes

api is a cursor rule published in the GitHub repository bayesimpact/bayes-platform (18 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 8,119 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-14.