Skip to content

forcedotcom/sf-skills / plugins/builder/experience-react/skills/experience-ui-bundle-app-coordinate

experience-ui-bundle-app-coordinate

Verified

MUST activate when the user wants to build, create, or generate a React application, React app, web application, single-page application (SPA), or frontend application — even if no project files exist yet. MUST also activate when the project contains a uiBundles/*/src/ directory or sfdx-project.json and the prompt says create, build, construct, or generate a new app, site, or page from scratch — even if the prompt also describes visual styling. MUST also activate when the task spans more than one ui-bundle skill. Use this skill when building a complete app end-to-end. Do NOT use for Lightning Experience apps with custom objects (use platform-lightning-app-coordinate). Do NOT use for single-concern edits to an existing page (use experience-ui-bundle-frontend-generate).

scripts/check-dangling-refs.mjs

View on GitHub
#!/usr/bin/env node
// Verify no surviving file still imports/references a file deleted during
// scaffold pruning.
// Usage: node check-dangling-refs.mjs <deleted-basename> [<deleted-basename> ...]
//   <deleted-basename> is the file name without extension, e.g. "codegen" for
//   codegen.yml, "graphqlClient" for src/api/graphqlClient.ts, "useAsyncData"
//   for the deleted hook.
//
// Always invoke via `node` (never as a bare executable) so this works on
// Windows cmd/PowerShell as well as macOS/Linux/Git Bash. Quote each
// <deleted-basename> argument.
//
// Exit 0 if no dangling references found, exit 1 with error message(s) if
// any are found.

import fs from "node:fs";
import path from "node:path";

const EXCLUDE_DIRS = new Set(["node_modules", "dist", "build", ".git"]);
const UIBUNDLES_DIR = path.join("force-app", "main", "default", "uiBundles");

// Filesystem read errors encountered while walking the bundle or reading a
// file. A dangling-reference scan that could not read part of the tree has NOT
// proven the reference is gone, so any entry here must turn a would-be SUCCESS
// into a non-zero exit (see the end of the script).
const ioErrors = [];

function findBundleDir() {
  let entries;
  try {
    entries = fs.readdirSync(UIBUNDLES_DIR, { withFileTypes: true });
  } catch {
    // uiBundles dir absent/unreadable: return "" so the caller emits an explicit
    // "No UI bundle directory found" error and exits non-zero. This is a handled,
    // expected case (e.g. a fresh project), not a silently-swallowed failure.
    return "";
  }
  const dirs = entries
    .filter((e) => e.isDirectory())
    .map((e) => e.name)
    .sort();
  return dirs.length > 0 ? path.join(UIBUNDLES_DIR, dirs[0]) : "";
}

function collectFiles(dir, out) {
  let entries;
  try {
    entries = fs.readdirSync(dir, { withFileTypes: true });
  } catch (err) {
    // A subdirectory we cannot list may hide a surviving reference. Record it so
    // the run fails rather than reporting an untrustworthy SUCCESS.
    ioErrors.push(`could not read directory '${dir}': ${err.message}`);
    return;
  }
  for (const entry of entries) {
    const full = path.join(dir, entry.name);
    if (entry.isDirectory()) {
      if (EXCLUDE_DIRS.has(entry.name)) continue;
      collectFiles(full, out);
    } else if (entry.isFile()) {
      out.push(full);
    }
  }
}

const basenames = process.argv.slice(2);

if (basenames.length === 0) {
  console.error(
    "ERROR: check-dangling-refs.mjs requires at least one deleted-file basename as an argument",
  );
  process.exit(1);
}

const bundleDir = findBundleDir();

if (!bundleDir) {
  console.error(`ERROR: No UI bundle directory found in ${UIBUNDLES_DIR}${path.sep}`);
  process.exit(1);
}

const files = [];
collectFiles(bundleDir, files);

let foundDangling = false;

for (const basename of basenames) {
  const matches = [];
  for (const file of files) {
    let content;
    try {
      content = fs.readFileSync(file, "utf8");
    } catch (err) {
      // Could not read a surviving file — record and skip. We cannot confirm it
      // is free of the deleted reference, so the run must not report SUCCESS.
      ioErrors.push(`could not read file '${file}': ${err.message}`);
      continue;
    }
    if (content.includes(basename)) {
      matches.push(file);
    }
  }

  if (matches.length > 0) {
    foundDangling = true;
    console.error(`ERROR: Dangling reference to deleted file '${basename}' found in:`);
    for (const match of matches) {
      console.error(`  - ${match}`);
    }
  }
}

if (foundDangling) {
  process.exit(1);
}

// A read failure means the scan was incomplete — do not claim SUCCESS.
if (ioErrors.length > 0) {
  console.error(
    "ERROR: dangling-reference scan is incomplete — some paths could not be read:",
  );
  for (const e of ioErrors) {
    console.error(`  - ${e}`);
  }
  console.error(
    "Resolve the read errors above and re-run; not reporting SUCCESS on an incomplete scan.",
  );
  process.exit(1);
}

console.log(`SUCCESS: No dangling references found for: ${basenames.join(" ")}`);
process.exit(0);
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