The Experience
Copilot in VS Code paired with the Salesforce Extension Pack gives you autocomplete for Apex classes, LWC components, SOQL queries, and Flow XML. Agent mode (introduced 2025, expanded through 2026) handles multi-file refactors with explicit edits you can review. The chat panel answers “how do I” questions and can read your open file as context. Copilot CLI extends the same models to terminal workflows for sf CLI scripting.
What works without extra config:
- Method-level Apex completion from JavaDoc-style comments
- Standard SOQL skeletons (often missing WITH USER_MODE — review)
- LWC scaffolding (template + JS + meta XML) from descriptive comments
- Test class structure with mock data (often using SeeAllData=true — fix)
- Common bulkification patterns
Strong Patterns
Trigger framework implementations once you’ve taught it your base class. Test class scaffolding with Test.startTest()/stopTest(), mock data, and assertion stubs. SOQL query patterns and basic optimization (LIMIT, ORDER BY, indexed filter selection). LWC component structure with proper @api and @track decorators. Standard Salesforce patterns are well-represented in Copilot’s training data because GitHub indexes a huge volume of public Apex repos.
Weak Patterns
Salesforce-specific governor-limit awareness — Copilot will sometimes generate code that violates limits silently, particularly SOQL or DML inside loops in non-obvious code paths. Novel or custom org patterns it can’t have learned (your TriggerHandler, your Selector base class, your specific FLS approach). Integration-heavy code involving MCP servers, IntegrationHub spokes, or Named Credentials with the newer per-user external credentials. Anything that depends on metadata it can’t see (validation rules that affect a DML pattern, sharing rules that change SOQL behavior).
// Common Copilot trap: SOQL inside loop
// Copilot suggests this:
for (Account a : accountIds) {
List<Contact> contacts = [SELECT Id FROM Contact WHERE AccountId = :a];
// ...
}
// Should be a single bulk SOQL outside the loop
// with results assembled into a Map<Id, List<Contact>>.
// Always review for this pattern.
Configuration
Enable Copilot custom instructions via .github/copilot-instructions.md in the repo root. Describe your org’s patterns, style guide, and common utilities. This reduces generic suggestions that don’t fit your codebase and aligns Copilot’s output with your code review standards. Add per-language instructions for Apex and LWC, and document the trigger framework class name explicitly.
.github/copilot-instructions.md (excerpt):
- All triggers must extend our TriggerHandler base; never write raw triggers.
- All SOQL must use WITH USER_MODE unless explicitly system-mode justified.
- Tests must use TestDataFactory; never use SeeAllData=true.
- LWC: use lightning/uiRecordApi via @wire when reactive; imperative only for one-shot ops.
- Permissions: grant via Permission Set; never on Profile.
- Naming: PascalCase for Apex classes, camelCase for methods, ALL_CAPS for constants.
When to Pick Copilot Over Alternatives
Pick Copilot if your team already standardizes on GitHub for code review and you want a single AI vendor across all languages. Pick Cursor for stronger multi-file refactor and project-wide context. Pick Vibes 2.0 if the workflow is heavy on org schema and Salesforce CLI integration.
What to Do This Week
Add a .github/copilot-instructions.md to your Salesforce repo capturing trigger framework, FLS expectation, test data convention, and Permission Set policy. Re-run a PR through Copilot’s review and compare suggestion quality.