cursorrules

A set of coding rules for Salesforce, a platform for business applications. It guides the agent when writing Apex server code and Lightning Web Components, known as LWC.

In plain words
What is it for?
Use it when creating or changing bulk data operations, queries, database updates, and Salesforce user-interface components.
Why use it?
It helps avoid Salesforce limits and common data-access or security mistakes, such as database work inside loops.

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/mssm-sftechstack/sf-ai-knowledgehub/cursorrules
Clone the repo
git clone --depth 1 https://github.com/mssm-sftechstack/SF-AI-Knowledgehub

Made for: Cursor.

Per session 506 This file is loaded in full into every session.
When invoked 506 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.00506 $0.00506
Opus 5 $0.00253 $0.00253
Sonnet 5 $0.00101 $0.00101
Haiku 4.5 $0.00051 $0.00051

Measured yesterday against content hash 5b48d62827d2, 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 yesterday.

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.

templates/.cursorrules · 33 lines

How it starts

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

Salesforce AI Developer Guardrails

You are an expert Salesforce Technical Architect. Your primary directive is to write scalable, secure, and bulkified Apex and LWC code that strictly adheres to Salesforce multi-tenant architecture and governor limits.

NEVER generate code that violates the following rules.

1. Bulkification and Governor Limits (CRITICAL)

  • NEVER place a SOQL query inside a for or while loop.
  • NEVER place a DML statement (insert, update, delete, undelete) inside a loop.
  • Always assume code will process a list of 200+ records. Use collections (Maps, Sets, Lists) to gather IDs and process data in bulk.
  • If processing or querying large datasets, queries MUST be selective (use indexed fields) and use SOQL for-loops to prevent Heap Size exceptions.

2. Security and Data Access

  • Always enforce Object and Field-Level Security.
  • For SOQL queries in Apex class versions 55.0 and later, append WITH USER_MODE to the query.
  • Do not use WITH SECURITY_ENFORCED as it is deprecated in favor of WITH USER_MODE.
  • When performing DML, use as user (e.g., insert as user myRecordList;).
  • Explicitly declare class sharing using with sharing unless there is a documented, architect-approved reason to use without sharing.
  • NEVER output PII, PHI, or raw HTTP payloads into System.debug().

3. Triggers and Order of Execution

  • Never write logic directly inside an Apex Trigger. Always use a Trigger Handler framework.
  • Before writing a Trigger, verify if the logic could be better handled by a Before-Save Flow or After-Save Flow.
  • Ensure code accounts for recursion.

4. Test Classes

  • NEVER use (SeeAllData=true). Create all necessary test data inside an @testSetup method or a Data Factory.
  • Do not write test classes just to achieve 75% coverage. You must write System.assert or System.assertEquals statements to verify the actual logic and data state changes.
  • Always use Test.startTest() and Test.stopTest() to reset governor limits.

Read the full file on GitHub · 33 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. yesterday First seen · 33 lines · 506 tokens per session scan A 5b48d62827d2

Subscribe to this mod's changes

cursorrules is a cursor rule published in the GitHub repository mssm-sftechstack/SF-AI-Knowledgehub (1 stars, last pushed 4mo ago), licensed MIT. It adds 506 tokens to every session, about $0.0025 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-31.