From sf-demo-scout
Canonical deployment rules for Flows, Apex, LWC, Agentforce, Page Layouts, Queues, and Picklists in SF Demo Prep. Pattern-gated 3-attempt rule, known deploy-error patterns, rollback commands, and per-category deployment procedures. TRIGGER when: a phase sub-agent needs deployment rules outside its inlined scope, or needs to verify rollback command syntax. DO NOT TRIGGER when: deploying metadata (phase prompts inline the relevant rules), during sparring, or for permission set generation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/sf-demo-scout:demo-deployment-rulesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
One home per category:
One home per category:
${CLAUDE_PLUGIN_ROOT}/prompts/building/phase1.md. This skill file does NOT duplicate them. If a Phase 1 sub-agent needs a rule, it reads its own prompt.sf-flow, platform-apex-generate, experience-lwc-generate, agentforce-generate). This skill file carries the rollback commands, the attempt-rule meta-rule, unfamiliar-error escalation, and Script Deliverable Rules that the phase prompts reference but do not inline. The Known Deploy-Error Patterns catalog lives in references/deploy-error-patterns.md (loaded on demand on a deploy failure).Attempt rule (max 3, pattern-gated): every retry must carry a new fix — never redeploy unchanged metadata, it fails identically.
Unfamiliar errors: if the error message is not self-evident, not already
in a loaded orgs/lessons/ topic, and not matched by a Known Deploy-Error Pattern, invoke
the demo-docs-consultation skill before the next attempt. Record the
consultation in docs_consulted.
The full catalog of deterministic fixes for recurring Salesforce metadata
deploy errors lives in
references/deploy-error-patterns.md.
On a deploy failure, read that file, match the error, and apply the
documented fix — the attempt rule above counts a match as the next attempt.
These are org-agnostic parse errors (distinct from orgs/lessons/, which
holds org-specific gotchas); a rule-based fix is preferred over improvising.
The catalog currently covers FlexiPage (Pattern A — duplicate
componentInstance; Pattern B — design-time component not found), PermissionSet
(Pattern C — FLS on a required / master-detail field), and LWC (Pattern D —
literal in template expression / apiVersion-66). Pattern B removes a component
the SE must re-add via Lightning App Builder → SE Manual Checklist. To extend
the catalog, add a new pattern there via /project-sparring; org-specific
gotchas still go to orgs/lessons/ (topic-clustered).
Applies whenever a sub-agent produces a reusable shell or language script as part of its deliverable — data-seeding scripts, Apex test-data factories, agent smoke-test harnesses, cleanup scripts. The script is an SE-runnable artifact that outlives the session.
Default execution pattern (Pattern B — idempotent script):
--pilot-only flag that exercises every distinct command/object path the bulk run uses — one real guarded write per (CLI verb × target object) combination, against one target record each (or the minimum viable slice) — before the bulk path runs. A pilot that touches only one path while the bulk run uses several is structurally unable to catch a bug in the untested paths. Exit code 0 with expected counts on every exercised path = pass; anything else = fail.discovery_notes. Pattern B is the default; Pattern A is the exception.Mandatory self-test before returning the deliverable:
bash -n [script] — syntax check. Cheap insurance against later edits; will NOT catch runtime bugs (subshell exports, declare -A under Bash 3.2, JSON envelope unwrap, while-loop counter scope). Run it anyway.bash [script] --pilot-only against the live target org — the mandatory step that exercises every distinct command/object path at low cost. If the bulk run does import bulk on three objects plus an update record on a fourth, the pilot MUST exercise all four (verb × object) combinations, not just the cheapest one — a pilot that validates a single path while the real run uses several will certify a script whose untested paths are broken. Confirm exit 0 AND expected record counts (e.g., 1 pilot record per exercised path) BEFORE returning the sub-agent's output. This is what actually catches the Bash 3.2 / declare -A class of failure AND a wrong CLI verb on a path the pilot would otherwise skip.--pilot-only until it passes. Every bug caught during self-test goes in the issues array verbatim (with the error or symptom). Do NOT hide them behind a successful final run — the orchestrator and the SE need to know what was fragile. The sub-agent MUST be honest about the state of its deliverable.declare -A, use temp-file JSON for Python↔bash state handoff"), record it in discovery_notes as well — it carries forward; issues is this session only.SE-runnable standalone contract:
orgs/[alias]-[customer]/[script-name].sh (or language-appropriate extension). Change log records its path and the --pilot-only + bulk invocation commands. Handover brief surfaces both commands under Your Files.Target environment defaults (macOS SE laptop):
/bin/bash). No declare -A, no ${var^^}, no &>. If associative arrays are genuinely needed, use temp-file JSON parsed via python3 / jq.python3 and jq available (both in standard SE install). sf CLI and MCP available in-session only — the SE re-run path uses sf CLI.Salesforce CLI data-write command reference (pin these — do not invent verbs):
At demo-seed scale (handfuls to low hundreds of records — every Scout seed) use the single-record commands. They return clean JSON and need no CSV:
sf data create record --sobject <Object> --values "Field1=val Field2=val" --target-org <alias> --jsonsf data update record --sobject <Object> --record-id <Id> --values "Field=val" --target-org <alias> --jsonsf data query --query "<SOQL>" --target-org <alias> --jsonBulk API 2.0 is for thousands of records and is rarely warranted in a demo seed. If genuinely needed, the verbs are (Bulk API 2.0, sf v2):
sf data import bulk (paired with sf data import resume). There is NO sf data create bulk — that verb does not exist; import bulk IS the insert path.sf data upsert bulk (paired with sf data upsert resume) — requires an external-Id field.sf data update bulk. Delete: sf data delete bulk. Export: sf data export bulk.bulk verb submits a job and returns a jobId; the success/failed record counts and the *-success-records.csv / *-failed-records.csv files come from sf data bulk results --job-id <id> (or the paired resume command) — NOT from the submitting command's immediate output.Full procedure lives under <!-- IF:LRP --> in ${CLAUDE_PLUGIN_ROOT}/prompts/building/phase1.md. This summary is for orchestrator-level decisions and rollback.
Autonomous scope:
flexipage:fieldSection whose label matches the spec verbatim. Single-column sections: deploy targets the section-body Facet directly. Multi-column sections: spec names a Target column (1-indexed), deploy follows the section-body Facet → flexipage:column componentInstance → column-body Facet, appends there.field_section or mixed per audit. Re-verified at deploy time via pre-flight grep on retrieved XML.field_sections[].columns[] must carry a non-null facet_uuid for the targeted column — opaque sections route to SE Manual.Out of scope (skip — SE Manual):
record_detail (use classic Page Layout instead), custom, or unretrievable.facet_uuid: null (opaque column structure).Rollback:
.preedit sidecar). Restore the pre-edit XML and redeploy:
sf project deploy start --metadata FlexiPage:[Name] --target-org [alias]sf project delete source --metadata FlexiPage:[Name] rollback path because deletion would remove the page entirely (catastrophic for a live demo surface). Always restore-and-redeploy.Autonomous-with-SE-gate flow scope matches sf-flow's full trigger spectrum: record-triggered (before-save / after-save / before-delete; any object; cross-object DML allowed), screen flows (whitelist below), autolaunched flows, subflows, scheduled flows, and platform-event-triggered flows. Orchestration flows and complex screen flows route to SE Manual — if one reaches Phase 2, skip with reason "out of scope for autonomous deploy — SE Manual Checklist."
sf-flow skill before generating any Flow XML — it holds the 110-point validation checklist, the full asset template set, and reference guides.${CLAUDE_PLUGIN_ROOT}/skills/sf-flow/references/xml-gotchas.md — root-level alphabetical ordering, fault-connector self-reference, relationship-field traps in recordLookups, storeOutputAutomatically data-leak risk. Deployment blockers.issues.<status>Draft</status>). Confirm success.sf flow run test --class-names [FlowApiName]_Test --target-org [alias] --json. Pass → activate. Fail twice → skip activation, record in issues — never activate a flow that failed its own smoke test. Per-type FlowTest adaptations live in building/phase2.md Flow Rules step 4.retrieve_metadata — flag execution order conflicts in discovery_notes.rollback_commands):
sf project delete source --metadata Flow:[FlowApiName] --target-org [alias]
Plus QuickAction:[Name] if deployed, FlowTest:[FlowApiName]_Test if deployed.record-triggered-before-save.xml, record-triggered-after-save.xml, record-triggered-before-delete.xml.<recordTriggerType>Delete</recordTriggerType> + <triggerType>RecordBeforeDelete</triggerType>. No after-delete flavor exists.screen-flow-template.xml. LWC-embedded variant (screen-flow-with-lwc.xml) is out of autonomous scope.<queriedFields> — never <storeOutputAutomatically> in screen flows, per xml-gotchas).QuickAction (actionType=Flow), retrieve active layout, add under <quickActionListItems>, redeploy.autolaunched-flow-template.xml.Flow.Interview), subflow, process, or REST. FlowTest exercises via <parameters> block providing input variables.${CLAUDE_PLUGIN_ROOT}/skills/sf-flow/assets/subflows/ (bulk-updater, dml-rollback, email-alert, error-logger, query-with-retry, record-validator).scheduled-flow-template.xml. Built on autolaunched skeleton with a <schedule> block in <start>.<startDate> (YYYY-MM-DD, ≥ demo date unless recurring), <startTime> (HH:MM:SS), <frequency> (Once / Daily / Weekly / Monthly / Yearly / Hourly / Weekdays — FlowSchedule subtype, API v66.0+). Pre-flight: if any field missing in spec, skip.<object> + <filters> for batch-record runs (max 250K interviews/day).SCHEDULED_FLOW_DETAIL debug log event confirms record count per run.retrieve_metadata read-back.platform-event-flow-template.xml.<start><object> = platform event API name (CustomEvent__e or standard — AIPredictionEvent, BatchApexErrorEvent, FlowExecutionErrorEvent, etc.).retrieve_metadata. If the spec deploys a new platform event in the same run, deploy the event before the flow.<parameters> blocks, one per referenced event field.Scope: single-trigger, single-object. No cross-object Apex. No test classes (demo org context).
platform-apex-generate skill for generation rules.run_code_analyzer before deploying (if MCP available). Record any
high-severity findings in issues.sf project delete source --metadata ApexClass:[ClassName] --target-org [alias]sf project delete source --metadata ApexTrigger:[TriggerName] --target-org [alias]Scope: demo-specific UI — Customer 360 Cards, custom record views, branded components.
run_code_analyzer before deploying (if MCP available). Record
high-severity findings in issues.sf project delete source --metadata LightningComponentBundle:[ComponentName] --target-org [alias]Two paths depending on whether the agent is new or already exists in the
org. Both use the ADLC skill suite (agentforce-generate,
agentforce-test, agentforce-observe).
Scope: single agent, topic-based routing with Apex or Flow backing actions.
agentforce-generate skill — follow its "Create an Agent"
workflow.retrieve_metadata — flag conflicts
in issues.run_code_analyzer on Apex backing actions (if MCP available).sf agent validate authoring-bundle before publishing.sf agent preview before publishing.sf project delete source --metadata AiAuthoringBundle:[AgentName] --target-org [alias]sf project delete source --metadata ApexClass:[ClassName] --target-org [alias] (backing Apex)For agents already in the org (e.g., SDO/IDO pre-installed agents). Every
publish creates a new version; previous versions remain activatable, so
rollback is instant via sf agent activate --version-number N.
agentforce-generate skill — follow its "Modify an Existing
Agent" workflow.sf agent deactivate --json --api-name [AgentName] --target-org [alias]sf agent activate --json --api-name [AgentName] --version-number [N] --target-org [alias]After the agent is activated, run the official agent test suite using the agentforce-test skill. Prefer Mode B (Testing Center) — build the test-spec.yaml from the spec's Agent test cases and run it:
test-spec.yaml in the official format (delegate the schema to agentforce-test: basic-test-spec.yaml + guardrail-test-spec.yaml are authoritative). Map each spec test-case row to utterance / expectedTopic / expectedActions (Level-2 invocation names) / expectedOutcome. Include at least one guardrail/off-topic row. Never attach the instruction_following / conciseness / completeness metrics (UI crash / score-0 / routing penalty) — rely on expectedOutcome (LLM-as-judge).sf agent test create --json --spec test-spec.yaml --api-name [Suite] -o [alias]sf agent test run --json --api-name [Suite] --wait 10 --result-format json -o [alias]sf agent test results --json --job-id [runId] -o [alias] (use --job-id from the run output, NEVER --use-most-recent). Filter the guardrail false-negative: a topic_assertion FAILURE on a row with empty expectedTopic is spurious.sf agent test is unavailable, fall back to a Mode A sf agent preview conversational check (start/send/end --authoring-bundle) and record the fallback in discovery_notes.smoke_test object of your JSON output.A failed test suite does NOT block deployment — the agent is already active. Record failures in issues and flag for the SE. The event-log Action-Invocation Probe (building/sub-agent-validation.md) remains the deterministic gate for hero-action invocation; the suite runs alongside it.
If the spec asks for any of the following, skip with reason "out of scope for autonomous deploy — SE Manual Checklist":
npx claudepluginhub seb-schi/sf-demo-scout --plugin sf-demo-scoutGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.