npx skills add https://github.com/jaganpro/sf-skills --skill sf-data当用户需要执行 Salesforce 数据工作 时使用此技能:记录增删改查、批量导入/导出、测试数据生成、清理脚本,或用于验证 Apex、Flow 或集成行为的数据工厂模式。
当工作涉及以下内容时,使用 sf-data:
sf data CLI 命令当用户进行以下操作时,请委托给其他技能:
确认用户想要哪种模式:
| 模式 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 使用场景 |
|---|
| 脚本生成 | 他们希望获得可重用的 .apex、CSV 或 JSON 资产,而无需立即操作组织 |
| 远程执行 | 他们希望现在就在真实组织中创建/更改记录 |
如果用户可能只想要脚本,请不要假设是远程执行。
询问或推断:
sf-data 作用于 远程组织数据,除非用户明确希望生成本地脚本。如果缺少元数据,请停止并移交至:
确认对象/字段可用性、组织授权以及所需的父记录。
在创建或更新记录之前,使用对象描述数据来验证:
示例模式:
sf sobject describe --sobject ObjectName --target-org <alias> --json
有用的过滤器:
# 必填且可创建的字段
jq '.result.fields[] | select(.nillable==false and .createable==true) | {name, type}'
# 某个字段的有效选择列表值
jq '.result.fields[] | select(.name=="StageName") | .picklistValues[].value'
# 创建时无法设置的字段
jq '.result.fields[] | select(.createable==false) | .name'
| 需求 | 默认方法 |
|---|---|
| 少量一次性增删改查 | sf data 单记录命令 |
| 大型导入/导出 | 通过 sf data ... bulk 使用 Bulk API 2.0 |
| 父子级种子数据集 | 树状导入/导出 |
| 可重用的测试数据集 | 工厂/匿名 Apex 脚本 |
| 可逆的实验 | 清理脚本或基于保存点的方法 |
当 assets/ 下的内置模板适用时使用它们:
assets/factories/assets/bulk/assets/cleanup/assets/soql/assets/csv/assets/json/在创建或更新后检查数量、关系和记录 ID。
如果创建失败:
请 不要 无限重复相同的失败命令。
每当创建了数据时,提供确切的清理命令或回滚资产。
优先选择以下一种方式:
| 错误 | 可能原因 | 默认修复方向 |
|---|---|---|
INVALID_FIELD | 错误的字段 API 名称或字段级安全性问题 | 验证架构和访问权限 |
REQUIRED_FIELD_MISSING | 遗漏了必填字段 | 根据描述数据包含必填值 |
INVALID_CROSS_REFERENCE_KEY | 错误的父记录 ID | 首先创建/验证父记录 |
FIELD_CUSTOM_VALIDATION_EXCEPTION | 验证规则阻止了记录 | 使用有效的测试数据或调整设置 |
| 无效的选择列表值 | 猜测值而非基于描述的值 | 首先检查选择列表值 |
| 不可写字段错误 | 字段不可创建/不可更新 | 将其从负载中移除 |
| 批量限制/超时 | 工具不适合该数据量 | 切换到批量/分阶段导入 |
完成时,按以下顺序报告:
建议格式:
数据操作: <创建 / 更新 / 删除 / 导出 / 播种>
对象: <对象 + 数量>
目标: <组织别名或本地路径>
工件: <记录 ID / csv / apex / json 文件>
验证: <通过 / 部分 / 失败>
清理: <确切的删除或回滚指导>
| 需求 | 委托给 | 原因 |
|---|---|---|
| 发现对象/字段结构 | sf-metadata | 准确的架构基础 |
| 运行对批量敏感的 Apex 验证 | sf-testing | 测试执行和覆盖率 |
| 首先部署缺失的架构 | sf-deploy | 元数据准备就绪 |
| 实现使用该数据的生产逻辑 | sf-apex 或 sf-flow | 行为实现 |
| 分数 | 含义 |
|---|---|
| 117+ | 强大的生产安全数据工作流 |
| 104–116 | 良好的操作,可能有小的改进空间 |
| 91–103 | 可接受,但建议审查 |
| 78–90 | 存在部分/有风险的模式 |
| < 78 | 在纠正之前受阻 |
每周安装量
268
代码仓库
GitHub 星标数
219
首次出现
Jan 22, 2026
安全审计
安装于
codex258
opencode257
cursor257
gemini-cli256
github-copilot254
amp251
Use this skill when the user needs Salesforce data work : record CRUD, bulk import/export, test data generation, cleanup scripts, or data factory patterns for validating Apex, Flow, or integration behavior.
Use sf-data when the work involves:
sf data CLI commandsDelegate elsewhere when the user is:
Confirm which mode the user wants:
| Mode | Use when |
|---|---|
| Script generation | they want reusable .apex, CSV, or JSON assets without touching an org yet |
| Remote execution | they want records created / changed in a real org now |
Do not assume remote execution if the user may only want scripts.
Ask for or infer:
sf-data acts on remote org data unless the user explicitly wants local script generation.If metadata is missing, stop and hand off to:
Confirm object / field availability, org auth, and required parent records.
Before creating or updating records, use object describe data to validate:
Example pattern:
sf sobject describe --sobject ObjectName --target-org <alias> --json
Helpful filters:
# Required + createable fields
jq '.result.fields[] | select(.nillable==false and .createable==true) | {name, type}'
# Valid picklist values for one field
jq '.result.fields[] | select(.name=="StageName") | .picklistValues[].value'
# Fields that cannot be set on create
jq '.result.fields[] | select(.createable==false) | .name'
| Need | Default approach |
|---|---|
| small one-off CRUD | sf data single-record commands |
| large import/export | Bulk API 2.0 via sf data ... bulk |
| parent-child seed set | tree import/export |
| reusable test dataset | factory / anonymous Apex script |
| reversible experiment | cleanup script or savepoint-based approach |
Use the built-in templates under assets/ when they fit:
assets/factories/assets/bulk/assets/cleanup/assets/soql/assets/csv/assets/json/Check counts, relationships, and record IDs after creation or update.
If creation fails:
Do not repeat the same failing command indefinitely.
Provide exact cleanup commands or rollback assets whenever data was created.
Prefer one of:
| Error | Likely cause | Default fix direction |
|---|---|---|
INVALID_FIELD | wrong field API name or FLS issue | verify schema and access |
REQUIRED_FIELD_MISSING | mandatory field omitted | include required values from describe data |
INVALID_CROSS_REFERENCE_KEY | bad parent ID | create / verify parent first |
FIELD_CUSTOM_VALIDATION_EXCEPTION | validation rule blocked the record | use valid test data or adjust setup |
| invalid picklist value | guessed value instead of describe-backed value | inspect picklist values first |
When finishing, report in this order:
Suggested shape:
Data operation: <create / update / delete / export / seed>
Objects: <object + counts>
Target: <org alias or local path>
Artifacts: <record ids / csv / apex / json files>
Verification: <passed / partial / failed>
Cleanup: <exact delete or rollback guidance>
| Need | Delegate to | Reason |
|---|---|---|
| discover object / field structure | sf-metadata | accurate schema grounding |
| run bulk-sensitive Apex validation | sf-testing | test execution and coverage |
| deploy missing schema first | sf-deploy | metadata readiness |
| implement production logic consuming the data | sf-apex or sf-flow | behavior implementation |
| Score | Meaning |
|---|---|
| 117+ | strong production-safe data workflow |
| 104–116 | good operation with minor improvements possible |
| 91–103 | acceptable but review advised |
| 78–90 | partial / risky patterns present |
| < 78 | blocked until corrected |
Weekly Installs
268
Repository
GitHub Stars
219
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex258
opencode257
cursor257
gemini-cli256
github-copilot254
amp251
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
| non-writeable field error | field is not createable / updateable | remove it from the payload |
| bulk limits / timeouts | wrong tool for the volume | switch to bulk / staged import |