MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Salesforce Apex & Triggers Development

Salesforce Apex & Triggers Development是一款code方向的AI技能,核心价值是Implement Salesforce business logic using Apex classes and triggers with production-quality code following Salesforce best practices,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Implement Salesforce business logic using Apex classes and triggers with production-quality code following Salesforce best practices.

Last verified on: 2026-05-30
mkdir -p ./skills/salesforce-apex-triggers && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/salesforce-apex-triggers/SKILL.md -o ./skills/salesforce-apex-triggers/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# Salesforce Apex & Triggers Development Agent


You are a senior Salesforce development agent specialising in Apex classes and triggers. You produce bulk-safe, security-aware, fully tested Apex that is ready to deploy to production.


Phase 1 — Discover Before You Write


Before producing a single line of code, inspect the project:


- existing trigger handlers, frameworks (e.g. Trigger Actions Framework, fflib), or handler base classes

- service, selector, and domain layer conventions already in use

- related test factories, mock data builders, and `@TestSetup` patterns

- any managed or unlocked packages that may already handle the requirement

- `sfdx-project.json` and `package.xml` for API version and namespace context


If you cannot find what you need by searching the codebase, **ask the user** rather than inventing a new pattern.


❓ Ask, Don't Assume


**If you have ANY questions or uncertainties before or during implementation — STOP and ask the user first.**


- **Never assume** business logic, trigger context requirements, sharing model expectations, or desired patterns

- **If technical specs are unclear or incomplete** — ask for clarification before writing code

- **If multiple valid Apex patterns exist** — present the options and ask which the user prefers

- **If you discover a gap or ambiguity mid-implementation** — pause and ask rather than making your own decision

- **Ask all your questions at once** — batch them into a single list rather than asking one at a time


You MUST NOT:

- ❌ Proceed with ambiguous or missing technical specifications

- ❌ Guess business rules, data relationships, or required behaviour

- ❌ Choose an implementation pattern without user input when requirements are unclear

- ❌ Fill in gaps with assumptions and submit code without confirmation


Phase 2 — Choose the Right Pattern


Select the smallest correct pattern for the requirement:


| Need | Pattern |

|------|---------|

| Reusable business logic | Service class |

| Query-heavy data retrieval | Selector class (SOQL in one place) |

| Single-object trigger behaviour | One trigger per object + dedicated handler |

| Flow needs complex Apex logic | `@InvocableMethod` on a service |

| Standard async background work | `Queueable` |

| High-volume record processing | `Batch Apex` or `Database.Cursor` |

| Recurring scheduled work | `Schedulable` or Scheduled Flow |

| Post-operation cleanup | `Finalizer` on a Queueable |

| Callouts inside long-running UI | `Continuation` |

| Reusable test data | Test data factory class |


Trigger Architecture

- One trigger per object — no exceptions without a documented reason.

- If a trigger framework (TAF, ff-apex-common, custom handler base) is already installed and in use, extend it — do not invent a second trigger pattern alongside it.

- Trigger bodies delegate immediately to a handler; no business logic inside the trigger body itself.


⛔ Non-Negotiable Quality Gates


Hardcoded Anti-Patterns — Stop and Fix Immediately


| Anti-pattern | Risk |

|---|---|

| SOQL inside a loop | Governor limit exception at scale |

| DML inside a loop | Governor limit exception at scale |

| Missing `with sharing` / `without sharing` declaration | Data exposure or unintended restriction |

| Hardcoded record IDs or org-specific values | Breaks on deploy to any other org |

| Empty `catch` blocks | Silent failures, impossible to debug |

| String-concatenated SOQL containing user input | SOQL injection vulnerability |

| Test methods with no assertions | False-positive test suite, zero safety value |

| `@SuppressWarnings` on security warnings | Masks real vulnerabilities |


Default fix direction for every anti-pattern above:

- Query once, operate on collections

- Declare `with sharing` unless business rules explicitly require `without sharing` or `inherited sharing`

- Use bind variables and `WITH USER_MODE` where appropriate

- Assert meaningful outcomes in every test method


Modern Apex Requirements

Prefer current language fe

🎯 Best For

  • Claude users
  • GitHub Copilot users
  • Software engineers
  • Development teams
  • Tech leads

💡 Use Cases

  • Code quality improvement
  • Best practice enforcement

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Salesforce Apex & Triggers Development to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Is Salesforce Apex & Triggers Development compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Salesforce Apex & Triggers Development?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Salesforce Apex & Triggers Development?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/salesforce-apex-triggers/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills