Prompt Library
Reusable prompts for common Salesforce development tasks with Cursor
This library contains battle-tested prompts for common Salesforce development tasks. Copy and paste these prompts into Cursor's AI chat, and customize them for your specific needs.

Pro Tip
When using these prompts, reference specific files with the @ symbol (e.g., @force-app/main/default/lwc/myComponent) to give the AI more context.
Data Generation & Management
Fill Up the Activity Timeline with Data
Use this prompt to populate an Account with realistic activity data, perfect for demos or testing.
This record in Salesforce is an account: 001gK00000CLuptQAD
Please use the MCP and CLI to fill it with events, tasks, EmailMessages, and more
to make it look like the activity timeline over the last 12 months is full of activity.
You can relate any deal-specific communication to this closed-won opportunity -
RecordId is 006gK000003subNQAQ - and relate any task, EmailMessage, event to the
main contact on the account, the CEO, Bobby Gibbs - RecordId 003gK000005UgzpQAC.Customization:
- Replace the Account ID with your record ID
- Adjust the time period (change "12 months" to your needs)
- Add or remove activity types as needed
Generate Test Data for Custom Objects
@salesforce create 50 test records for the Property__c custom object. Each record should have:
- Name: A realistic property address
- Price__c: A random value between $200,000 and $2,000,000
- Bedrooms__c: A random number between 1 and 5
- Bathrooms__c: A random number between 1 and 4
- Status__c: Randomly choose from "Available", "Pending", "Sold"
- City__c: Randomly choose from "San Francisco", "Los Angeles", "San Diego", "Seattle"
Make sure the data feels realistic and varied.Lightning Web Components
Create a Data Table Component
Create a Lightning Web Component that displays Account records in a data table with the following features:
- Columns: Name, Industry, Type, Annual Revenue, Phone
- Sortable columns
- Search/filter functionality
- Row actions for View and Edit
- Responsive design using SLDS
- Error handling for data loading
Place it in force-app/main/default/lwc/accountDataTableCreate a Form Component with Validation
Create a Lightning Web Component form for creating Contact records with:
- Fields: First Name, Last Name, Email, Phone, Title
- Client-side validation (required fields, email format, phone format)
- Success/error toast messages
- Account lookup field
- Cancel and Save buttons
- Loading spinner during save
Use modern LWC patterns and follow Salesforce best practices.Build a Chart Component
Create a Lightning Web Component that displays a chart using Chart.js showing:
- Opportunities by Stage (Bar Chart)
- Data should be fetched from Apex using wire adapter
- Include a date range filter (Last 30 Days, Last 90 Days, This Year)
- Responsive and mobile-friendly
- Loading state while data is being fetched
Include all necessary files: HTML, JS, CSS, and meta.xmlApex Development
Create an Apex Controller
Create an Apex controller class named AccountController with these methods:
- getAccounts(): Return top 10 Accounts with fields Id, Name, Industry, Type, AnnualRevenue
- searchAccounts(String searchTerm): Search Accounts by Name
- updateAccount(Id accountId, Map<String, Object> fields): Update Account fields
- createAccount(Account acc): Create new Account with error handling
Include proper @AuraEnabled annotations, error handling, and security checks (with sharing).
Also create a corresponding test class with 100% coverage.Build a Trigger with Handler Pattern
Create a trigger and handler for the Opportunity object following best practices:
- Trigger: OpportunityTrigger (handles before/after insert, update)
- Handler: OpportunityTriggerHandler with these methods:
- beforeInsert: Validate required fields
- afterInsert: Create default tasks for new opps
- beforeUpdate: Prevent closing without Products
- afterUpdate: Update Account total revenue
Include bulkification, recursion prevention, and a test class.Flows & Automation
Create a Screen Flow
Help me design a Screen Flow for the following user journey:
1. Welcome screen explaining the process
2. Collect customer information (Name, Email, Phone, Company)
3. Display available product options from a custom object
4. Allow user to select multiple products
5. Show a summary screen with total price
6. Create an Opportunity with selected products on confirmation
Provide the flow structure in a clear format I can implement in Flow Builder.SOQL Queries
Complex Query with Relationships
@salesforce write a SOQL query that:
- Selects from Opportunity
- Includes related Account fields (Name, Industry, BillingCity)
- Includes related Owner fields (Name, Email)
- Filters for Opportunities closed in the last 90 days
- Filters for specific stages: "Closed Won", "Closed Lost"
- Ordered by CloseDate descending
- Limited to 100 records
- Includes aggregate information about related OpportunityLineItemsQuery for Reports and Dashboards
@salesforce create a SOQL query for a sales leaderboard showing:
- Owner Name
- Count of Opportunities
- Total Opportunity Amount
- Win Rate (percentage)
- Group by Owner
- Filter for current fiscal year
- Order by Total Amount descendingDeployment & DevOps
Deploy Specific Components
@salesforce deploy only the following components to my sandbox:
- LWC: myCustomComponent
- Apex Class: MyCustomController
- Apex Class: MyCustomControllerTest
Use the appropriate CLI commands and show me the deployment status.Create a Package.xml
Generate a package.xml file that includes:
- All LWC components in the lwc folder
- All Apex classes and triggers
- All custom objects starting with "Property_"
- All Permission Sets
- API version 60.0
Format it properly and explain each section.Testing & Quality
Generate Test Data in Apex Test
Show me how to create comprehensive test data in an Apex test class for:
- 5 Accounts with different Industries
- 10 Contacts related to these Accounts
- 15 Opportunities related to these Accounts in various Stages
- 30 OpportunityLineItems related to these Opportunities
Use best practices: test data factory pattern, proper relationships, and varied data.Integration
Create a REST API Callout
Create an Apex class that makes a REST API callout to an external service:
- Endpoint: https://api.example.com/data
- Method: GET with query parameters
- Include authentication header
- Parse JSON response
- Handle errors gracefully
- Include logging
- Create a corresponding test class with mock calloutQuick Tips for Better Prompts
- Be Specific: Include exact field names, object API names, and requirements
- Provide Context: Use
@filenameto reference existing files - Request Explanations: Ask "explain why" to learn as you build
- Iterate: Start simple, then ask for enhancements
- Test Code: Always ask for test classes and error handling
Prompt Writing Best Practices
- Use Active Voice: "Create a component" vs "A component should be created"
- List Requirements: Use bullet points or numbered lists
- Specify Technology: Mention LWC, Aura, Flow, etc. explicitly
- Include Edge Cases: Mention error handling, null checks, etc.
- Request Documentation: Ask for inline comments and JSDoc

Advanced Prompting Techniques
Chain of Thought
Let's build this step by step:
1. First, create the Apex controller
2. Then, create the LWC that uses it
3. Finally, create the test class
Explain your reasoning at each step.Comparative Analysis
Compare these two approaches for [problem]:
1. [Approach A]
2. [Approach B]
Recommend which is better for my use case and why.Code Review
Review this code for:
- Security vulnerabilities (SOQL injection, XSS, etc.)
- Performance issues (bulk limits, SOQL queries in loops)
- Best practices (naming conventions, error handling)
- Salesforce-specific recommendationsCreating Your Own Prompts
When creating your own prompt library, consider:
- Context: What background information does the AI need?
- Constraints: What limitations or requirements exist?
- Format: How should the output be structured?
- Validation: How will you verify the results?
Share Your Prompts
Found a great prompt? Consider sharing it with other Salesforce SEs or the greater SE community on Slack! You can also create a pull request to contribute it to this documentation.
Next Steps
- Learn how to build Agentforce agents using these prompting techniques
- Explore advanced Cursor features for power users
- Check out the Architecture section to understand Salesforce development patterns