@salesforce/afv-skills 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/package.json +3 -3
  2. package/skills/building-webapp-data-visualization/SKILL.md +1 -1
  3. package/skills/building-webapp-react-components/SKILL.md +1 -1
  4. package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +1 -1
  5. package/skills/configuring-webapp-metadata/SKILL.md +2 -2
  6. package/skills/creating-webapp/SKILL.md +2 -3
  7. package/skills/deploying-webapp-to-salesforce/SKILL.md +2 -5
  8. package/skills/generating-custom-application/SKILL.md +1 -1
  9. package/skills/generating-custom-field/SKILL.md +1 -1
  10. package/skills/generating-custom-lightning-type/SKILL.md +1 -1
  11. package/skills/generating-custom-object/SKILL.md +1 -1
  12. package/skills/generating-custom-tab/SKILL.md +1 -1
  13. package/skills/generating-experience-lwr-site/SKILL.md +1 -1
  14. package/skills/generating-experience-react-site/SKILL.md +1 -1
  15. package/skills/generating-flexipage/SKILL.md +1 -1
  16. package/skills/generating-flow/SKILL.md +1 -1
  17. package/skills/generating-fragment/SKILL.md +1 -1
  18. package/skills/generating-list-view/SKILL.md +1 -1
  19. package/skills/generating-permission-set/SKILL.md +1 -1
  20. package/skills/generating-validation-rule/SKILL.md +1 -1
  21. package/skills/implementing-webapp-file-upload/SKILL.md +1 -1
  22. package/skills/installing-webapp-features/SKILL.md +1 -1
  23. package/skills/managing-webapp-agentforce-conversation-client/SKILL.md +1 -1
  24. package/skills/trigger-refactor-pipeline/SKILL.md +1 -1
  25. package/skills/using-webapp-salesforce-data/SKILL.md +363 -0
  26. package/skills/using-webapp-salesforce-data/graphql-search.sh +139 -0
  27. package/skills/accessing-webapp-data/SKILL.md +0 -178
  28. package/skills/exploring-webapp-graphql-schema/SKILL.md +0 -149
  29. package/skills/fetching-webapp-rest-api/SKILL.md +0 -167
  30. package/skills/generating-webapp-graphql-mutation-query/SKILL.md +0 -258
  31. package/skills/generating-webapp-graphql-read-query/SKILL.md +0 -253
  32. package/skills/using-webapp-graphql/SKILL.md +0 -324
  33. package/skills/using-webapp-graphql/shared-schema.graphqls +0 -1150
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/afv-skills",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Salesforce skills for Agentforce Vibes",
5
5
  "license": "CC-BY-NC-4.0",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  "registry": "https://registry.npmjs.org"
12
12
  },
13
13
  "devDependencies": {
14
- "@salesforce/webapp-template-app-react-sample-b2e-experimental": "1.109.1",
15
- "@salesforce/webapp-template-app-react-sample-b2x-experimental": "1.109.1",
14
+ "@salesforce/webapp-template-app-react-sample-b2e-experimental": "^1.112.5",
15
+ "@salesforce/webapp-template-app-react-sample-b2x-experimental": "^1.112.5",
16
16
  "tsx": "^4.21.0"
17
17
  },
18
18
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: building-webapp-data-visualization
3
- description: Adds data visualization components (charts, stat cards, KPI metrics) to React pages using Recharts. Use when the user asks to add a chart, graph, donut chart, pie chart, bar chart, stat card, KPI metric, dashboard visualization, or analytics component to the web application.
3
+ description: "Adds data visualization components (charts, stat cards, KPI metrics) to React pages using Recharts. Use when the user asks to add a chart, graph, donut chart, pie chart, bar chart, stat card, KPI metric, dashboard visualization, or analytics component to the web application."
4
4
  ---
5
5
 
6
6
  # Data Visualization
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: building-webapp-react-components
3
- description: Use when editing any React code in the web application — creating or modifying components, pages, layout, headers, footers, or any TSX/JSX files. Follow this skill for add component, add page, header/footer, and general React UI implementation patterns (shadcn UI and Tailwind CSS).
3
+ description: "Use when editing any React code in the web application — creating or modifying components, pages, layout, headers, footers, or any TSX/JSX files. Follow this skill for add component, add page, header/footer, and general React UI implementation patterns (shadcn UI and Tailwind CSS)."
4
4
  ---
5
5
 
6
6
  # React Web App (Components, Pages, Layout)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: configuring-webapp-csp-trusted-sites
3
- description: Creates Salesforce CSP Trusted Site metadata when adding external domains. Use when the user adds an external API, CDN, image host, font provider, map tile server, or any third-party URL that the web application needs to load resources from — or when a browser console shows a CSP violation error.
3
+ description: "Creates Salesforce CSP Trusted Site metadata when adding external domains. Use when the user adds an external API, CDN, image host, font provider, map tile server, or any third-party URL that the web application needs to load resources from — or when a browser console shows a CSP violation error."
4
4
  ---
5
5
 
6
6
  # CSP Trusted Sites
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: configuring-webapp-metadata
3
- description: Use this skill when configuring web application metadata structure, webapplication.json, or bundle organization. Covers WebApplication bundle layout, meta XML, build output directory, and webapplication.json settings.
3
+ description: "Use this skill when configuring web application metadata structure, webapplication.json, or bundle organization. Covers WebApplication bundle layout, meta XML, build output directory, and webapplication.json settings."
4
4
  ---
5
5
 
6
6
  # WebApplication Requirements
@@ -53,7 +53,7 @@ Applies to:
53
53
 
54
54
  Reject:
55
55
  - backslashes
56
- - leading `\`
56
+ - leading `/` or `\`
57
57
  - `..` segments
58
58
  - null or control characters
59
59
  - globs: `*`, `?`, `**`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: creating-webapp
3
- description: Use this skill when creating or setting up a new SFDX React web application. Covers first steps, npm install, skills-first protocol, deployment order, and core web app rules.
3
+ description: "Use this skill when creating or setting up a new SFDX React web application. Covers first steps, npm install, skills-first protocol, deployment order, and core web app rules."
4
4
  paths:
5
5
  - "**/webapplications/**/*"
6
6
  ---
@@ -111,7 +111,7 @@ Apps run behind dynamic base paths. Router navigation (`<Link to>`, `navigate()`
111
111
 
112
112
  ## Module Restrictions
113
113
 
114
- React apps must NOT import Salesforce platform modules like `lightning/*` or `@wire` (LWC-only). For data access, invoke the **accessing-data** skill.
114
+ React apps must NOT import Salesforce platform modules like `lightning/*` or `@wire` (LWC-only). For data access, invoke the **using-salesforce-data** skill.
115
115
 
116
116
  # Frontend Aesthetics
117
117
 
@@ -138,4 +138,3 @@ Only stop when:
138
138
  - All checklist items are completed and quality gates pass, or
139
139
  - A blocking error cannot be resolved after reasonable remediation, or
140
140
  - The user explicitly asks to pause.
141
-
@@ -1,8 +1,6 @@
1
1
  ---
2
2
  name: deploying-webapp-to-salesforce
3
- description: Enforces the correct order for deploying metadata, assigning permission sets, and fetching GraphQL schema. Use for ANY deployment to a Salesforce org — webapps, LWC, Aura, Apex, metadata, schema fetch, or org sync. Codifies setup-cli.mjs.
4
- paths:
5
- - "**/*"
3
+ description: "Enforces the correct order for deploying metadata, assigning permission sets, and fetching GraphQL schema. Use for ANY deployment to a Salesforce org — webapps, LWC, Aura, Apex, metadata, schema fetch, or org sync. Codifies setup-cli.mjs."
6
4
  ---
7
5
 
8
6
  # Deploying to Salesforce
@@ -225,5 +223,4 @@ The project includes `scripts/setup-cli.mjs` which runs this sequence in batch.
225
223
 
226
224
  ## Related Skills
227
225
 
228
- - **exploring-graphql-schema** — Schema exploration (grep-only) after schema exists
229
- - **using-graphql** — Full GraphQL workflow (explore, query, codegen, lint)
226
+ - **using-salesforce-data** — Full data access workflow (GraphQL queries/mutations, REST APIs, schema exploration, webapp integration)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-custom-application
3
- description: Use this skill when users need to create or configure Salesforce Custom Applications. Trigger when users mention custom apps, application metadata, app navigation, or organizing tabs into applications. Use when users want to create app containers for tabs and pages. Always use this skill for custom application work.
3
+ description: "Use this skill when users need to create or configure Salesforce Custom Applications. Trigger when users mention custom apps, application metadata, app navigation, or organizing tabs into applications. Use when users want to create app containers for tabs and pages. Always use this skill for custom application work."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-custom-field
3
- description: Use this skill when users need to create, generate, or validate Salesforce Custom Field metadata. Trigger when users mention custom fields, field types, Roll-up Summary fields, Master-Detail relationships, Lookup relationships, formula fields, picklists, or field metadata. Also use when users encounter field deployment errors, especially around Roll-up Summary format, Master-Detail constraints, or formula issues. Always use this skill for any custom field metadata work, field generation, or field troubleshooting.
3
+ description: "Use this skill when users need to create, generate, or validate Salesforce Custom Field metadata. Trigger when users mention custom fields, field types, Roll-up Summary fields, Master-Detail relationships, Lookup relationships, formula fields, picklists, or field metadata. Also use when users encounter field deployment errors, especially around Roll-up Summary format, Master-Detail constraints, or formula issues. Always use this skill for any custom field metadata work, field generation, or field troubleshooting."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-custom-lightning-type
3
- description: Use this skill when users need to create Custom Lightning Types (CLTs) for Einstein Agent actions or structured input/output schemas. Trigger when users mention CLT, Custom Lightning Types, JSON schemas for agents, type definitions, lightning__objectType, or editor/renderer configurations. This is complex - always use this skill for CLT work.
3
+ description: "Use this skill when users need to create Custom Lightning Types (CLTs) for Einstein Agent actions or structured input/output schemas. Trigger when users mention CLT, Custom Lightning Types, JSON schemas for agents, type definitions, lightning__objectType, or editor/renderer configurations. This is complex - always use this skill for CLT work."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-custom-object
3
- description: Use this skill when users need to create, generate, or validate Salesforce Custom Object metadata. Trigger when users mention custom objects, creating objects, object metadata, .object files, sharing models, name fields, or validation rules on objects. Also use when users say things like "create a custom object", "generate object metadata", "set up an object for...", or when they're troubleshooting object deployment errors especially around sharing models and Master-Detail relationships. Always use this skill for any custom object metadata work.
3
+ description: "Use this skill when users need to create, generate, or validate Salesforce Custom Object metadata. Trigger when users mention custom objects, creating objects, object metadata, .object files, sharing models, name fields, or validation rules on objects. Also use when users say things like \"create a custom object\", \"generate object metadata\", \"set up an object for...\", or when they're troubleshooting object deployment errors especially around sharing models and Master-Detail relationships. Always use this skill for any custom object metadata work."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-custom-tab
3
- description: Use this skill when users need to create or configure Salesforce Custom Tabs. Trigger when users mention tabs, navigation tabs, object tabs, web tabs, Visualforce tabs, Lightning component tabs, app page tabs, or tab configuration. Also use when users want to add navigation to custom objects, create tabs for external content, or set up Lightning page tabs. Always use this skill for any custom tab work.
3
+ description: "Use this skill when users need to create or configure Salesforce Custom Tabs. Trigger when users mention tabs, navigation tabs, object tabs, web tabs, Visualforce tabs, Lightning component tabs, app page tabs, or tab configuration. Also use when users want to add navigation to custom objects, create tabs for external content, or set up Lightning page tabs. Always use this skill for any custom tab work."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-experience-lwr-site
3
- description: Creates, modifies, or manages Salesforce Experience Cloud LWR sites via DigitalExperience metadata. Always trigger when users mention Experience sites, LWR sites, DigitalExperience, Experience Cloud, community sites, portals, creating pages, adding routes, views, theme layouts, branding sets, previewing sites, or any DigitalExperience bundle work. Also use when users mention specific content types like sfdc_cms__route, sfdc_cms__themeLayout, etc. or when troubleshooting site deployment.
3
+ description: "Creates, modifies, or manages Salesforce Experience Cloud LWR sites via DigitalExperience metadata. Always trigger when users mention Experience sites, LWR sites, DigitalExperience, Experience Cloud, community sites, portals, creating pages, adding routes, views, theme layouts, branding sets, previewing sites, or any DigitalExperience bundle work. Also use when users mention specific content types like sfdc_cms__route, sfdc_cms__themeLayout, etc. or when troubleshooting site deployment."
4
4
  ---
5
5
 
6
6
  # Experience LWR Site Builder
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-experience-react-site
3
- description: Use this skill when users need to create or configure a Salesforce Digital Experience Site specifically for hosting a React web application. Trigger when users mention creating an Experience site for a React app, setting up a React site on Salesforce, configuring Network/CustomSite/DigitalExperience metadata for a web app, or deploying site infrastructure for a React application. Also trigger when users mention site URL path prefixes, app namespaces, appDevName, guest access configuration, DigitalExperienceConfig, DigitalExperienceBundle, or sfdc_cms__site content types in the context of React apps. Always use this skill for any React web application site creation or site infrastructure configuration work, even if the user just says "create a site for my React app" or "set up the site for my web application."
3
+ description: "Use this skill when users need to create or configure a Salesforce Digital Experience Site specifically for hosting a React web application. Trigger when users mention creating an Experience site for a React app, setting up a React site on Salesforce, configuring Network/CustomSite/DigitalExperience metadata for a web app, or deploying site infrastructure for a React application. Also trigger when users mention site URL path prefixes, app namespaces, appDevName, guest access configuration, DigitalExperienceConfig, DigitalExperienceBundle, or sfdc_cms__site content types in the context of React apps. Always use this skill for any React web application site creation or site infrastructure configuration work, even if the user just says \"create a site for my React app\" or \"set up the site for my web application.\""
4
4
  ---
5
5
 
6
6
  # Digital Experience Site for React Web Applications
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-flexipage
3
- description: Use this skill when users need to create, generate, modify, or validate Salesforce Lightning pages (FlexiPages). Trigger when users mention RecordPage, AppPage, HomePage, Lightning pages, page layouts, adding components to pages, or page customization. Also use when users say things like "create a Lightning page", "add a component to a page", "customize the record page", "generate a FlexiPage", or when they're working with FlexiPage XML files and need help with components, regions, or deployment errors. Always use this skill for any FlexiPage-related work, even if they just mention "page" in the context of Salesforce.
3
+ description: "Use this skill when users need to create, generate, modify, or validate Salesforce Lightning pages (FlexiPages). Trigger when users mention RecordPage, AppPage, HomePage, Lightning pages, page layouts, adding components to pages, or page customization. Also use when users say things like \"create a Lightning page\", \"add a component to a page\", \"customize the record page\", \"generate a FlexiPage\", or when they're working with FlexiPage XML files and need help with components, regions, or deployment errors. Always use this skill for any FlexiPage-related work, even if they just mention \"page\" in the context of Salesforce."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-flow
3
- description: Generate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as "when a record is created", "trigger daily at", "send an email when", "update the field when", "automate", "workflow", or "flow XML/metadata". This is the only skill for Salesforce Flow generation.
3
+ description: "Generate Salesforce Flows using the MCP tool execute_metadata_action. Use when the user asks to create, build, or generate a flow — including Screen, Autolaunched, Record-Triggered (before/after-save), Scheduled. Also trigger for flow-like requests such as \"when a record is created\", \"trigger daily at\", \"send an email when\", \"update the field when\", \"automate\", \"workflow\", or \"flow XML/metadata\". This is the only skill for Salesforce Flow generation."
4
4
  ---
5
5
 
6
6
  ## Goal
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-fragment
3
- description: Use this skill when users need to create or edit Salesforce Fragments (reusable UI pieces). Trigger when users mention fragments, UEM blocks, reusable UI templates, structured rendering across Slack/Mobile/LEX, or block-based layouts. Also use when users want to create unified experience components. Always use this skill for any fragment work.
3
+ description: "Use this skill when users need to create or edit Salesforce Fragments (reusable UI pieces). Trigger when users mention fragments, UEM blocks, reusable UI templates, structured rendering across Slack/Mobile/LEX, or block-based layouts. Also use when users want to create unified experience components. Always use this skill for any fragment work."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-list-view
3
- description: Use this skill when users need to create, generate, or validate Salesforce List View metadata. Trigger when users mention list views, filtered record lists, creating views, setting up record columns, filtering records by criteria, or ask about list view visibility. Also use when users say things like "I need a view that shows...", "filter records by...", "create a list view for...", or when they're working with ListView XML files and need validation or troubleshooting.
3
+ description: "Use this skill when users need to create, generate, or validate Salesforce List View metadata. Trigger when users mention list views, filtered record lists, creating views, setting up record columns, filtering records by criteria, or ask about list view visibility. Also use when users say things like \"I need a view that shows...\", \"filter records by...\", \"create a list view for...\", or when they're working with ListView XML files and need validation or troubleshooting."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-permission-set
3
- description: Generates correct, deployable Salesforce permission set metadata (PermissionSet XML) with object, field, user, and app permissions. Use this skill when creating or editing permission set metadata, object permissions, field-level security (FLS), tab visibility, or deploying permission sets.
3
+ description: "Generates correct, deployable Salesforce permission set metadata (PermissionSet XML) with object, field, user, and app permissions. Use this skill when creating or editing permission set metadata, object permissions, field-level security (FLS), tab visibility, or deploying permission sets."
4
4
  compatibility: Salesforce Metadata API v60.0+
5
5
  metadata:
6
6
  author: afv-library
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: generating-validation-rule
3
- description: Use this skill when users need to create, modify, or validate Salesforce Validation Rules. Trigger when users mention validation rules, field validation, data quality rules, formula validation, error messages, or validation logic. Also use when users encounter validation errors, need to update formulas, or want to enforce business rules at the data layer. Always use this skill for any validation rule work.
3
+ description: "Use this skill when users need to create, modify, or validate Salesforce Validation Rules. Trigger when users mention validation rules, field validation, data quality rules, formula validation, error messages, or validation logic. Also use when users encounter validation errors, need to update formulas, or want to enforce business rules at the data layer. Always use this skill for any validation rule work."
4
4
  ---
5
5
 
6
6
  ## When to Use This Skill
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: implementing-webapp-file-upload
3
- description: Add file upload functionality to React webapps with progress tracking and Salesforce ContentVersion integration. Use when the user wants to upload files, attach documents, handle file input, create file dropzones, track upload progress, or link files to Salesforce records. This feature provides programmatic APIs ONLY — no components or hooks are exported. Build your own custom UI using the upload() API. ALWAYS use this feature instead of building file upload from scratch with FormData or XHR.
3
+ description: "Add file upload functionality to React webapps with progress tracking and Salesforce ContentVersion integration. Use when the user wants to upload files, attach documents, handle file input, create file dropzones, track upload progress, or link files to Salesforce records. This feature provides programmatic APIs ONLY — no components or hooks are exported. Build your own custom UI using the upload() API. ALWAYS use this feature instead of building file upload from scratch with FormData or XHR."
4
4
  ---
5
5
 
6
6
  # File Upload API (workflow)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: installing-webapp-features
3
- description: Search, describe, and install pre-built UI features (authentication, shadcn components, navigation, search, GraphQL, Agentforce AI) into Salesforce webapps. Use this when the user wants to add functionality to a webapp, or when determining what salesforce-provided features are available — whether prompted by the user or on your own initiative. Always check for an existing feature before building from scratch.
3
+ description: "Search, describe, and install pre-built UI features (authentication, shadcn components, navigation, search, GraphQL, Agentforce AI) into Salesforce webapps. Use this when the user wants to add functionality to a webapp, or when determining what salesforce-provided features are available — whether prompted by the user or on your own initiative. Always check for an existing feature before building from scratch."
4
4
  ---
5
5
 
6
6
  # webapps-features-experimental CLI — Agent Reference
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: managing-webapp-agentforce-conversation-client
3
- description: Adds or modifies AgentforceConversationClient in React apps (.tsx or .jsx files). Use when user says "add chat widget", "embed agentforce", "add agent", "add chatbot", "integrate conversational AI", or asks to change colors, dimensions, styling, or configure agentId, width, height, inline mode, or styleTokens for travel agent, HR agent, employee agent, or any Salesforce agent chat.
3
+ description: "Adds or modifies AgentforceConversationClient in React apps (.tsx or .jsx files). Use when user says \"add chat widget\", \"embed agentforce\", \"add agent\", \"add chatbot\", \"integrate conversational AI\", or asks to change colors, dimensions, styling, or configure agentId, width, height, inline mode, or styleTokens for travel agent, HR agent, employee agent, or any Salesforce agent chat."
4
4
  metadata:
5
5
  author: ACC Components
6
6
  version: 1.0.0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: trigger-refactor-pipeline
3
- description: Refactor Salesforce triggers into handler patterns with automated test generation and deployment. Use when modernizing legacy triggers with DML/SOQL in loops or inconsistent patterns.
3
+ description: "Refactor Salesforce triggers into handler patterns with automated test generation and deployment. Use when modernizing legacy triggers with DML/SOQL in loops or inconsistent patterns."
4
4
  license: Apache-2.0
5
5
  compatibility: Requires Salesforce CLI, Python 3.9+
6
6
  metadata:
@@ -0,0 +1,363 @@
1
+ ---
2
+ name: using-webapp-salesforce-data
3
+ description: "Salesforce data access for reading, writing, and querying records via REST, GraphQL, Apex, or Platform SDK. Use when the user wants to fetch, search, filter, sort, display, create, update, delete, or attach files to Salesforce records (standard objects like Accounts, Contacts, Opportunities, Cases, Quotes, or any custom object) in a web app or UI component (React, Angular, Vue, etc.); call Chatter, Connect, or Apex REST APIs; or invoke AuraEnabled Apex methods from an external app. Does not apply to authentication/OAuth setup, schema changes (adding fields, relationships), Bulk/Tooling/Metadata API usage, declarative automation (Flows, Process Builder), general LWC/Apex coding guidance without a specific data operation, or Salesforce admin/configuration tasks."
4
+ ---
5
+
6
+ # Salesforce Data Access
7
+
8
+ ## When to Use
9
+
10
+ Use this skill when the user wants to:
11
+
12
+ - **Fetch or display Salesforce data** — Query records (Account, Contact, Opportunity, custom objects) to show in a component
13
+ - **Create, update, or delete records** — Perform mutations on Salesforce data
14
+ - **Add data fetching to a component** — Wire up a React component to Salesforce data
15
+ - **Call REST APIs** — Use Connect REST, Apex REST, or UI API endpoints
16
+ - **Explore the org schema** — Discover available objects, fields, or relationships
17
+
18
+ ## Data SDK Requirement
19
+
20
+ > **All Salesforce data access MUST use the Data SDK** (`@salesforce/sdk-data`). The SDK handles authentication, CSRF, and base URL resolution. Never use `fetch()` or `axios` directly.
21
+
22
+ ```typescript
23
+ import { createDataSDK, gql } from "@salesforce/sdk-data";
24
+
25
+ const sdk = await createDataSDK();
26
+
27
+ // GraphQL for record queries/mutations (PREFERRED)
28
+ const response = await sdk.graphql?.<ResponseType>(query, variables);
29
+
30
+ // REST for Connect REST, Apex REST, UI API (when GraphQL insufficient)
31
+ const res = await sdk.fetch?.("/services/apexrest/my-resource");
32
+ ```
33
+
34
+ **Always use optional chaining** (`sdk.graphql?.()`, `sdk.fetch?.()`) — these methods may be undefined in some surfaces.
35
+
36
+ ## Supported APIs
37
+
38
+ **Only the following APIs are permitted.** Any endpoint not listed here must not be used.
39
+
40
+ | API | Method | Endpoints / Use Case |
41
+ |-----|--------|----------------------|
42
+ | GraphQL | `sdk.graphql` | All record queries and mutations via `uiapi { }` namespace |
43
+ | UI API REST | `sdk.fetch` | `/services/data/v{ver}/ui-api/records/{id}` — record metadata when GraphQL is insufficient |
44
+ | Apex REST | `sdk.fetch` | `/services/apexrest/{resource}` — custom server-side logic, aggregates, multi-step transactions |
45
+ | Connect REST | `sdk.fetch` | `/services/data/v{ver}/connect/file/upload/config` — file upload config |
46
+ | Einstein LLM | `sdk.fetch` | `/services/data/v{ver}/einstein/llm/prompt/generations` — AI text generation |
47
+
48
+ **Not supported:**
49
+
50
+ - **Enterprise REST query endpoint** (`/services/data/v*/query` with SOQL) — blocked at the proxy level. Use GraphQL for record reads; use Apex REST if server-side SOQL aggregates are required.
51
+ - **Aura-enabled Apex** (`@AuraEnabled`) — an LWC/Aura pattern with no invocation path from React webapps.
52
+ - **Chatter API** (`/chatter/users/me`) — use `uiapi { currentUser { ... } }` in a GraphQL query instead.
53
+ - **Any other Salesforce REST endpoint** not listed in the supported table above.
54
+
55
+ ## Decision: GraphQL vs REST
56
+
57
+ | Need | Method | Example |
58
+ |------|--------|---------|
59
+ | Query/mutate records | `sdk.graphql` | Account, Contact, custom objects |
60
+ | Current user info | `sdk.graphql` | `uiapi { currentUser { Id Name { value } } }` |
61
+ | UI API record metadata | `sdk.fetch` | `/ui-api/records/{id}` |
62
+ | Connect REST | `sdk.fetch` | `/connect/file/upload/config` |
63
+ | Apex REST | `sdk.fetch` | `/services/apexrest/auth/login` |
64
+ | Einstein LLM | `sdk.fetch` | `/einstein/llm/prompt/generations` |
65
+
66
+ **GraphQL is preferred** for record operations. Use REST only when GraphQL doesn't cover the use case.
67
+
68
+ ---
69
+
70
+ ## GraphQL Workflow
71
+
72
+ ### Step 1: Acquire Schema
73
+
74
+ The `schema.graphql` file (265K+ lines) is the source of truth. **Never open or parse it directly.**
75
+
76
+ 1. Check if `schema.graphql` exists at the SFDX project root
77
+ 2. If missing, run from the **webapp dir**: `npm run graphql:schema`
78
+ 3. Custom objects appear only after metadata is deployed
79
+
80
+ ### Step 2: Look Up Entity Schema
81
+
82
+ Map user intent to PascalCase names ("accounts" → `Account`), then **run the search script from the project root**:
83
+
84
+ ```bash
85
+ # From project root — look up all relevant schema info for one or more entities
86
+ bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account
87
+
88
+ # Multiple entities at once
89
+ bash .a4drules/skills/using-salesforce-data/graphql-search.sh Account Contact Opportunity
90
+ ```
91
+
92
+ The script outputs five sections per entity:
93
+ 1. **Type definition** — all queryable fields and relationships
94
+ 2. **Filter options** — available fields for `where:` conditions
95
+ 3. **Sort options** — available fields for `orderBy:`
96
+ 4. **Create input** — fields accepted by create mutations
97
+ 5. **Update input** — fields accepted by update mutations
98
+
99
+ Use this output to determine exact field names before writing any query or mutation. **Maximum 2 script runs.** If the entity still can't be found, ask the user — the object may not be deployed.
100
+
101
+ ### Step 3: Generate Query
102
+
103
+ Use the templates below. Every field name **must** be verified from the script output in Step 2.
104
+
105
+ #### Read Query Template
106
+
107
+ ```graphql
108
+ query GetAccounts {
109
+ uiapi {
110
+ query {
111
+ Account(where: { Industry: { eq: "Technology" } }, first: 10) {
112
+ edges {
113
+ node {
114
+ Id
115
+ Name @optional { value }
116
+ Industry @optional { value }
117
+ # Parent relationship
118
+ Owner @optional { Name { value } }
119
+ # Child relationship
120
+ Contacts @optional {
121
+ edges { node { Name @optional { value } } }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ **FLS Resilience**: Apply `@optional` to all record fields. The server omits inaccessible fields instead of failing. Consuming code must use optional chaining:
132
+
133
+ ```typescript
134
+ const name = node.Name?.value ?? "";
135
+ ```
136
+
137
+ #### Mutation Template
138
+
139
+ ```graphql
140
+ mutation CreateAccount($input: AccountCreateInput!) {
141
+ uiapi {
142
+ AccountCreate(input: $input) {
143
+ Record { Id Name { value } }
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ **Mutation constraints:**
150
+ - Create: Include required fields, only `createable` fields, no child relationships
151
+ - Update: Include `Id`, only `updateable` fields
152
+ - Delete: Include `Id` only
153
+
154
+ #### Object Metadata & Picklist Values
155
+
156
+ Use `uiapi { objectInfos(...) }` to fetch field metadata or picklist values. Pass **either** `apiNames` or `objectInfoInputs` — never both in the same query.
157
+
158
+ **Object metadata** (field labels, data types, CRUD flags):
159
+
160
+ ```typescript
161
+ const GET_OBJECT_INFO = gql`
162
+ query GetObjectInfo($apiNames: [String!]!) {
163
+ uiapi {
164
+ objectInfos(apiNames: $apiNames) {
165
+ ApiName
166
+ label
167
+ labelPlural
168
+ fields {
169
+ ApiName
170
+ label
171
+ dataType
172
+ updateable
173
+ createable
174
+ }
175
+ }
176
+ }
177
+ }
178
+ `;
179
+
180
+ const sdk = await createDataSDK();
181
+ const response = await sdk.graphql?.(GET_OBJECT_INFO, { apiNames: ["Account"] });
182
+ const objectInfos = response?.data?.uiapi?.objectInfos ?? [];
183
+ ```
184
+
185
+ **Picklist values** (use `objectInfoInputs` + `... on PicklistField` inline fragment):
186
+
187
+ ```typescript
188
+ const GET_PICKLIST_VALUES = gql`
189
+ query GetPicklistValues($objectInfoInputs: [ObjectInfoInput!]!) {
190
+ uiapi {
191
+ objectInfos(objectInfoInputs: $objectInfoInputs) {
192
+ ApiName
193
+ fields {
194
+ ApiName
195
+ ... on PicklistField {
196
+ picklistValuesByRecordTypeIDs {
197
+ recordTypeID
198
+ picklistValues {
199
+ label
200
+ value
201
+ }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+ `;
209
+
210
+ const response = await sdk.graphql?.(GET_PICKLIST_VALUES, {
211
+ objectInfoInputs: [{ objectApiName: "Account" }],
212
+ });
213
+ const fields = response?.data?.uiapi?.objectInfos?.[0]?.fields ?? [];
214
+ ```
215
+
216
+ ### Step 4: Validate & Test
217
+
218
+ 1. **Lint**: `npx eslint <file>` from webapp dir
219
+ 2. **Test**: Ask user before testing. For mutations, request input values — never fabricate data.
220
+
221
+ **If ESLint reports a GraphQL error** (e.g. `Cannot query field`, `Unknown type`, `Unknown argument`), the field or type name is wrong. Re-run the schema search script to find the correct name — do not guess:
222
+
223
+ ```bash
224
+ # From project root — re-check the entity that caused the error
225
+ bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
226
+ ```
227
+
228
+ Then fix the query using the exact names from the script output.
229
+
230
+ ---
231
+
232
+ ## Webapp Integration (React)
233
+
234
+ ```typescript
235
+ import { createDataSDK, gql } from "@salesforce/sdk-data";
236
+
237
+ const GET_ACCOUNTS = gql`
238
+ query GetAccounts {
239
+ uiapi {
240
+ query {
241
+ Account(first: 10) {
242
+ edges {
243
+ node {
244
+ Id
245
+ Name @optional { value }
246
+ Industry @optional { value }
247
+ }
248
+ }
249
+ }
250
+ }
251
+ }
252
+ }
253
+ `;
254
+
255
+ const sdk = await createDataSDK();
256
+ const response = await sdk.graphql?.(GET_ACCOUNTS);
257
+
258
+ if (response?.errors?.length) {
259
+ throw new Error(response.errors.map(e => e.message).join("; "));
260
+ }
261
+
262
+ const accounts = response?.data?.uiapi?.query?.Account?.edges?.map(e => e.node) ?? [];
263
+ ```
264
+
265
+ ---
266
+
267
+ ## REST API Patterns
268
+
269
+ Use `sdk.fetch` when GraphQL is insufficient. See the [Supported APIs](#supported-apis) table for the full allowlist.
270
+
271
+ ```typescript
272
+ declare const __SF_API_VERSION__: string;
273
+ const API_VERSION = typeof __SF_API_VERSION__ !== "undefined" ? __SF_API_VERSION__ : "65.0";
274
+
275
+ // Connect — file upload config
276
+ const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/connect/file/upload/config`);
277
+
278
+ // Apex REST (no version in path)
279
+ const res = await sdk.fetch?.("/services/apexrest/auth/login", {
280
+ method: "POST",
281
+ body: JSON.stringify({ email, password }),
282
+ headers: { "Content-Type": "application/json" },
283
+ });
284
+
285
+ // UI API — record with metadata (prefer GraphQL for simple reads)
286
+ const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/ui-api/records/${recordId}`);
287
+
288
+ // Einstein LLM
289
+ const res = await sdk.fetch?.(`/services/data/v${API_VERSION}/einstein/llm/prompt/generations`, {
290
+ method: "POST",
291
+ body: JSON.stringify({ promptTextorId: prompt }),
292
+ });
293
+ ```
294
+
295
+ **Current user**: Do not use Chatter (`/chatter/users/me`). Use GraphQL instead:
296
+
297
+ ```typescript
298
+ const GET_CURRENT_USER = gql`
299
+ query CurrentUser {
300
+ uiapi { currentUser { Id Name { value } } }
301
+ }
302
+ `;
303
+ const response = await sdk.graphql?.(GET_CURRENT_USER);
304
+ ```
305
+
306
+ ---
307
+
308
+ ## Directory Structure
309
+
310
+ ```
311
+ <project-root>/ ← SFDX project root
312
+ ├── schema.graphql ← grep target (lives here)
313
+ ├── sfdx-project.json
314
+ └── force-app/main/default/webapplications/<app-name>/ ← webapp dir
315
+ ├── package.json ← npm scripts
316
+ └── src/
317
+ ```
318
+
319
+ | Command | Run From | Why |
320
+ |---------|----------|-----|
321
+ | `npm run graphql:schema` | webapp dir | Script in webapp's package.json |
322
+ | `npx eslint <file>` | webapp dir | Reads eslint.config.js |
323
+ | `bash .a4drules/skills/using-salesforce-data/graphql-search.sh <Entity>` | project root | Schema lookup |
324
+ | `sf api request rest` | project root | Needs sfdx-project.json |
325
+
326
+ ---
327
+
328
+ ## Quick Reference
329
+
330
+ ### Schema Lookup (from project root)
331
+
332
+ Run the search script to get all relevant schema info in one step:
333
+
334
+ ```bash
335
+ bash .a4drules/skills/using-salesforce-data/graphql-search.sh <EntityName>
336
+ ```
337
+
338
+ | Script Output Section | Used For |
339
+ |-----------------------|----------|
340
+ | Type definition | Field names, parent/child relationships |
341
+ | Filter options | `where:` conditions |
342
+ | Sort options | `orderBy:` |
343
+ | CreateRepresentation | Create mutation field list |
344
+ | UpdateRepresentation | Update mutation field list |
345
+
346
+ ### Error Categories
347
+
348
+ | Error Contains | Resolution |
349
+ |----------------|------------|
350
+ | `Cannot query field` | Field name is wrong — run `graphql-search.sh <Entity>` and use the exact name from the Type definition section |
351
+ | `Unknown type` | Type name is wrong — run `graphql-search.sh <Entity>` to confirm the correct PascalCase entity name |
352
+ | `Unknown argument` | Argument name is wrong — run `graphql-search.sh <Entity>` and check Filter or OrderBy sections |
353
+ | `invalid syntax` | Fix syntax per error message |
354
+ | `validation error` | Field name is wrong — run `graphql-search.sh <Entity>` to verify |
355
+ | `VariableTypeMismatch` | Correct argument type from schema |
356
+ | `invalid cross reference id` | Entity deleted — ask for valid Id |
357
+
358
+ ### Checklist
359
+
360
+ - [ ] All field names verified via search script (Step 2)
361
+ - [ ] `@optional` applied to record fields (reads)
362
+ - [ ] Optional chaining in consuming code
363
+ - [ ] Lint passes: `npx eslint <file>`