Skip to content

forcedotcom/sf-skills / plugins/builder/experience-react/skills/experience-ui-bundle-salesforce-data-access

experience-ui-bundle-salesforce-data-access

Verified

MUST activate whenever a uiBundles/*/src/ project reads, writes, or displays Salesforce data — INCLUDING building a page, list, table, card grid, dashboard, or form that shows, filters, counts, or edits records of any object (e.g. Property__c, Account, Case), even when the prompt names only the UI or the object and never says query, GraphQL, or SDK. Records behind such a component come from Salesforce, so use this ALONGSIDE experience-ui-bundle-frontend-generate: that skill styles the component, this one wires its data. Also triggers on @salesforce/platform-sdk imports, sdk.graphql.query / mutate / sdk.fetch calls, *.graphql files, or stale data needing force-refresh. New read/write work uses the current @salesforce/platform-sdk API; migrate only EXISTING old @salesforce/sdk-data callable code. Not for pure styling/layout with no records, app shell, file upload, or auth/search scaffolding. DO NOT TRIGGER for OAuth, object/field schema changes, Bulk/Tooling/Metadata API, or declarative automation.

FileKindSize
SKILL.mdskill md29.6 KB
references/caching.mdmarkdown8.8 KB
references/graphiti-cli.mdmarkdown19.5 KB
references/graphql-hand-authoring.mdmarkdown14.9 KB
references/migration.mdmarkdown6.0 KB
references/rest-and-integration.mdmarkdown6.7 KB
references/sdk-api.mdmarkdown4.9 KB
scripts/graphql-search.shexecutablescript7.6 KB

scripts/graphql-search.sh

View on GitHub
#!/usr/bin/env bash
set -euo pipefail  # exit on error (-e), undefined vars (-u), and propagate pipeline failures (-o pipefail)
# graphql-search.sh — Look up one or more Salesforce entities in schema.graphql.
#
# Run from the SFDX project root, where schema.graphql lives:
#   bash <skill-dir>/scripts/graphql-search.sh Account
#   bash <skill-dir>/scripts/graphql-search.sh Account Contact Opportunity
#
# The script does NOT search up the directory tree — an ancestor schema.graphql
# may belong to a DIFFERENT org, and silently matching it would validate fields
# against the wrong schema. If schema.graphql is not at ./ you must point the
# script at the right file explicitly (resolution order, first hit wins):
#   1. -s / --schema <path>      explicit flag
#   2. $GRAPHQL_SCHEMA env var   explicit override
#   3. ./schema.graphql          (current working directory only)
#
#   bash <skill-dir>/scripts/graphql-search.sh -s force-app/main/default/uiBundles/<app>/schema.graphql Account
#   GRAPHQL_SCHEMA=/abs/path/schema.graphql bash <skill-dir>/scripts/graphql-search.sh Account
#
# Output sections per entity:
#   1. Type definition          — all fields and relationships
#   2. Filter options           — <Entity>_Filter input (for `where:`)
#   3. Sort options             — <Entity>_OrderBy input (for `orderBy:`)
#   4. Create mutation wrapper  — <Entity>CreateInput
#   5. Create mutation fields   — <Entity>CreateRepresentation (for create mutations)
#   6. Update mutation wrapper  — <Entity>UpdateInput
#   7. Update mutation fields   — <Entity>UpdateRepresentation (for update mutations)

SCHEMA=""

# ── Argument parsing ─────────────────────────────────────────────────────────

while [[ $# -gt 0 ]]; do
  case "$1" in
    -s|--schema)
      if [[ -z "${2-}" || "$2" == -* ]]; then
        echo "ERROR: --schema requires a file path argument"
        exit 1
      fi
      SCHEMA="$2"
      shift 2
      ;;
    --)
      shift
      break
      ;;
    -*)
      echo "ERROR: Unknown option: $1"
      echo "Usage: bash $0 [-s <schema-path>] <EntityName> [EntityName2 ...]"
      exit 1
      ;;
    *)
      break
      ;;
  esac
done

if [ $# -eq 0 ]; then
  echo "Usage: bash $0 [-s <schema-path>] <EntityName> [EntityName2 ...]"
  echo "Example: bash $0 Account"
  echo "Example: bash $0 Account Contact Opportunity"
  echo "Example: bash $0 --schema /path/to/schema.graphql Account"
  exit 1
fi

# ── Schema resolution ────────────────────────────────────────────────────────
# NO directory walk-up: resolve only from an explicit flag, an explicit env var,
# or schema.graphql in the CURRENT directory. Searching ancestors risks matching
# an unrelated project's schema and validating fields against the wrong org.
# Resolution order (first hit wins): -s/--schema, then $GRAPHQL_SCHEMA, then ./schema.graphql.

if [ -z "$SCHEMA" ] && [ -n "${GRAPHQL_SCHEMA-}" ]; then
  SCHEMA="$GRAPHQL_SCHEMA"
fi

if [ -z "$SCHEMA" ]; then
  SCHEMA="./schema.graphql"
fi

if [ ! -f "$SCHEMA" ]; then
  echo "ERROR: schema.graphql not found at '$SCHEMA'."
  echo "  This script does NOT search parent directories (an ancestor schema may be the wrong org's)."
  echo "  Run from the SFDX project root where schema.graphql lives, or point at it explicitly:"
  echo "    bash $0 --schema <path/to/schema.graphql> <EntityName>"
  echo "    GRAPHQL_SCHEMA=<path/to/schema.graphql> bash $0 <EntityName>"
  echo "  If the file is missing entirely, generate it from the UI bundle dir:"
  echo "    cd force-app/main/default/uiBundles/<app-name> && npm run graphql:schema"
  exit 1
fi

if [ ! -r "$SCHEMA" ]; then
  echo "ERROR: schema.graphql is not readable at $SCHEMA"
  echo "  Check file permissions: ls -la $SCHEMA"
  exit 1
fi

if [ ! -s "$SCHEMA" ]; then
  echo "ERROR: schema.graphql is empty at $SCHEMA"
  echo "  Regenerate it from the UI bundle dir:"
  echo "    cd force-app/main/default/uiBundles/<app-name> && npm run graphql:schema"
  exit 1
fi

# Announce the resolved schema so a wrong-file match is visible, not silent.
# stderr keeps it out of the parsed lookup output on stdout.
echo "[graphql-search] using schema: $SCHEMA" >&2

# ── Helper: extract lines from a grep match through the closing brace ────────
# Prints up to MAX_LINES lines after (and including) the first match of PATTERN.
# Uses a generous line count — blocks are always closed by a "}" line.

extract_block() {
  local label="$1"
  local pattern="$2"
  local max_lines="$3"

  local match
  local grep_exit=0
  match=$(grep -nE "$pattern" "$SCHEMA" | head -1) || grep_exit=$?

  if [ "$grep_exit" -eq 2 ]; then
    echo "  ERROR: grep failed on pattern: $pattern" >&2
    return 1
  fi

  if [ -z "$match" ]; then
    echo "  (not found: $pattern)"
    return 3
  fi

  echo "### $label"
  grep -E "$pattern" "$SCHEMA" -A "$max_lines" | \
    awk '/^\}$/{print; exit} {print}' | \
    head -n "$max_lines" || true
  echo ""
}

# ── Main loop ────────────────────────────────────────────────────────────────

for ENTITY in "$@"; do
  # Validate entity name: must be a valid PascalCase identifier (letters, digits, underscores)
  if [[ ! "$ENTITY" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
    echo "ERROR: Invalid entity name: '$ENTITY'"
    echo "  Entity names must start with a letter or underscore, followed by letters, digits, or underscores."
    echo "  Examples: Account, My_Custom_Object__c"
    continue
  fi

  echo ""
  echo "======================================================================"
  echo "  SCHEMA LOOKUP: $ENTITY"
  echo "======================================================================"
  echo ""

  found=0

  # Helper: call extract_block, track matches, surface errors
  try_extract() {
    local rc=0
    extract_block "$@" || rc=$?
    if [ "$rc" -eq 0 ]; then
      found=$((found + 1))
    elif [ "$rc" -eq 1 ]; then
      echo "  Aborting lookup for '$ENTITY' due to grep error" >&2
    fi
    # rc=3 is not-found — continue silently (already printed by extract_block)
  }

  # 1. Type definition — all fields and relationships
  try_extract \
    "Type definition — fields and relationships" \
    "^type ${ENTITY} implements Record" \
    200

  # 2. Filter input — used in `where:` arguments
  try_extract \
    "Filter options — use in where: { ... }" \
    "^input ${ENTITY}_Filter" \
    100

  # 3. OrderBy input — used in `orderBy:` arguments
  try_extract \
    "Sort options — use in orderBy: { ... }" \
    "^input ${ENTITY}_OrderBy" \
    60

  # 4. Create mutation wrapper
  try_extract \
    "Create mutation wrapper — ${ENTITY}CreateInput" \
    "^input ${ENTITY}CreateInput" \
    10

  # 5. Create mutation fields
  try_extract \
    "Create mutation fields — ${ENTITY}CreateRepresentation" \
    "^input ${ENTITY}CreateRepresentation" \
    100

  # 6. Update mutation wrapper
  try_extract \
    "Update mutation wrapper — ${ENTITY}UpdateInput" \
    "^input ${ENTITY}UpdateInput" \
    10

  # 7. Update mutation fields
  try_extract \
    "Update mutation fields — ${ENTITY}UpdateRepresentation" \
    "^input ${ENTITY}UpdateRepresentation" \
    100

  if [ "$found" -eq 0 ]; then
    echo "WARNING: No schema entries found for '$ENTITY'."
    echo "  - Names are PascalCase (e.g., 'Account' not 'account')"
    echo "  - Custom objects may need deployment first"
  fi

  echo ""
done
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall