SF-AI-Knowledgehub / templates
Copilot instructions1 starsChanged 8 months agoMITView on GitHub
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.
In this repository2 other files it gives its agents.
- templates/AGENTS.mdAGENTS.md
- templates/CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
17 rules. About 0 are common, 10 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 5
NEVER generate code that violates the following rules.
- Very specific: line 8
NEVER place a SOQL query inside a for or while loop.
- Very specific: line 9
NEVER place a DML statement (insert, update, delete, undelete) inside a loop.
- Distinctive: line 10
Always assume code will process a list of 200+ records.
- Distinctive: line 11
If processing or querying large datasets, queries MUST be selective (use indexed fields) and use SOQL for-loops to prevent Heap Size …
- Distinctive: line 14
Always enforce Object and Field-Level Security.
- Very specific: line 16
Do not use WITH SECURITY_ENFORCED as it is deprecated in favor of WITH USER_MODE.
- Very specific: line 17
When performing DML, use as user (e.g., insert as user myRecordList;).
- Distinctive: line 19
NEVER output PII, PHI, or raw HTTP payloads into System.debug().
- Distinctive: line 22
Never write logic directly inside an Apex Trigger.
- Distinctive: line 23
Before writing a Trigger, verify if the logic could be better handled by a Before-Save Flow or After-Save Flow.
- Distinctive: line 24
Ensure code accounts for recursion.
- Very specific: line 27
NEVER use (SeeAllData=true).
- Very specific: line 28
Do not write test classes just to achieve 75% coverage.
- Very specific: line 29
Always use Test.startTest() and Test.stopTest() to reset governor limits.
- Distinctive: line 32
Do not hardcode Salesforce IDs.
- Distinctive: line 33
Use early returns in your methods to avoid deep nesting.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
fororwhileloop. - 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_MODEto the query. - Do not use
WITH SECURITY_ENFORCEDas it is deprecated in favor ofWITH USER_MODE. - When performing DML, use
as user(e.g.,insert as user myRecordList;). - Explicitly declare class sharing using
with sharingunless there is a documented, architect-approved reason to usewithout 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@testSetupmethod or a Data Factory. - Do not write test classes just to achieve 75% coverage. You must write
System.assertorSystem.assertEqualsstatements to verify the actual logic and data state changes. - Always use
Test.startTest()andTest.stopTest()to reset governor limits.
5. Coding Standards
- Do not hardcode Salesforce IDs. Use Custom Labels, Custom Metadata Types, or query for the ID.
- Use early returns in your methods to avoid deep nesting.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

