Skip to content
Development
Skill

/data360-code-extension-generate

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.

From plugin
sf-skills
803161 skills6 agents10 commands3 MCP
Install
$ npx -y skills add forcedotcom/sf-skills --skill data360-code-extension-generate --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/data360-code-extension-generate

Context preview

The summary Claude sees to decide when to auto-load this skill.

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.

SKILL.md

data360-code-extension-generate.SKILL.md
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"
  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**

   sf plugins --core | grep data-code-extension

If not installed:

   sf plugins install @salesforce/plugin-data-code-extension

2. **Python 3.11**

   python --version  # Should show 3.11.x

3. **Data Cloud Custom Code SDK**

   pip list | grep salesforce-data-customcode

If not installed:

   pip install salesforce-data-customcode

4. **Docker running** (for deploy only)

   docker ps

5. **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 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:**

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:

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:**

   python3 scripts/get_dlo_schema.py <org_alias> <dlo_name>

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
Read more
Ships withsf-skills

This repository provides a curated collection of Salesforce agent skills for building applications.

Get the whole plugin

Other skills on sf-skills.