[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-e65085c5-abc2-4a53-b51c-f3a6f9e28532":3,"$f_gscnq5I4uxAZmu6Oq9iKUza3KdqJJ-wVzERTBhPHjg":43},{"id":4,"title":5,"description":6,"categoryId":7,"moduleId":8,"tags":9,"prompt":10,"icon":11,"source":12,"sourceUrl":13,"authorId":14,"authorName":15,"isPublic":16,"stars":17,"runs":18,"createdAt":19,"updatedAt":19,"module":20,"category":27,"packages":34},"e65085c5-abc2-4a53-b51c-f3a6f9e28532","salesforce-development","Salesforce平台开发的专业模式包括","cat_life_career","mod_other","sickn33,other","---\nname: salesforce-development\ndescription: Expert patterns for Salesforce platform development including\n  Lightning Web Components (LWC), Apex triggers and classes, REST\u002FBulk APIs,\n  Connected Apps, and Salesforce DX with scratch orgs and 2nd generation\n  packages (2GP).\nrisk: safe\nsource: vibeship-spawner-skills (Apache 2.0)\ndate_added: 2026-02-27\n---\n\n# Salesforce Development\n\nExpert patterns for Salesforce platform development including Lightning Web\nComponents (LWC), Apex triggers and classes, REST\u002FBulk APIs, Connected Apps,\nand Salesforce DX with scratch orgs and 2nd generation packages (2GP).\n\n## Patterns\n\n### Lightning Web Component with Wire Service\n\nUse @wire decorator for reactive data binding with Lightning Data Service\nor Apex methods. @wire fits LWC's reactive architecture and enables\nSalesforce performance optimizations.\n\n\u002F\u002F myComponent.js\nimport { LightningElement, wire, api } from 'lwc';\nimport { getRecord, getFieldValue } from 'lightning\u002FuiRecordApi';\nimport getRelatedRecords from '@salesforce\u002Fapex\u002FMyController.getRelatedRecords';\nimport ACCOUNT_NAME from '@salesforce\u002Fschema\u002FAccount.Name';\nimport ACCOUNT_INDUSTRY from '@salesforce\u002Fschema\u002FAccount.Industry';\n\nconst FIELDS = [ACCOUNT_NAME, ACCOUNT_INDUSTRY];\n\nexport default class MyComponent extends LightningElement {\n  @api recordId;  \u002F\u002F Passed from parent or record page\n\n  \u002F\u002F Wire to Lightning Data Service (preferred for single records)\n  @wire(getRecord, { recordId: '$recordId', fields: FIELDS })\n  account;\n\n  \u002F\u002F Wire to Apex method (for complex queries)\n  @wire(getRelatedRecords, { accountId: '$recordId' })\n  wiredRecords({ error, data }) {\n    if (data) {\n      this.relatedRecords = data;\n      this.error = undefined;\n    } else if (error) {\n      this.error = error;\n      this.relatedRecords = undefined;\n    }\n  }\n\n  get accountName() {\n    return getFieldValue(this.account.data, ACCOUNT_NAME);\n  }\n\n  get isLoading() {\n    return !this.account.data && !this.account.error;\n  }\n\n  \u002F\u002F Reactive: changing recordId automatically re-fetches\n}\n\n\u002F\u002F myComponent.html\n\u003Ctemplate>\n  \u003Clightning-card title={accountName}>\n    \u003Ctemplate if:true={isLoading}>\n      \u003Clightning-spinner alternative-text=\"Loading\">\u003C\u002Flightning-spinner>\n    \u003C\u002Ftemplate>\n\n    \u003Ctemplate if:true={account.data}>\n      \u003Cp>Industry: {industry}\u003C\u002Fp>\n    \u003C\u002Ftemplate>\n\n    \u003Ctemplate if:true={error}>\n      \u003Cp class=\"slds-text-color_error\">{error.body.message}\u003C\u002Fp>\n    \u003C\u002Ftemplate>\n  \u003C\u002Flightning-card>\n\u003C\u002Ftemplate>\n\n\u002F\u002F MyController.cls\npublic with sharing class MyController {\n  @AuraEnabled(cacheable=true)\n  public static List\u003CContact> getRelatedRecords(Id accountId) {\n    return [\n      SELECT Id, Name, Email, Phone\n      FROM Contact\n      WHERE AccountId = :accountId\n      WITH SECURITY_ENFORCED\n      LIMIT 100\n    ];\n  }\n}\n\n### Context\n\n- building LWC components\n- fetching Salesforce data\n- reactive UI\n\n### Bulkified Apex Trigger with Handler Pattern\n\nApex triggers must be bulkified to handle 200+ records per transaction.\nUse handler pattern for separation of concerns, testability, and\nrecursion prevention.\n\n\u002F\u002F AccountTrigger.trigger\ntrigger AccountTrigger on Account (\n  before insert, before update, before delete,\n  after insert, after update, after delete, after undelete\n) {\n  new AccountTriggerHandler().run();\n}\n\n\u002F\u002F TriggerHandler.cls (base class)\npublic virtual class TriggerHandler {\n  \u002F\u002F Recursion prevention\n  private static Set\u003CString> executedHandlers = new Set\u003CString>();\n\n  public void run() {\n    String handlerName = String.valueOf(this).split(':')[0];\n\n    \u002F\u002F Prevent recursion\n    String contextKey = handlerName + '_' + Trigger.operationType;\n    if (executedHandlers.contains(contextKey)) {\n      return;\n    }\n    executedHandlers.add(contextKey);\n\n    switch on Trigger.operationType {\n      when BEFORE_INSERT { this.beforeInsert(); }\n      when BEFORE_UPDATE { this.beforeUpdate(); }\n      when BEFORE_DELETE { this.beforeDelete(); }\n      when AFTER_INSERT { this.afterInsert(); }\n      when AFTER_UPDATE { this.afterUpdate(); }\n      when AFTER_DELETE { this.afterDelete(); }\n      when AFTER_UNDELETE { this.afterUndelete(); }\n    }\n  }\n\n  \u002F\u002F Override in child classes\n  protected virtual void beforeInsert() {}\n  protected virtual void beforeUpdate() {}\n  protected virtual void beforeDelete() {}\n  protected virtual void afterInsert() {}\n  protected virtual void afterUpdate() {}\n  protected virtual void afterDelete() {}\n  protected virtual void afterUndelete() {}\n}\n\n\u002F\u002F AccountTriggerHandler.cls\npublic class AccountTriggerHandler extends TriggerHandler {\n  private List\u003CAccount> newAccounts;\n  private List\u003CAccount> oldAccounts;\n  private Map\u003CId, Account> newMap;\n  private Map\u003CId, Account> oldMap;\n\n  public AccountTriggerHandler() {\n    this.newAccounts = (List\u003CAccount>) Trigger.new;\n    this.oldAccounts = (List\u003CAccount>) Trigger.old;\n    this.newMap = (Map\u003CId, Account>) Trigger.newMap;\n    this.oldMap = (Map\u003CId, Account>) Trigger.oldMap;\n  }\n\n  protected override void afterInsert() {\n    createDefaultContacts();\n    notifySlack();\n  }\n\n  protected override void afterUpdate() {\n    handleIndustryChange();\n  }\n\n  \u002F\u002F BULKIFIED: Query once, update once\n  private void createDefaultContacts() {\n    List\u003CContact> contactsToInsert = new List\u003CContact>();\n\n    for (Account acc : newAccounts) {\n      if (acc.Type == 'Prospect') {\n        contactsToInsert.add(new Contact(\n          AccountId = acc.Id,\n          LastName = 'Primary Contact',\n          Email = 'contact@' + acc.Website\n        ));\n      }\n    }\n\n    if (!contactsToInsert.isEmpty()) {\n      insert contactsToInsert;  \u002F\u002F Single DML for all\n    }\n  }\n\n  private void handleIndustryChange() {\n    Set\u003CId> changedAccountIds = new Set\u003CId>();\n\n    for (Account acc : newAccounts) {\n      Account oldAcc = oldMap.get(acc.Id);\n      if (acc.Industry != oldAcc.Industry) {\n        changedAccountIds.add(acc.Id);\n      }\n    }\n\n    if (!changedAccountIds.isEmpty()) {\n      \u002F\u002F Queue async processing for heavy work\n      System.enqueueJob(new IndustryChangeQueueable(changedAccountIds));\n    }\n  }\n\n  private void notifySlack() {\n    \u002F\u002F Offload callouts to async\n    List\u003CId> accountIds = new List\u003CId>(newMap.keySet());\n    System.enqueueJob(new SlackNotificationQueueable(accountIds));\n  }\n}\n\n### Context\n\n- apex triggers\n- data operations\n- automation\n\n### Queueable Apex for Async Processing\n\nUse Queueable Apex for async processing with support for non-primitive\ntypes, monitoring via AsyncApexJob, and job chaining. Limit: 50 jobs\nper transaction, 1 child job when chaining.\n\n\u002F\u002F IndustryChangeQueueable.cls\npublic class IndustryChangeQueueable implements Queueable, Database.AllowsCallouts {\n  private Set\u003CId> accountIds;\n  private Integer retryCount;\n\n  public IndustryChangeQueueable(Set\u003CId> accountIds) {\n    this(accountIds, 0);\n  }\n\n  public IndustryChangeQueueable(Set\u003CId> accountIds, Integer retryCount) {\n    this.accountIds = accountIds;\n    this.retryCount = retryCount;\n  }\n\n  public void execute(QueueableContext context) {\n    try {\n      \u002F\u002F Query with fresh data\n      List\u003CAccount> accounts = [\n        SELECT Id, Name, Industry, OwnerId\n        FROM Account\n        WHERE Id IN :accountIds\n        WITH SECURITY_ENFORCED\n      ];\n\n      \u002F\u002F Process and make callout\n      for (Account acc : accounts) {\n        syncToExternalSystem(acc);\n      }\n\n      \u002F\u002F Update records\n      updateRelatedOpportunities(accountIds);\n\n    } catch (Exception e) {\n      handleError(e);\n    }\n  }\n\n  private void syncToExternalSystem(Account acc) {\n    HttpRequest req = new HttpRequest();\n    req.setEndpoint('callout:ExternalCRM\u002Faccounts');\n    req.setMethod('POST');\n    req.setHeader('Content-Type', 'application\u002Fjson');\n    req.setBody(JSON.serialize(new Map\u003CString, Object>{\n      'salesforceId' => acc.Id,\n      'name' => acc.Name,\n      'industry' => acc.Industry\n    }));\n\n    Http http = new Http();\n    HttpResponse res = http.send(req);\n\n    if (res.getStatusCode() != 200 && res.getStatusCode() != 201) {\n      throw new CalloutException('Sync failed: ' + res.getBody());\n    }\n  }\n\n  private void updateRelatedOpportunities(Set\u003CId> accIds) {\n    List\u003COpportunity> oppsToUpdate = [\n      SELECT Id, Industry__c, AccountId\n      FROM Opportunity\n      WHERE AccountId IN :accIds\n      WITH SECURITY_ENFORCED\n    ];\n\n    Map\u003CId, Account> accountMap = new Map\u003CId, Account>([\n      SELECT Id, Industry FROM Account WHERE Id IN :accIds\n    ]);\n\n    for (Opportunity opp : oppsToUpdate) {\n      opp.Industry__c = accountMap.get(opp.AccountId).Industry;\n    }\n\n    if (!oppsToUpdate.isEmpty()) {\n      update oppsToUpdate;\n    }\n  }\n\n  private void handleError(Exception e) {\n    \u002F\u002F Log error\n    System.debug(LoggingLevel.ERROR, 'Queueable failed: ' + e.getMessage());\n\n    \u002F\u002F Retry with exponential backoff (max 3 retries)\n    if (retryCount \u003C 3) {\n      \u002F\u002F Chain new job for retry\n      System.enqueueJob(new IndustryChangeQueueable(accountIds, retryCount + 1));\n    } else {\n      \u002F\u002F Create error record for monitoring\n      insert new Integration_Error__c(\n        Type__c = 'Industry Sync',\n        Message__c = e.getMessage(),\n        Stack_Trace__c = e.getStackTraceString(),\n        Record_Ids__c = String.join(new List\u003CId>(accountIds), ',')\n      );\n    }\n  }\n}\n\n### Context\n\n- async processing\n- long-running operations\n- callouts from triggers\n\n### REST API Integration with Connected App\n\nExternal integrations use Connected Apps with OAuth 2.0. JWT Bearer flow\nfor server-to-server, Web Server flow for user-facing apps. Always use\nNamed Credentials for secure callout configuration.\n\n\u002F\u002F Node.js - JWT Bearer Flow (server-to-server)\nimport jwt from 'jsonwebtoken';\nimport fs from 'fs';\n\nclass SalesforceClient {\n  private accessToken: string | null = null;\n  private instanceUrl: string | null = null;\n  private tokenExpiry: number = 0;\n\n  constructor(\n    private clientId: string,\n    private username: string,\n    private privateKeyPath: string,\n    private loginUrl: string = 'https:\u002F\u002Flogin.salesforce.com'\n  ) {}\n\n  async authenticate(): Promise\u003Cvoid> {\n    \u002F\u002F Check if token is still valid (5 min buffer)\n    if (this.accessToken && Date.now() \u003C this.tokenExpiry - 300000) {\n      return;\n    }\n\n    const privateKey = fs.readFileSync(this.privateKeyPath, 'utf8');\n\n    \u002F\u002F Create JWT assertion\n    const claim = {\n      iss: this.clientId,\n      sub: this.username,\n      aud: this.loginUrl,\n      exp: Math.floor(Date.now() \u002F 1000) + 300  \u002F\u002F 5 minutes\n    };\n\n    const assertion = jwt.sign(claim, privateKey, { algorithm: 'RS256' });\n\n    \u002F\u002F Exchange JWT for access token\n    const response = await fetch(`${this.loginUrl}\u002Fservices\u002Foauth2\u002Ftoken`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application\u002Fx-www-form-urlencoded' },\n      body: new URLSearchParams({\n        grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',\n        assertion\n      })\n    });\n\n    if (!response.ok) {\n      const error = await response.json();\n      throw new Error(`Auth failed: ${error.error_description}`);\n    }\n\n    const data = await response.json();\n    this.accessToken = data.access_token;\n    this.instanceUrl = data.instance_url;\n    this.tokenExpiry = Date.now() + 7200000;  \u002F\u002F 2 hours\n  }\n\n  async query(soql: string): Promise\u003Cany> {\n    await this.authenticate();\n\n    const response = await fetch(\n      `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fquery?q=${encodeURIComponent(soql)}`,\n      {\n        headers: {\n          'Authorization': `Bearer ${this.accessToken}`,\n          'Content-Type': 'application\u002Fjson'\n        }\n      }\n    );\n\n    if (!response.ok) {\n      await this.handleError(response);\n    }\n\n    return response.json();\n  }\n\n  async createRecord(sobject: string, data: object): Promise\u003Cany> {\n    await this.authenticate();\n\n    const response = await fetch(\n      `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fsobjects\u002F${sobject}`,\n      {\n        method: 'POST',\n        headers: {\n          'Authorization': `Bearer ${this.accessToken}`,\n          'Content-Type': 'application\u002Fjson'\n        },\n        body: JSON.stringify(data)\n      }\n    );\n\n    if (!response.ok) {\n      await this.handleError(response);\n    }\n\n    return response.json();\n  }\n\n  private async handleError(response: Response): Promise\u003Cnever> {\n    const error = await response.json();\n\n    if (response.status === 401) {\n      \u002F\u002F Token expired, clear and retry\n      this.accessToken = null;\n      throw new Error('Session expired, retry required');\n    }\n\n    throw new Error(`API Error: ${JSON.stringify(error)}`);\n  }\n}\n\n\u002F\u002F Usage\nconst sf = new SalesforceClient(\n  process.env.SF_CLIENT_ID!,\n  process.env.SF_USERNAME!,\n  '.\u002Fcertificates\u002Fserver.key'\n);\n\nconst accounts = await sf.query(\n  \"SELECT Id, Name FROM Account WHERE CreatedDate = TODAY\"\n);\n\n### Context\n\n- external integration\n- REST API access\n- connected apps\n\n### Bulk API 2.0 for Large Data Operations\n\nUse Bulk API 2.0 for operations on 10K+ records. Asynchronous processing\nwith job-based workflow. Part of REST API with streamlined interface\ncompared to original Bulk API.\n\n\u002F\u002F Node.js - Bulk API 2.0 insert\nclass SalesforceBulkClient extends SalesforceClient {\n\n  async bulkInsert(sobject: string, records: object[]): Promise\u003Cany> {\n    await this.authenticate();\n\n    \u002F\u002F Step 1: Create job\n    const job = await this.createBulkJob(sobject, 'insert');\n\n    try {\n      \u002F\u002F Step 2: Upload data (CSV format)\n      await this.uploadJobData(job.id, records);\n\n      \u002F\u002F Step 3: Close job to start processing\n      await this.closeJob(job.id);\n\n      \u002F\u002F Step 4: Poll for completion\n      return await this.waitForJobCompletion(job.id);\n\n    } catch (error) {\n      \u002F\u002F Abort job on error\n      await this.abortJob(job.id);\n      throw error;\n    }\n  }\n\n  private async createBulkJob(sobject: string, operation: string): Promise\u003Cany> {\n    const response = await fetch(\n      `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fjobs\u002Fingest`,\n      {\n        method: 'POST',\n        headers: {\n          'Authorization': `Bearer ${this.accessToken}`,\n          'Content-Type': 'application\u002Fjson'\n        },\n        body: JSON.stringify({\n          object: sobject,\n          operation,\n          contentType: 'CSV',\n          lineEnding: 'LF'\n        })\n      }\n    );\n\n    return response.json();\n  }\n\n  private async uploadJobData(jobId: string, records: object[]): Promise\u003Cvoid> {\n    \u002F\u002F Convert to CSV\n    const csv = this.recordsToCSV(records);\n\n    await fetch(\n      `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fjobs\u002Fingest\u002F${jobId}\u002Fbatches`,\n      {\n        method: 'PUT',\n        headers: {\n          'Authorization': `Bearer ${this.accessToken}`,\n          'Content-Type': 'text\u002Fcsv'\n        },\n        body: csv\n      }\n    );\n  }\n\n  private async closeJob(jobId: string): Promise\u003Cvoid> {\n    await fetch(\n      `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fjobs\u002Fingest\u002F${jobId}`,\n      {\n        method: 'PATCH',\n        headers: {\n          'Authorization': `Bearer ${this.accessToken}`,\n          'Content-Type': 'application\u002Fjson'\n        },\n        body: JSON.stringify({ state: 'UploadComplete' })\n      }\n    );\n  }\n\n  private async waitForJobCompletion(jobId: string): Promise\u003Cany> {\n    const maxWaitTime = 10 * 60 * 1000;  \u002F\u002F 10 minutes\n    const pollInterval = 5000;  \u002F\u002F 5 seconds\n    const startTime = Date.now();\n\n    while (Date.now() - startTime \u003C maxWaitTime) {\n      const response = await fetch(\n        `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fjobs\u002Fingest\u002F${jobId}`,\n        {\n          headers: { 'Authorization': `Bearer ${this.accessToken}` }\n        }\n      );\n\n      const job = await response.json();\n\n      if (job.state === 'JobComplete') {\n        \u002F\u002F Get results\n        return {\n          success: job.numberRecordsProcessed - job.numberRecordsFailed,\n          failed: job.numberRecordsFailed,\n          failedResults: job.numberRecordsFailed > 0\n            ? await this.getFailedResults(jobId)\n            : []\n        };\n      }\n\n      if (job.state === 'Failed' || job.state === 'Aborted') {\n        throw new Error(`Bulk job failed: ${job.state}`);\n      }\n\n      await new Promise(r => setTimeout(r, pollInterval));\n    }\n\n    throw new Error('Bulk job timeout');\n  }\n\n  private async getFailedResults(jobId: string): Promise\u003Cany[]> {\n    const response = await fetch(\n      `${this.instanceUrl}\u002Fservices\u002Fdata\u002Fv59.0\u002Fjobs\u002Fingest\u002F${jobId}\u002FfailedResults`,\n      {\n        headers: { 'Authorization': `Bearer ${this.accessToken}` }\n      }\n    );\n\n    const csv = await response.text();\n    return this.parseCSV(csv);\n  }\n\n  private recordsToCSV(records: object[]): string {\n    if (records.length === 0) return '';\n\n    const headers = Object.keys(records[0]);\n    const rows = records.map(r =>\n      headers.map(h => this.escapeCSV(r[h])).join(',')\n    );\n\n    return [headers.join(','), ...rows].join('\\n');\n  }\n\n  private escapeCSV(value: any): string {\n    if (value === null || value === undefined) return '';\n    const str = String(value);\n    if (str.includes(',') || str.includes('\"') || str.includes('\\n')) {\n      return `\"${str.replace(\u002F\"\u002Fg, '\"\"')}\"`;\n    }\n    return str;\n  }\n}\n\n### Context\n\n- large data volumes\n- data migration\n- bulk operations\n\n### Salesforce DX with Scratch Orgs\n\nSource-driven development with disposable scratch orgs for isolated\ntesting. Scratch orgs exist 7-30 days and can be created throughout\nthe day, unlike sandbox refresh limits.\n\n\u002F\u002F project-scratch-def.json - Scratch org definition\n{\n  \"orgName\": \"MyApp Dev Org\",\n  \"edition\": \"Developer\",\n  \"features\": [\"EnableSetPasswordInApi\", \"Communities\"],\n  \"settings\": {\n    \"lightningExperienceSettings\": {\n      \"enableS1DesktopEnabled\": true\n    },\n    \"mobileSettings\": {\n      \"enableS1EncryptedStoragePref2\": false\n    },\n    \"securitySettings\": {\n      \"passwordPolicies\": {\n        \"enableSetPasswordInApi\": true\n      }\n    }\n  }\n}\n\n\u002F\u002F sfdx-project.json - Project configuration\n{\n  \"packageDirectories\": [\n    {\n      \"path\": \"force-app\",\n      \"default\": true,\n      \"package\": \"MyPackage\",\n      \"versionName\": \"ver 1.0\",\n      \"versionNumber\": \"1.0.0.NEXT\",\n      \"dependencies\": [\n        {\n          \"package\": \"SomePackage@2.0.0\"\n        }\n      ]\n    }\n  ],\n  \"namespace\": \"myns\",\n  \"sfdcLoginUrl\": \"https:\u002F\u002Flogin.salesforce.com\",\n  \"sourceApiVersion\": \"59.0\"\n}\n\n# Development workflow commands\n# 1. Create scratch org\nsf org create scratch \\\n  --definition-file config\u002Fproject-scratch-def.json \\\n  --alias myapp-dev \\\n  --duration-days 7 \\\n  --set-default\n\n# 2. Push source to scratch org\nsf project deploy start --target-org myapp-dev\n\n# 3. Assign permission set\nsf org assign permset --name MyApp_Admin --target-org myapp-dev\n\n# 4. Import sample data\nsf data import tree --plan data\u002Fsample-data-plan.json --target-org myapp-dev\n\n# 5. Open org\nsf org open --target-org myapp-dev\n\n# 6. Run tests\nsf apex run test \\\n  --code-coverage \\\n  --result-format human \\\n  --wait 10 \\\n  --target-org myapp-dev\n\n# 7. Pull changes back\nsf project retrieve start --target-org myapp-dev\n\n### Context\n\n- development workflow\n- CI\u002FCD\n- testing\n\n### 2nd Generation Package (2GP) Development\n\n2GP replaces 1GP with source-driven, modular packaging. Requires Dev Hub\nwith 2GP enabled, namespace linked, and 75% code coverage for promoted\npackages.\n\n# Enable Dev Hub and 2GP in Setup:\n# Setup > Dev Hub > Enable Dev Hub\n# Setup > Dev Hub > Enable Unlocked Packages and 2GP\n\n# Link namespace (required for managed packages)\nsf package create \\\n  --name \"MyManagedPackage\" \\\n  --package-type Managed \\\n  --path force-app \\\n  --target-dev-hub DevHub\n\n# Create package version (beta)\nsf package version create \\\n  --package \"MyManagedPackage\" \\\n  --installation-key-bypass \\\n  --wait 30 \\\n  --code-coverage \\\n  --target-dev-hub DevHub\n\n# Check version status\nsf package version list --packages \"MyManagedPackage\" --target-dev-hub DevHub\n\n# Promote to released (requires 75% coverage)\nsf package version promote \\\n  --package \"MyManagedPackage@1.0.0-1\" \\\n  --target-dev-hub DevHub\n\n# Install in sandbox for testing\nsf package install \\\n  --package \"MyManagedPackage@1.0.0-1\" \\\n  --target-org MySandbox \\\n  --wait 20\n\n# CI\u002FCD Pipeline (GitHub Actions)\n# .github\u002Fworkflows\u002Fsalesforce-ci.yml\nname: Salesforce CI\n\non:\n  push:\n    branches: [main, develop]\n  pull_request:\n    branches: [main]\n\njobs:\n  validate:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v4\n\n      - name: Install Salesforce CLI\n        run: npm install -g @salesforce\u002Fcli\n\n      - name: Authenticate Dev Hub\n        run: |\n          echo \"${{ secrets.SFDX_AUTH_URL }}\" > auth.txt\n          sf org login sfdx-url --sfdx-url-file auth.txt --alias DevHub --set-default-dev-hub\n\n      - name: Create Scratch Org\n        run: |\n          sf org create scratch \\\n            --definition-file config\u002Fproject-scratch-def.json \\\n            --alias ci-scratch \\\n            --duration-days 1 \\\n            --set-default\n\n      - name: Deploy Source\n        run: sf project deploy start --target-org ci-scratch\n\n      - name: Run Tests\n        run: |\n          sf apex run test \\\n            --code-coverage \\\n            --result-format human \\\n            --wait 20 \\\n            --target-org ci-scratch\n\n      - name: Delete Scratch Org\n        if: always()\n        run: sf org delete scratch --target-org ci-scratch --no-prompt\n\n### Context\n\n- packaging\n- ISV development\n- AppExchange\n\n## Sharp Edges\n\n### Governor Limits Apply Per Transaction, Not Per Record\n\nSeverity: CRITICAL\n\n### @wire Results Are Cached and May Be Stale\n\nSeverity: HIGH\n\n### LWC Properties Are Case-Sensitive\n\nSeverity: MEDIUM\n\n### Null Pointer Exceptions in Apex Collections\n\nSeverity: HIGH\n\n### Trigger Recursion Causes Infinite Loops\n\nSeverity: CRITICAL\n\n### Cannot Make Callouts from Synchronous Triggers\n\nSeverity: HIGH\n\n### Cannot Mix Setup and Non-Setup DML\n\nSeverity: HIGH\n\n### Dynamic SOQL Is Vulnerable to Injection\n\nSeverity: CRITICAL\n\n### Scratch Orgs Expire and Lose All Data\n\nSeverity: MEDIUM\n\n### API Version Mismatches Cause Silent Failures\n\nSeverity: MEDIUM\n\n## Validation Checks\n\n### SOQL Query Inside Loop\n\nSeverity: ERROR\n\nSOQL in loops causes governor limit exceptions with bulk data\n\nMessage: SOQL query inside loop. Query once outside the loop and use a Map.\n\n### DML Operation Inside Loop\n\nSeverity: ERROR\n\nDML in loops hits 150 statement limit\n\nMessage: DML operation inside loop. Collect records and perform single DML outside loop.\n\n### HTTP Callout in Trigger\n\nSeverity: ERROR\n\nSynchronous triggers cannot make callouts\n\nMessage: Callout in trigger. Use @future(callout=true) or Queueable with Database.AllowsCallouts.\n\n### Potential SOQL Injection\n\nSeverity: ERROR\n\nDynamic SOQL with string concatenation is vulnerable\n\nMessage: Dynamic SOQL with concatenation. Use bind variables or String.escapeSingleQuotes().\n\n### Missing WITH SECURITY_ENFORCED\n\nSeverity: WARNING\n\nSOQL should enforce FLS\u002FCRUD permissions\n\nMessage: SOQL without security enforcement. Add WITH SECURITY_ENFORCED.\n\n### Hardcoded Salesforce ID\n\nSeverity: WARNING\n\nRecord IDs differ between orgs\n\nMessage: Hardcoded Salesforce ID. Query by DeveloperName or ExternalId instead.\n\n### Hardcoded Credentials\n\nSeverity: ERROR\n\nCredentials must use Named Credentials or Custom Metadata\n\nMessage: Hardcoded credentials. Use Named Credentials or Custom Metadata.\n\n### Direct DOM Manipulation in LWC\n\nSeverity: WARNING\n\nLWC uses shadow DOM, direct manipulation breaks encapsulation\n\nMessage: Direct DOM access in LWC. Use this.template.querySelector() or data binding.\n\n### Reactive Property Without @track\n\nSeverity: INFO\n\nComplex object properties need @track for reactivity\n\nMessage: Object assignment may need @track for reactivity (post-Spring '20 objects are auto-tracked).\n\n### Wire Without Refresh After DML\n\nSeverity: WARNING\n\nCached wire data becomes stale after updates\n\nMessage: DML after @wire without refreshApex. Data may be stale.\n\n## Collaboration\n\n### Delegation Triggers\n\n- user needs external API integration -> backend (REST API design, external system sync)\n- user needs complex UI beyond LWC -> frontend (Custom portal with React\u002FNext.js)\n- user needs HubSpot integration -> hubspot-integration (Salesforce-HubSpot sync patterns)\n- user needs data warehouse sync -> data-engineer (ETL from Salesforce to warehouse)\n- user needs payment processing -> stripe-integration (Beyond Salesforce Billing)\n- user needs advanced auth -> auth-specialist (SSO, SAML, custom portals)\n\n## When to Use\n- User mentions or implies: salesforce\n- User mentions or implies: sfdc\n- User mentions or implies: apex\n- User mentions or implies: lwc\n- User mentions or implies: lightning web components\n- User mentions or implies: sfdx\n- User mentions or implies: scratch org\n- User mentions or implies: visualforce\n- User mentions or implies: soql\n- User mentions or implies: governor limits\n- User mentions or implies: connected app\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.\n","","imported","https:\u002F\u002Fgithub.com\u002Fsickn33\u002Fantigravity-awesome-skills","user_system_seed","SkillOPIC",true,59,693,"2026-05-16 13:37:38",{"id":8,"name":21,"slug":22,"icon":23,"description":24,"sort":25,"createdAt":26},"其他","other","mdi-page-next-outline","其他类型Skill",5,"2026-05-16 12:53:40",{"id":7,"name":28,"slug":29,"icon":30,"description":31,"moduleId":8,"sort":32,"skillCount":33,"createdAt":26},"职场发展","career","mdi-briefcase-outline","面试准备、简历优化、职业规划",4,575,[35],{"id":36,"skillId":4,"version":37,"fileName":38,"fileSize":39,"filePath":40,"fileHash":41,"manifest":42,"createdAt":19},"f3b91bb4-7b25-4c6d-9f29-8ad548449f9b","1.0.0","salesforce-development.zip",8338,"uploads\u002Fskills\u002Fe65085c5-abc2-4a53-b51c-f3a6f9e28532\u002Fsalesforce-development.zip","1665c00d337a68f91ade13d2475c4fa35223e57ff5edec345aeca66dc4136d50","[{\"path\":\"SKILL.md\",\"isDirectory\":false,\"size\":25161}]",{"code":44,"message":45,"data":46},200,"success",{"items":47,"stats":48,"page":51},[],{"averageRating":49,"totalRatings":49,"ratingCounts":50},0,[49,49,49,49,49],{"limit":52,"offset":49,"hasMore":53,"nextOffset":52,"ratedOnly":16},15,false]