
Data Cloud Code Extensions
OfficialFreeEfficiently develop and deploy Python transformations for Salesforce Data Cloud.
Free · Opens the source repo
What Data Cloud Code Extensions does
The Data Cloud Code Extensions skill streamlines the process of developing, testing, and deploying custom Python transformations for Salesforce Data Cloud. This skill is particularly useful for developers who need to create code extensions that interact with Data Lake Objects (DLOs) and Data Model Objects (DMOs). By leveraging the Salesforce CLI plugin, users can initiate projects, run tests, and deploy their code extensions with ease, ensuring a smooth workflow from development to deployment.
To get started, users must have the required prerequisites, including the Salesforce CLI with the data-code-extension plugin, Python 3.11, and the Data Cloud Custom Code SDK. The skill provides clear commands for initializing a new project, where users can choose between script-based or function-based code extensions. This flexibility allows developers to tailor their approach based on the specific needs of their transformations, whether they are batch processes or real-time functions.
Once the project is set up, users can write their transformation logic in Python, utilizing built-in methods to read from and write to DLOs and DMOs. The skill also includes functionality to scan code for required permissions and validate DLO schemas, ensuring that all necessary configurations are in place before running tests. This thorough approach minimizes errors and enhances the reliability of the code being deployed.
Overall, this skill is designed for developers working with Salesforce Data Cloud who require a robust framework for creating and managing custom data transformations. Its comprehensive workflow, combined with clear command structures and validation steps, makes it an essential tool for efficient development in this environment.
When to use it
Use this skill when you need to create, test, or deploy custom Python code extensions for Salesforce Data Cloud, especially when working with DLOs and DMOs.
When not to use it
This skill is not suitable for users who do not require interaction with Salesforce Data Cloud or those who are not developing Python transformations.
What you can build with it
Creating a New Code Extension
Initialize a new code extension project to start developing custom Python transformations for your data.
Testing Transformations Locally
Run your code extension locally to ensure it works as expected before deploying it to Salesforce Data Cloud.
Validating Data Permissions
Scan your code to automatically detect required permissions for DLOs and DMOs, ensuring compliance before deployment.
How to install Data Cloud Code Extensions
View source1. Install with the skills CLI
npx skills add forcedotcom/sf-skills/data360-code-extension-generate --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by forcedotcomdata360-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:
-
SF CLI with plugin installed
sf plugins --core | grep data-code-extensionIf not installed:
sf plugins install @salesforce/plugin-data-code-extension -
Python 3.11
python --version # Should show 3.11.x -
Data Cloud Custom Code SDK
pip list | grep salesforce-data-customcodeIf not installed:
pip install salesforce-data-customcode -
Docker running (for deploy only)
docker ps -
Authenticated org
sf org display --target-org <org_alias> --json
Skill Workflow
Phase 1: Initialize Project
Create a new code extension project with scaffolding.
Commands:
For script-based code extensions (batch transformations):
sf data-code-extension script init --package-dir <directory>
For function-based code extensions (real-time):
sf data-code-extension function init --package-dir <directory>
Required Option:
--package-dir, -p- Directory path where the package will be created
What it creates:
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 | <project-name> 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):
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):
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 DLOclient.read_dmo('DMO_Name')- Read from DMOclient.write_to_dlo('DLO_Name__dll', df, 'overwrite')- Write to DLOclient.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:
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.jsonandrequirements.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:
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:
-
Verify DLO exists:
python3 scripts/get_dlo_schema.py <org_alias> <dlo_name> -
Verify field names match — compare fields used in your
entrypoint.pyagainst the DLO schema. -
Check all DLOs:
- Validate all DLOs in
readpermissions - Validate all DLOs in
writepermissions - Check field names match exactly (case-sensitive)
- Verify data types are compatible with operations
- Validate all DLOs in
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:
sf data-code-extension script run --entrypoint <entrypoint_file> --target-org <org_alias> [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:
sf data-code-extension script deploy --target-org <org_alias> --name <name> --package-dir ./payload --package-version <version> --description <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./payloadwhen 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 <org_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
- Always scan before testing — run scan after code changes
- Test locally first — use
runcommand before deploying - Use version control — git commit after each successful test
- Version your deployments — use semantic versioning (1.0.0, 1.1.0, etc.)
- 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
- No hardcoded credentials — use SF CLI authentication only
- Validate input data — check for nulls and data types
- 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:
- Create DLO via code extension
- Map DLO to DMO using datakit workflow
- 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
Frequently asked questions about Data Cloud Code Extensions
Similar skills
Rhino 3D Scripting
Streamline your Rhinoceros 3D scripting tasks.
MVVM Toolkit
Streamline ViewModel development with source generators.
FreeCAD Scripts
Generate Python scripts for FreeCAD automation and modeling.
Azure Architecture Builder
Design and deploy Azure infrastructure using natural language.
Command Development
Streamline your command creation for Claude Code.
Create Cowork Plugin
Easily build and package plugins through guided sessions.
