PranavNagrecha/AwesomeSalesforceSkills / skills/admin/einstein-discovery-setup
einstein-discovery-setup
VerifiedUse this skill when an admin needs to create an Einstein Discovery story in CRM Analytics Studio, configure prediction definitions, deploy writeback fields, set up what-if analysis, or manage model refresh and activation. Trigger keywords: Einstein Discovery story, prediction definition, writeback field, CRM Analytics Studio, model refresh, what-if analysis, bulk scoring, prediction field, 1OR prefix. NOT for the Einstein Discovery Flow action or model-health monitoring in Model Manager — use admin/einstein-discovery-deployment. NOT for Einstein Prediction Builder, a separate product needing no CRM Analytics license — use agentforce/einstein-prediction-builder. NOT for programmatic scoring through the Connect REST API — use agentforce/einstein-discovery-development.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 15.1 KB |
| references/examples.md | markdown | 6.4 KB |
| references/gotchas.md | markdown | 6.7 KB |
| references/llm-anti-patterns.md | markdown | 11.0 KB |
| references/metadata-examples.md | markdown | 6.6 KB |
| references/well-architected.md | markdown | 6.7 KB |
| scripts/check_einstein_discovery_setup.pyexecutable | script | 8.8 KB |
| templates/einstein-discovery-setup-template.md | markdown | 2.6 KB |
scripts/check_einstein_discovery_setup.py
View on GitHub#!/usr/bin/env python3
"""Checker script for Einstein Discovery Setup skill.
Inspects Salesforce metadata to detect common Einstein Discovery setup issues:
- Writeback fields missing field-level security grants
- Writeback field count approaching or exceeding the limit per object
- Prediction definitions that may reference stale model versions
- Story metadata missing deployment configuration
Uses stdlib only — no pip dependencies.
Usage:
python3 check_einstein_discovery_setup.py [--help]
python3 check_einstein_discovery_setup.py --manifest-dir path/to/metadata
"""
from __future__ import annotations
import argparse
import sys
import xml.etree.ElementTree as ET
from pathlib import Path
# UNVERIFIED (2026-10-03): the three-writeback-field ceiling and the `Einstein_` field prefix came
# from earlier versions of this skill and were not found in the Summer '26 docs; the limit is kept
# as an advisory threshold. The former `1OR` prediction-definition key-prefix constant was unused and
# unsupported, and has been removed.
WRITEBACK_FIELD_LIMIT = 3
EINSTEIN_FIELD_PREFIXES = ("Einstein_", "einstein_")
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description=(
"Check Einstein Discovery Setup configuration and metadata for common issues. "
"Detects writeback field FLS gaps, object-level writeback field limits, "
"and prediction definition configuration problems."
),
)
parser.add_argument(
"--manifest-dir",
default=".",
help="Root directory of the Salesforce metadata (default: current directory).",
)
return parser.parse_args()
def find_xml_files(root: Path, pattern: str) -> list[Path]:
"""Return all XML files matching a glob pattern under root."""
return sorted(root.rglob(pattern))
def check_writeback_field_fls(manifest_dir: Path) -> list[str]:
"""Check that Einstein writeback fields have at least one FLS grant.
Looks for CustomField metadata files whose name starts with an Einstein prefix
and checks corresponding Profile or PermissionSet metadata for fieldPermissions entries.
Returns issue strings for any writeback field with no FLS grants found.
"""
issues: list[str] = []
# Collect writeback field names from CustomField metadata
writeback_fields: list[str] = []
fields_dir = manifest_dir / "objects"
if not fields_dir.exists():
fields_dir = manifest_dir # flat structure fallback
for field_file in find_xml_files(manifest_dir, "*.field-meta.xml"):
field_name = field_file.stem.replace(".field-meta", "")
if any(field_name.startswith(prefix) for prefix in EINSTEIN_FIELD_PREFIXES):
writeback_fields.append(field_name)
if not writeback_fields:
return issues # No writeback fields found — nothing to check
# Collect field permissions granted in profiles and permission sets
granted_fields: set[str] = set()
for perm_file in find_xml_files(manifest_dir, "*.profile-meta.xml"):
granted_fields.update(_extract_field_permissions(perm_file))
for perm_file in find_xml_files(manifest_dir, "*.permissionset-meta.xml"):
granted_fields.update(_extract_field_permissions(perm_file))
for field_name in writeback_fields:
# Check if any permission grants read access for this field
field_found = any(
field_name in granted_field for granted_field in granted_fields
)
if not field_found:
issues.append(
f"Einstein writeback field '{field_name}' has no field-level security grants "
f"in any profile or permission set. The field will be invisible to all users "
f"in reports, list views, and page layouts until FLS is assigned."
)
return issues
def _extract_field_permissions(perm_file: Path) -> list[str]:
"""Return field names where readable=true in a Profile or PermissionSet XML file."""
readable_fields: list[str] = []
try:
tree = ET.parse(perm_file)
root = ET.getroot()
ns = {"sf": "http://soap.sforce.com/2006/04/metadata"}
for fp in root.findall(".//sf:fieldPermissions", ns):
readable_el = fp.find("sf:readable", ns)
field_el = fp.find("sf:field", ns)
if (
readable_el is not None
and field_el is not None
and readable_el.text == "true"
):
readable_fields.append(field_el.text or "")
except ET.ParseError:
pass # Malformed XML — skip silently
return readable_fields
def check_writeback_field_count_per_object(manifest_dir: Path) -> list[str]:
"""Check that no Salesforce object exceeds the max writeback fields limit.
Counts Einstein writeback fields per object and warns if count equals or exceeds 3.
"""
issues: list[str] = []
object_field_counts: dict[str, list[str]] = {}
for field_file in find_xml_files(manifest_dir, "*.field-meta.xml"):
field_name = field_file.stem.replace(".field-meta", "")
if not any(field_name.startswith(prefix) for prefix in EINSTEIN_FIELD_PREFIXES):
continue
# Infer object name from parent directory or file path
object_name = field_file.parent.name
if object_name == "fields":
object_name = field_file.parent.parent.name
if object_name not in object_field_counts:
object_field_counts[object_name] = []
object_field_counts[object_name].append(field_name)
for object_name, fields in object_field_counts.items():
count = len(fields)
if count >= WRITEBACK_FIELD_LIMIT:
issues.append(
f"Object '{object_name}' has {count} Einstein Discovery writeback field(s) "
f"({', '.join(fields)}). This reaches the {WRITEBACK_FIELD_LIMIT}-field advisory threshold (UNVERIFIED as a platform limit, 2026-10-03). "
f"Deploying an additional prediction with writeback on this object will fail."
)
elif count == WRITEBACK_FIELD_LIMIT - 1:
issues.append(
f"Object '{object_name}' has {count} Einstein Discovery writeback field(s). "
f"One more writeback field reaches the {WRITEBACK_FIELD_LIMIT}-field advisory threshold. "
f"Review before adding another prediction definition with writeback on this object."
)
return issues
def check_prediction_definition_files(manifest_dir: Path) -> list[str]:
"""Check prediction definition metadata for common configuration issues.
Looks for PredictionDefinition metadata XML files and checks for:
- Missing or disabled status
- Missing target object mapping
"""
issues: list[str] = []
for pd_file in find_xml_files(manifest_dir, "*.predictionDef-meta.xml"):
try:
tree = ET.parse(pd_file)
root = ET.getroot()
ns = {"sf": "http://soap.sforce.com/2006/04/metadata"}
status_el = root.find(".//sf:status", ns)
object_el = root.find(".//sf:targetObject", ns)
if status_el is None or status_el.text != "Enabled":
status_val = status_el.text if status_el is not None else "missing"
issues.append(
f"PredictionDefinition '{pd_file.name}' has status '{status_val}'. "
f"Prediction definitions must be in 'Enabled' status for scoring to run."
)
if object_el is None or not (object_el.text or "").strip():
issues.append(
f"PredictionDefinition '{pd_file.name}' is missing a targetObject mapping. "
f"Scoring cannot run without a target Salesforce object."
)
except ET.ParseError:
issues.append(
f"PredictionDefinition file '{pd_file.name}' could not be parsed as XML. "
f"Check the file for syntax errors."
)
return issues
def check_einstein_discovery_setup(manifest_dir: Path) -> list[str]:
"""Run all Einstein Discovery setup checks and return a combined list of issues."""
issues: list[str] = []
if not manifest_dir.exists():
issues.append(f"Manifest directory not found: {manifest_dir}")
return issues
issues.extend(check_writeback_field_fls(manifest_dir))
issues.extend(check_writeback_field_count_per_object(manifest_dir))
issues.extend(check_prediction_definition_files(manifest_dir))
return issues
def main() -> int:
args = parse_args()
manifest_dir = Path(args.manifest_dir)
issues = check_einstein_discovery_setup(manifest_dir)
if not issues:
print("No issues found.")
return 0
for issue in issues:
print(f"WARN: {issue}", file=sys.stderr)
return 1
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |