windsurfrules

windsurfrules is a cursor rule for Windsurf from AnandPilania/eloquentjs. It costs 826 tokens per session, scanned A, original, MIT.

A set of coding rules describing a Node.js application that uses ESM, the EloquentJS database library, PostgreSQL or MongoDB, and Express or Fastify.

In plain words
What is it for?
Use it when changing models, queries, validation, API routes, or database code in this project.
Why use it?
It highlights project-specific requirements such as awaiting database calls, loading related records efficiently, and declaring writable model fields.

Cursor rule for Windsurf

Written for Windsurf: a Windsurf rule.

Good fit Use it when changing models, queries, validation, API routes, or database code in this project.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/anandpilania/eloquentjs/windsurfrules
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/AnandPilania/eloquentjs

Made for: Windsurf.

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 windsurfrules

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

Your own site · 80×15
<a href="https://agentmods.dev/rules/anandpilania/eloquentjs/windsurfrules"><img src="https://agentmods.dev/badge/rules/anandpilania/eloquentjs/windsurfrules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 826 This file is loaded in full into every session.
When invoked 826 The same file — it is already loaded in full.
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.00826 $0.00826
Opus 5 $0.00413 $0.00413
Sonnet 5 $0.00165 $0.00165
Haiku 4.5 $0.00083 $0.00083

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

Security

Grade A, and why

windsurfrules 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/.windsurfrules · 119 lines

How it starts

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

EloquentJS — Windsurf Rules

Stack

Node.js ESM + EloquentJS ORM + PostgreSQL/MongoDB + Express/Fastify

Packages

  • @eloquentjs/core — Model, QueryBuilder, Relations, Events, Casts
  • @eloquentjs/validator — Validation (fluent schema + async DB rules)
  • @eloquentjs/pgsql — PostgreSQL driver with pool management
  • @eloquentjs/graphql — Auto GraphQL from models
  • @eloquentjs/api — Auto REST CRUD routes
  • @eloquentjs/realtime — WebSocket broadcasting
  • @eloquentjs/cli — Scaffold and migration commands

Critical Rules

1. Always await DB calls

// Every Model method returns a Promise
const user = await User.findOrFail(id)      // ✅
const user = User.findOrFail(id)            // ❌ Promise, not User

2. Eager load relations

// ✅ One query per relation
const posts = await Post.with('user', 'tags', 'comments').get()

// ❌ N+1: one extra query per post
const posts = await Post.all()
for (const p of posts) { const u = await p.user() }

3. Declare fillable

// ✅ Required for create/update to work
class User extends Model {
  static fillable = ['name', 'email', 'password']
}

// ❌ Empty fillable = nothing gets saved
class User extends Model {}

4. Validate before write

import { v } from '@eloquentjs/validator'

const schema = v.schema({
  email: v.string().email(),
  name:  v.string().min(2),
})
const data = schema.parse(req.body)       // throws on invalid
await User.create(data)

5. Use findOrFail for required records

// ✅ Throws ModelNotFoundException → handle as 404
const user = await User.findOrFail(req.params.id)

// ❌ Need manual null check
const user = await User.find(req.params.id)
if (!user) return res.status(404).json({ error: 'Not found' })

Model Template

import { Model } from '@eloquentjs/core'

export default class ModelName extends Model {
  static table       = 'table_name'
  static fillable    = ['field1', 'field2']
  static hidden      = []
  static softDeletes = false
  static casts = {
    // field: 'boolean' | 'integer' | 'decimal:2' | 'json' | 'array' | 'date' | 'datetime'
  }

  // Relations
  // parent()   { return this.belongsTo(Parent) }
  // children() { return this.hasMany(Child) }

  // Scopes
  // static scopeName(qb) { return qb.where(...) }

  // Hooks
  // static async creating(record) { }
  // static async created(record)  { }
}

Read the full file on GitHub · 119 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 · 119 lines · 826 tokens per session scan A 9f8208f0acbb

Subscribe to this mod's changes

windsurfrules is a cursor rule published in the GitHub repository AnandPilania/eloquentjs (74 stars, last pushed yesterday), licensed MIT. It adds 826 tokens to every session, about $0.0041 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-09-08.