跳到主内容
智客 ZICQ

技能库 智客分类:运维与云 data360-code-extension-generate

Data360 Code Extension Generate

使用 SF CLI 插件开发并部署数据云代码扩展. 在为 Data Cloud 创建自定义 Python 转换,部署代码扩展或测试数据转换时使用此技能. 支持进入、运行、扫描和部署行动.

4990 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

使用 SF CLI 插件开发并部署数据云代码扩展. 在为 Data Cloud 创建自定义 Python 转换,部署代码扩展或测试数据转换时使用此技能. 支持进入、运行、扫描和部署行动.

何时用

- 用户想要创建一个新的代码扩展项目

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:data360-code-extension-generate Skill、Overview、When to Use、Prerequisites Check、Skill Workflow、Phase 1: Initialize Project。 其中含规范建议的小节:分步指令。

文件分析

文件分析:除 SKILL.md 外,正文引用了 scripts/get_dlo_schema.py,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Develop and deploy Data Cloud Code Extensions using SF CLI plugin. Use this skill when creating custom Python transformations for Data Cloud, deploying code extensions, or testing data transformations. Supports init, run, scan, and deploy operations.

data360-code-extension-generate SkillOverviewWhen to UsePrerequisites CheckSkill WorkflowPhase 1: Initialize ProjectDirectory Context During WorkflowPhase 2: Develop TransformationRead from DLOTransform data (uppercase position field)Write to output DLOPhase 3: Scan for Permissions

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
data360-code-extension-generate
description
Develop and deploy Data Cloud Code Extensions using SF CLI plugin. Use this skill when creating custom Python transformations for Data Cloud, deploying code extensions, or testing data transformations. Supports init, run, scan, and deploy operations.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 1
  • scripts/get_dlo_schema.py

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「data360-code-extension-generate」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-07e8a9e1a0c4f766-%E6%95%B0%E6%8D%AE360-%E4%BB%A3%E7%A0%81%E6%89%A9%E5%B1%95%E7%94%9F%E6%88%90.html
请存为 .cursor/skills/data360-code-extension-generate/SKILL.md 或 .claude/skills/data360-code-extension-generate/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/forcedotcom/sf-skills 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/forcedotcom/sf-skills' --list

npx skills add 'https://github.com/forcedotcom/sf-skills' --skill 'data360-code-extension-generate'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: data360-code-extension-generate description: "Develop and deploy Data Cloud Code Extensions using SF CLI plugin. Use this skill when creating custom Python transformations for Data Cloud, deploying code extensions, or testing data transformations. Supports init, run, scan, and deploy operations." metadata: version: "1.0" domains: ["Data 360", "Developer Experience"] relatedSkills: - "data360-schema-get" cliTools: - tool: ["docker"] semver: ">=20.0.0" - tool: ["pip"] semver: ">=23.0.0" - tool: ["python"] semver: ">=3.11.0" - tool: ["python3"] semver: ">=3.11.0" - tool: ["sf"] semver: ">=2.0.0" --- # data360-code-extension-generate Skill ## Overview This skill provides a complete workflow for developing, testing, and deploying custom Python code extensions to Salesforce Data Cloud. Code extensions allow you to write Python transformations that read from and write to Data Lake Objects (DLOs) and Data Model Objects (DMOs). ## When to Use - User wants to create a new code extension project - User needs to test a code extension locally - User wants to scan code for required permissions - User needs to deploy a code extension to Data Cloud - User is working with Data Cloud transformations - User wants to read/write DLO or DMO data programmatically ## Prerequisites Check Before executing any code extension commands, verify prerequisites: 1. **SF CLI with plugin installed** ```bash sf plugins --core | grep data-code-extension ``` If not installed: ```bash sf plugins install @salesforce/plugin-data-code-extension ``` 2. **Python 3.11** ```bash python --version # Should show 3.11.x ``` 3. **Data Cloud Custom Code SDK** ```bash pip list | grep salesforce-data-customcode ``` If not installed: ```bash pip install salesforce-data-customcode ``` 4. **Docker running** (for deploy only) ```bash docker ps ``` 5. **Authenticated org** ```bash sf org display --target-org --json ``` ## Skill Workflow ### Phase 1: Initialize Project Create a new code extension project with scaffolding. **Commands:** For **script-based** code extensions (batch transformations): ```bash sf data-code-extension script init --package-dir ``` For **function-based** code extensions (real-time): ```bash sf data-code-extension function init --package-dir ``` **Required Option:** - `--package-dir, -p` - Directory path where the package will be created **What it creates:** ```text my-transform/ # Project root ├── payload/ # CRITICAL: This is what --package-dir must point to for deploy │ ├── entrypoint.py # Main transformation code │ └── config.json # Code extension configuration ├── requirements.txt # Python dependencies └── README.md ``` ## Directory Context During Workflow **IMPORTANT:** Understanding the directory structure is critical for successful deployment. **Commands and their directory requirements:** | Command | Run From | Path/File Argument | |---------|----------|-------------------| | `init` | Parent directory | `` or `.` | | `scan` | Project root | `./payload/entrypoint.py` | | `run` | Project root | `./payload/entrypoint.py` | | `deploy` | Project root | `--package-dir ./payload` (**REQUIRED**) | **CRITICAL: The `--package-dir` argument in deploy command MUST point to the `payload` directory, not the project root.** ### Phase 2: Develop Transformation Edit `payload/entrypoint.py` with transformation logic. **Script Example (Batch):** ```python from datacustomcode import Client client = Client() # Read from DLO df = client.read_dlo('Employee__dll') # Transform data (uppercase position field) df['position_upper'] = df['position'].str.upper() # Write to output DLO client.write_to_dlo('Employee_Upper__dll', df, 'overwrite') ``` **Function Example (Real-time):** ```python from datacustomcode import FunctionClient def transform(event, context): client = FunctionClient(context) input_data = event['data'] output = { 'name': input_data['name'].upper(), 'status': 'processed' } return output ``` **Common Operations:** - `client.read_dlo('DLO_Name__dll')` - Read from DLO - `client.read_dmo('DMO_Name')` - Read from DMO - `client.write_to_dlo('DLO_Name__dll', df, 'overwrite')` - Write to DLO - `client.write_to_dmo('DMO_Name', df, 'upsert')` - Write to DMO ### Phase 3: Scan for Permissions Scan the entrypoint file to detect required permissions and generate config.json. **Command:** ```bash sf data-code-extension script scan --entrypoint ./payload/entrypoint.py ``` **What it detects:** - Read permissions for DLOs/DMOs - Write permissions for DLOs/DMOs - Python package dependencies - Updates `config.json` and `requirements.txt` ### Phase 4: Validate DLO Schema (Pre-Test Check) **CRITICAL: Before running tests locally, validate that all DLOs used in your code exist and have the expected fields.** #### Step 4a: Extract DLOs from config.json After scanning, review the generated `config.json` to identify all DLOs: ```bash cat payload/config.json ``` #### Step 4b: Validate Each DLO Schema **Use the `data360-schema-get` skill to verify DLOs exist and check field names.** For each DLO referenced in your code: 1. **Verify DLO exists:** ```bash python3 scripts/get_dlo_schema.py ``` 2. **Verify field names match** — compare fields used in your `entrypoint.py` against the DLO schema. 3. **Check all DLOs:** - Validate all DLOs in `read` permissions - Validate all DLOs in `write` permissions - Check field names match exactly (case-sensitive) - Verify data types are compatible with operations #### Step 4c: Validation Checklist Before proceeding to run, ensure: - [ ] All DLOs in config.json exist in target org - [ ] All field names used in code exist in DLO schemas - [ ] Field data types match your transformation logic - [ ] Primary key fields are correctly identified - [ ] Write target DLOs are created and accessible ### Phase 5: Test Locally After validating DLO schemas, run the code extension locally against your Data Cloud org. **Command:** ```bash sf data-code-extension script run --entrypoint --target-org [options] ``` **Options:** - `--target-org, -o` - SF CLI org alias (required) - `--config-file, -c` - Custom config file path **If you get errors:** - Re-validate DLO schemas - Check field names are exact matches - Verify data types are compatible - Review error messages for field/DLO issues ### Phase 6: Deploy to Data Cloud Deploy the code extension to Data Cloud for scheduled or on-demand execution. **CRITICAL: You MUST specify `--package-dir ./payload` to point to the payload directory created by init.** **Command:** ```bash sf data-code-extension script deploy --target-org --name --package-dir ./payload --package-version --description [options] ``` **Required Options:** - `--target-org, -o` - SF CLI org alias - `--name, -n` - Name for code extension deployment - `--package-dir` - Path to payload directory (**REQUIRED** - must be `./payload` when running from project root) - `--package-version` - Version string (default: 0.0.1) - `--description` - Description of code extension **Optional Options:** - `--cpu-size` - CPU size: CPU_L, CPU_XL, CPU_2XL (default), CPU_4XL - `--function-invoke-opt` - Function invoke options (for function type) - `--network` - Docker network (default: default) **After deployment:** - Navigate to Data Cloud in Salesforce UI - Go to Data Transforms section - Find your deployment by name - Click "Run Now" to execute - Schedule for recurring execution ## Error Handling ### Common Issues and Solutions | Error | Solution | |-------|----------| | `command data-code-extension not found` | `sf plugins install @salesforce/plugin-data-code-extension` | | `datacustomcode CLI not found` | `pip install salesforce-data-customcode` | | `Python version mismatch` | Use pyenv: `pyenv install 3.11.0 && pyenv local 3.11.0` | | `Cannot connect to Docker daemon` | Start Docker Desktop | | `No org found for alias` | `sf org login web --alias ` | | `config.json not found` | `sf data-code-extension script scan --entrypoint ./payload/entrypoint.py` | | `DLO not found` | Verify DLO exists (use data360-schema-get skill), check spelling and `__dll` suffix | | `Permission denied writing` | Re-run scan, verify target DLO exists and is writable | | `Deploy fails - wrong directory` | Ensure `--package-dir` points to `payload/` directory, not project root | ## Best Practices ### Development 1. Always scan before testing — run scan after code changes 2. Test locally first — use `run` command before deploying 3. Use version control — git commit after each successful test 4. Version your deployments — use semantic versioning (1.0.0, 1.1.0, etc.) 5. Deploy from project root with `--package-dir ./payload` ### Performance - **CPU_L**: Small datasets (< 1M records) - **CPU_2XL**: Medium datasets (1M-10M records) - **CPU_4XL**: Large datasets (> 10M records) ### Security 1. No hardcoded credentials — use SF CLI authentication only 2. Validate input data — check for nulls and data types 3. Limit write permissions — only grant necessary DLO/DMO access ## Integration with Other Skills **Use with data360-schema-get skill (CRITICAL for validation):** The `data360-schema-get` skill is **required** for validating DLOs before testing code extensions. **Use with Datakit Workflow:** 1. Create DLO via code extension 2. Map DLO to DMO using datakit workflow 3. Use DMO in segments and activations ## Command Reference | Command | Purpose | Required Args | |---------|---------|---------------| | `script init` | Create new script project | --package-dir | | `function init` | Create new function project | --package-dir | | `script scan` | Generate config | entrypoint file | | `script run` | Test locally | entrypoint file, --target-org | | `script deploy` | Deploy to Data Cloud | --target-org, --name, --package-dir, --package-version, --description | ## Resources - SF CLI Plugin: https://github.com/salesforcecli/plugin-data-code-extension - Python SDK: https://github.com/forcedotcom/datacloud-customcode-python-sdk - Data Cloud Docs: https://help.salesforce.com/s/articleView?id=sf.c360_a_intro.htm - Python SDK PyPI: https://pypi.org/project/salesforce-data-customcode/ ## Notes - Code extensions run in isolated Python 3.11 environment - Docker is required only for deployment, not for local testing - Use SF CLI authentication only (no separate credential files) - Scan command auto-detects permissions from code - Local run uses actual Data Cloud data (not mocked) - Deployments are versioned and can be rolled back in UI

相关技能

运维与云

Docker Essentials

用于容器管理,图像操作,调试的基本道克命令和工作流程.

运维与云

Find Skills

从开放的代理技能生态系统中发现并安装技能. 使用时:(1)用户问"我如何做X",X可能拥有现有技能,(2)用户说"为X找到技能"或"是否为X有技能",(3)用户问"你能否做X",X是专门能力,(4)用户想扩展代理能力,(5)用户想搜索工具,模板,或工作流程,(6)用户提到他们希望…

运维与云

Microsoft Foundry

构建,部署,评价,优化,微调,管理微软创始代理,模型,资源最终结束. 用法:铸造、azd ai代理、azd 提供/部署、托管代理脚手架/开发/运行/部署/拖放、即时代理创建、创建代理、更新代理、添加代理工具、援引代理、代理.yaml、评估代理、批量活化、连续活化、持续监测、代理C…

运维与云

Azure Deploy

执行已有.azure/部署计划.md和基础设施文件的ALREADY-PREPARED应用程序的Azure部署。 当用户向 CREATE 请求新应用程序时, 请不要使用此技能 。 这种技能运行了 azd上行, azd 部署, trarraform 应用, 和 az 部署命令带有内置…