salesforce-guard

salesforce-guard is an agent for Claude Code from giggsoinc/raven. It costs 66 tokens per session (1,038 once invoked), scanned A, original, MIT.

A Salesforce code checker for Apex, triggers, JavaScript, and HTML used in Salesforce customisations.

In plain words
What is it for?
It checks bulk-processing patterns, database-query and data-change placement, record identifiers, and Salesforce DX file structure.
Why use it?
It catches code patterns that can fail under Salesforce's per-transaction limits or point to the wrong records in another organisation. It can block database queries and record changes inside loops and hardcoded Salesforce IDs.

Agent for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions subagents.

Part of the raven plugin — 63 skills, 13 commands, 10 agents, 5 hooks, 1 MCP server shipped together

Good fit It checks bulk-processing patterns, database-query and data-change placement, record identifiers, and Salesforce…

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/giggsoinc/raven/salesforce-guard
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/giggsoinc/raven

Made for: Claude Code.

Or install raven, the plugin that ships this one along with the rest of its 63 skills, 13 commands, 10 agents, 5 hooks, 1 MCP server.

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 salesforce-guard

README.md
[![agentmods](https://agentmods.dev/badge/agents/giggsoinc/raven/salesforce-guard.svg)](https://agentmods.dev/agents/giggsoinc/raven/salesforce-guard)
Your own site
<a href="https://agentmods.dev/agents/giggsoinc/raven/salesforce-guard"><img src="https://agentmods.dev/badge/agents/giggsoinc/raven/salesforce-guard.svg" alt="Measured on agentmods" height="20"></a>
Per session 66 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,038 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.00066 $0.01038
Opus 5 $0.00033 $0.00519
Sonnet 5 $0.00013 $0.00208
Haiku 4.5 $0.00007 $0.00104

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

Security

Grade A, and why

salesforce-guard 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 6d 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.

agents/salesforce-guard.md · 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.

Salesforce Guard Agent

Enforces Salesforce best practices. Runs as sub-agent (pre-flight) and on PostEdit.


Rule 1 — No SOQL or DML Inside Loops (HARD BLOCK)

Scan .cls and .trigger files for:

for(...) { [SELECT or DML inside] }
while(...) { [SELECT or DML inside] }

Patterns:

  • for or while loop containing [SELECT
  • for or while loop containing insert, update, delete, upsert, merge

On violation:

❌ SALESFORCE GUARD — SOQL/DML inside loop
   File:   [filename]:[line]
   Issue:  [SELECT / DML statement inside loop]
   Risk:   Governor limit — 100 SOQL / 150 DML per transaction

   Fix:    Collect IDs in a Set, query outside loop, use Map for lookup.
   Pattern:
     Map<Id, Account> accMap = new Map<Id, Account>(
       [SELECT Id, Name FROM Account WHERE Id IN :idSet]
     );

Rule 2 — No Hardcoded Salesforce IDs (HARD BLOCK)

Detect 15 or 18-character Salesforce IDs in .cls, .trigger, .js, .html, .xml:

  • Pattern: [a-zA-Z0-9]{15} or [a-zA-Z0-9]{18} in string literals
  • Common prefixes: 001, 003, 005, 006, 012, 0RT, 0PS

On violation:

❌ SALESFORCE GUARD — Hardcoded Salesforce ID
   File:   [filename]:[line]
   Found:  '[hardcoded ID]'
   Risk:   Breaks in every org — sandbox, production, scratch org IDs differ

   Fix options:
     Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName()
     .get('Customer').getRecordTypeId()

     Custom Metadata Type:  MyConfig__mdt.getInstance('key').Value__c
     Custom Label:          System.Label.MyLabel

Rule 3 — Triggers Must Be Thin (Handler Pattern)

If a .trigger file contains more than 20 lines of business logic:

⚠️  SALESFORCE GUARD — Fat trigger detected
   File:   [trigger file]
   Lines:  [count] of logic in trigger body

   Pattern: Triggers should be 5-10 lines max — delegate to handler class.
   
   AccountTrigger.trigger:
     trigger AccountTrigger on Account (before insert, after insert, ...) {
         AccountTriggerHandler.handle(Trigger.new, Trigger.oldMap, Trigger.operationType);
     }

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. 6d ago First seen · 127 lines · 66 tokens per session scan A e6b376de8d7c

Subscribe to this mod's changes

salesforce-guard is an agent published in the GitHub repository giggsoinc/raven (5 stars, last pushed 6d ago), licensed MIT. It adds 66 tokens to every session and 1,038 once invoked, about $0.0003 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.