agentleFS
mssm-sftechstackmssm-sftechstack/SF-AI-Knowledgehub/templates/copilot-instructions.md

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.

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
  1. Distinctive:

    NEVER generate code that violates the following rules.

    line 5
  2. Very specific:

    NEVER place a SOQL query inside a for or while loop.

    line 8
  3. Very specific:

    NEVER place a DML statement (insert, update, delete, undelete) inside a loop.

    line 9
  4. Distinctive:

    Always assume code will process a list of 200+ records.

    line 10
  5. Distinctive:

    If processing or querying large datasets, queries MUST be selective (use indexed fields) and use SOQL for-loops to prevent Heap Size …

    line 11
  6. Distinctive:

    Always enforce Object and Field-Level Security.

    line 14
  7. Very specific:

    Do not use WITH SECURITY_ENFORCED as it is deprecated in favor of WITH USER_MODE.

    line 16
  8. Very specific:

    When performing DML, use as user (e.g., insert as user myRecordList;).

    line 17
  9. Distinctive:

    NEVER output PII, PHI, or raw HTTP payloads into System.debug().

    line 19
  10. Distinctive:

    Never write logic directly inside an Apex Trigger.

    line 22
  11. Distinctive:

    Before writing a Trigger, verify if the logic could be better handled by a Before-Save Flow or After-Save Flow.

    line 23
  12. Distinctive:

    Ensure code accounts for recursion.

    line 24
  13. Very specific:

    NEVER use (SeeAllData=true).

    line 27
  14. Very specific:

    Do not write test classes just to achieve 75% coverage.

    line 28
  15. Very specific:

    Always use Test.startTest() and Test.stopTest() to reset governor limits.

    line 29
  16. Distinctive:

    Do not hardcode Salesforce IDs.

    line 32
  17. Distinctive:

    Use early returns in your methods to avoid deep nesting.

    line 33

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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.

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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.