Salesforce データ操作(130ポイント評価) レコード(Salesforceに保存されたデータ)の作成、更新、削除、一括取り込み/書き出し、テストデータ生成、および組織内の不要なレコード削除を、sf CLI(コマンドライン操作ツール)と無名Apex(実行スクリプト言語)を通じて実行します。 **次のような場合に使用:** - テストデータを生成する - 一括でレコードを取り込みまたは書き出す - sf data CLIコマンドを使用する - Apexテスト用のデータ生成パターンを利用する - 組織内のテストレコードの初期設定または削除を行う **使用しない場合:** - SOQL(Salesforceのデータベース検索言語)クエリの記述のみ → platform-soql-queryを使用 - Apexテストの実行 → platform-apex-test-runを使用 - メタデータ(構成情報)の配置 → platform-metadata-deployを使用
Salesforce data operations with 130-point scoring. Use to create, update, delete, bulk import/export, generate test data, and clean up org records via sf CLI and anonymous Apex. TRIGGER on creating test data, bulk import/export, sf data CLI commands, data-factory patterns for Apex tests, or seeding/cleaning org records. DO NOT TRIGGER for SOQL query writing only (use platform-soql-query), Apex test execution (use platform-apex-test-run), or metadata deployment (use platform-metadata-deploy).
次のような場合に使用: ユーザーがSalesforce のデータ操作を必要としている場合。具体的には、レコードの作成・更新・削除、一括インポート・エクスポート、テストデータの生成、データクリーンアップスクリプト、または Apex・Flow・統合処理の動作を検証するためのデータファクトリーパターン(テストデータ生成テンプレート)。
platform-data-manage は以下の作業を担当します:
sf data CLI コマンド以下の場合は他のスキルに委譲してください:
ユーザーが希望するモードを確認してください:
| モード | 使用場面 |
|---|---|
| スクリプト生成 | ユーザーがまだ組織に変更を加えず、再利用可能な .apex、CSV、JSON ファイルが欲しい場合 |
| リモート実行 | ユーザーが実際の組織に今すぐレコードを作成・変更したい場合 |
ユーザーがスクリプトのみを望んでいる可能性がある場合は、リモート実行を前提としないでください。
以下の情報を確認または推測してください:
platform-data-manage は、ユーザーが明示的にローカルスクリプト生成を希望しない限り、リモート組織のデータに対して実行します。メタデータが不足している場合は、以下に委譲してください:
オブジェクト・フィールドの利用可能性、組織の認証、必須の親レコードを確認してください。
レコードを作成・更新する前に、オブジェクト説明データを使用して以下を検証してください:
詳細は references/sf-cli-data-commands.md を参照してください。sf sobject describe コマンドと jq フィルターパターンを使用してフィールド、ピックリスト値、作成可能制約を検査できます。
| 必要な操作 | デフォルトの方法 |
|---|---|
| 小規模な単発 CRUD | sf data 単一レコードコマンド |
| 大量のインポート・エクスポート | Bulk API 2.0(sf data ... bulk 経由) |
| 親子関係のあるデータセット | ツリーインポート・エクスポート |
| 再利用可能なテストデータセット | ファクトリー・無名 Apex スクリプト |
| 実験の可逆性確保 | クリーンアップスクリプトまたはセーブポイント(保存点)ベースの方法 |
assets/ 下のテンプレートを活用してください:
assets/factories/ — Apex テストデータファクトリースクリプトassets/bulk/ — Bulk API 2.0 Apex テンプレートassets/cleanup/ — クリーンアップ・ロールバックスクリプトassets/soql/ — SOQL クエリテンプレートassets/csv/ — CSV インポートテンプレートassets/json/ — JSON ツリーインポートテンプレート作成・更新後、件数、関連性、レコード ID を確認してください。
作成に失敗した場合:
同じ失敗コマンドを無限に繰り返さないでください。
データが作成された場合は、常に正確なクリーンアップコマンドまたはロールバックアセットを提示してください。
以下のいずれかを選択:
| エラー | 原因の可能性 | デフォルトの対処方向 |
|---|---|---|
INVALID_FIELD |
間違ったフィールド API 名または FLS(フィールドレベルセキュリティ)の問題 | スキーマとアクセス権を検証 |
REQUIRED_FIELD_MISSING |
必須フィールドの欠落 | describe データから必須値を含める |
INVALID_CROSS_REFERENCE_KEY |
無効な親 ID | 親をまず作成・検証 |
FIELD_CUSTOM_VALIDATION_EXCEPTION |
検証ルールがレコードをブロック | 有効なテストデータを使用、またはセットアップを調整 |
| ピックリスト値が無効 | 推測した値(describe データに基づかない) | ピックリスト値をまず確認 |
| 非書き込み可能フィールドエラー | フィールドが作成・更新不可 | ペイロードから削除 |
| 一括制限・タイムアウト | ボリュームに対して間違ったツール | 一括・段階的インポートに切り替え |
完了時は以下の順序で報告してください:
推奨の形式:
データ操作: <作成/更新/削除/エクスポート/シード>
オブジェクト: <オブジェクト + 件数>
対象: <組織エイリアスまたはローカルパス>
アーティファクト: <レコード ID・CSV・Apex・JSON ファイル>
検証: <成功/部分的/失敗>
クリーンアップ: <正確な削除またはロールバック指示>
| 必要な作業 | 委譲先 | 理由 |
|---|---|---|
| カスタムオブジェクトの作成 | platform-custom-object-generate | データ操作の前にスキーマが存在する必要がある |
| カスタムフィールドの作成 | platform-custom-field-generate | データ作成の前にフィールドレベルのスキーマが必要 |
| 一括に敏感な Apex 検証の実行 | platform-apex-test-run | テスト実行とカバレッジ |
| 欠落スキーマの展開 | platform-metadata-deploy | メタデータの準備状態 |
| データを処理する本番 Apex ロジックの実装 | platform-apex-generate | Apex クラス・トリガーの作成 |
| データを処理する Flow ロジックの実装 | automation-flow-generate | Flow の作成と自動化 |
assets/factories/ — Apex テストデータファクトリースクリプト(取引先、連絡先、商談、リード、ユーザーなど)assets/bulk/ — Bulk API 2.0 Apex テンプレート(200、500、10000 件のレコード挿入;外部 ID でアップサート)assets/cleanup/ — クリーンアップ・ロール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 platform-data-manage 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:
platform-data-manage 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:
See references/sf-cli-data-commands.md for the sf sobject describe command and jq filter patterns for inspecting fields, picklist values, and createable constraints.
| 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 |
| 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 |
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 |
|---|---|---|
| create missing custom objects | platform-custom-object-generate | schema must exist before data operations |
| create missing custom fields | platform-custom-field-generate | field-level schema must exist before data creation |
| run bulk-sensitive Apex validation | platform-apex-test-run | test execution and coverage |
| deploy missing schema first | platform-metadata-deploy | metadata readiness |
| implement production Apex logic consuming the data | platform-apex-generate | Apex class / trigger authoring |
| implement Flow logic consuming the data | automation-flow-generate | Flow authoring and automation |
assets/factories/ — Apex test data factory scripts (account, contact, opportunity, lead, user, etc.)assets/bulk/ — Bulk API 2.0 Apex templates (insert 200, 500, 10000 records; upsert by external ID)assets/cleanup/ — Cleanup and rollback scripts (delete by name, date, pattern; transaction rollback)assets/soql/ — SOQL query templates (aggregate, subquery, parent-to-child, child-to-parent, polymorphic)assets/csv/ — CSV import templates for Account, Contact, Opportunity, custom objectsassets/json/ — JSON tree import templates (account-contact, account-opportunity, full hierarchy)| 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 |
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。