cursorrules

A set of coding rules for EloquentJS applications, a Node.js toolkit for working with databases and building APIs.

In plain words
What is it for?
Writing EloquentJS models and related Node.js applications using PostgreSQL or MongoDB, validation, REST APIs, GraphQL, and realtime features.
Why use it?
It keeps imports, model files, database fields, and deletion behavior consistent across the project.

Cursor rule for Cursor

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 rules/anandpilania/eloquentjs/cursorrules
Clone the repo
git clone --depth 1 https://github.com/AnandPilania/eloquentjs

Made for: Cursor.

Per session 1,036 This file is loaded in full into every session.
When invoked 1,036 The same file — it is already loaded in full.
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.01036 $0.01036
Opus 5 $0.00518 $0.00518
Sonnet 5 $0.00207 $0.00207
Haiku 4.5 $0.00104 $0.00104

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

Security

Grade A, and why

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

agent-files/.cursorrules · 127 lines

How it starts

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

EloquentJS — Cursor Rules

Project Tech Stack

  • Runtime: Node.js (ESM, "type": "module")
  • ORM: EloquentJS (@eloquentjs/core)
  • Database: PostgreSQL via @eloquentjs/pgsql (or MongoDB via @eloquentjs/mongodb)
  • Validation: @eloquentjs/validator
  • REST API: @eloquentjs/api (Express/Fastify)
  • GraphQL: @eloquentjs/graphql
  • Realtime: @eloquentjs/realtime

Code Style Rules

Imports

  • Always use ESM imports (import, not require)
  • Import from package names, not file paths for EloquentJS packages
  • Default export for Model classes; named exports for utilities
// ✅ Correct
import { Model } from '@eloquentjs/core'
import { v }     from '@eloquentjs/validator'
import User      from './models/User.js'

// ❌ Wrong
const { Model } = require('@eloquentjs/core')

Model files

  • One model per file in app/models/
  • PascalCase filename matching class name
  • Always declare static table, static fillable, and static casts
  • Soft deletes: add static softDeletes = true (never delete rows in user-facing apps)
// ✅ Standard model structure
export default class Product extends Model {
  static table    = 'products'
  static fillable = ['name', 'price', 'sku', 'category_id']
  static hidden   = []
  static casts    = { price: 'decimal:2', in_stock: 'boolean', tags: 'array' }
  static softDeletes = true

  category() { return this.belongsTo(Category) }
  static scopeInStock(qb) { return qb.where('in_stock', true) }
}

Querying

  • Always await query results
  • Use .with() for any relations accessed after fetching
  • Use findOrFail() when record absence should be an error
  • Use paginate() for list endpoints (never .all() without limit in production)
// ✅
const product = await Product.findOrFail(id)
const page    = await Product.inStock().with('category').paginate(page, 20)

// ❌
const product = Product.find(id)     // missing await
const all     = await Product.all()  // dangerous in production

Validation

  • Always validate before create() or update()
  • Use @eloquentjs/validator fluent schema for complex validation
  • Use schema.parseAsync() when rules include unique() or exists()

Read the full file on GitHub · 127 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 · 127 lines · 1,036 tokens per session scan A 6b0c983f3864

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository AnandPilania/eloquentjs (74 stars, last pushed 27d ago), licensed MIT. It adds 1,036 tokens to every session, about $0.0052 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-30.