sf-bulk-operations
Salesforce Bulk API 2.0 write operations using the sf CLI. Use when performing bulk data imports, updates, upserts, or deletes via sf data import bulk, sf data update bulk, sf data upsert bulk, sf data delete bulk, or sf data resume. Covers CSV preparation, line endings, job monitoring, error handling, and result retrieval.
What this skill does
# Salesforce Bulk Write Operations
Bulk API 2.0 write operations for inserting, updating, upserting, and deleting records via the `sf` CLI.
## Critical: Choose the Right Command
The Bulk API 2.0 does **NOT** auto-detect the operation from your CSV. Each operation has a separate command:
| Command | Operation | Required CSV Column | Use When |
|---------|-----------|-------------------|----------|
| `sf data import bulk` | INSERT | (none — creates new records) | Loading new records |
| `sf data update bulk` | UPDATE | `Id` | Modifying existing records by Salesforce ID |
| `sf data upsert bulk` | UPSERT | External ID field | Insert-or-update by external key |
| `sf data delete bulk` | DELETE | `Id` | Removing records by Salesforce ID |
Common mistake: using `import` (INSERT) when you need `update` (UPDATE). If all
records fail with `INVALID_CROSS_REFERENCE_KEY` or duplicate errors, you likely
used the wrong command.
## CSV Preparation
### Line Endings (macOS Gotcha)
The `--line-ending` flag must match your CSV's actual line endings. On macOS, the default is `LF`.
**Python's `csv` module writes CRLF (`\r\n`) by default.** To produce LF:
```python
with open("upload.csv", "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=["Id", "My_Field__c"], lineterminator="\n")
writer.writeheader()
for row in data:
writer.writerow(row)
```
Then pass `--line-ending LF` explicitly:
```bash
sf data update bulk --file upload.csv --sobject Account --target-org myorg --line-ending LF --wait 10
```
If line endings don't match, you'll get: `ClientInputError: LineEnding is invalid on user data`.
### Header Row
- Use **API field names** (e.g., `Stripe_ATR__c`), not field labels (e.g., "Stripe ATR")
- For update/delete: include an `Id` column with 18-character Salesforce record IDs
- For upsert: include the external ID field specified by `--external-id`
### Column Delimiter
Default is comma. Use `--column-delimiter` for alternatives: `BACKQUOTE`, `CARET`, `COMMA`, `PIPE`, `SEMICOLON`, `TAB`.
## Running Bulk Jobs
### Always Use `--json` Output
The progress spinner produces thousands of ANSI escape characters that overflow terminal buffers. Always capture structured output:
```bash
sf data update bulk \
--file upload.csv \
--sobject Account \
--target-org production \
--line-ending LF \
--wait 10 \
--json 2>&1 | tail -50
```
### Common Flags
| Flag | Description |
|------|-------------|
| `--file` | Path to CSV file (required) |
| `--sobject` | API name of target object (required) |
| `--target-org` | Org alias or username (required) |
| `--line-ending` | `LF` or `CRLF` (default: LF on macOS, CRLF on Windows) |
| `--wait` | Minutes to wait for completion |
| `--external-id` | External ID field name (upsert only) |
| `--column-delimiter` | CSV delimiter |
### Async Jobs
If `--wait` is omitted or the job exceeds the wait time, the CLI returns a job ID. Resume monitoring with:
```bash
sf data import resume --job-id <JOB_ID> --target-org myorg --wait 10 --json
sf data update resume --job-id <JOB_ID> --target-org myorg --wait 10 --json
```
## JSON Response Shapes (Critical for Programmatic Use)
`sf data update bulk --json` returns **two completely different JSON shapes** depending on whether all records succeeded or some failed. Code that parses bulk operation results must handle both.
### Full Success (status: 0)
All records processed without error:
```json
{
"status": 0,
"result": {
"id": "750TN00000iZJOGYA4",
"processedRecords": 17956,
"failedRecords": 0,
"status": "JobComplete",
"operation": "update",
"object": "Account"
}
}
```
Record counts and job state are directly in `result`.
### Partial Failure (status: 1, FailedRecordDetailsError)
Some records failed — the CLI wraps the response in an **error envelope** with a different shape:
```json
{
"name": "FailedRecordDetailsError",
"message": "Job finished being processed but failed to process 200 records.",
"exitCode": 1,
"status": 1,
"data": {
"jobId": "750TN00000iZk9tYAC",
"state": "JobComplete"
},
"actions": [
"Get the job results by running: \"sf data bulk results -o myorg --job-id 750TN...\"."
],
"context": "DataUpdateBulk",
"commandName": "DataUpdateBulk"
}
```
**The error envelope does NOT contain record counts.** Only `data.jobId` and `data.state`. To get `processedRecords`/`failedRecords`, you must follow up with `sf data bulk results`.
### Parsing Strategy for Scripts
```python
payload = json.loads(stdout)
if payload.get("status") == 0:
# Success — counts in result
result = payload["result"]
processed = result["processedRecords"]
failed = result["failedRecords"]
else:
# Error envelope — check if job completed with failures
err_data = payload.get("data", {})
job_id = err_data.get("jobId")
job_state = err_data.get("state")
if job_state == "JobComplete" and job_id:
# Job completed but had failures — fetch counts separately
# Run: sf data bulk results --job-id <job_id> --target-org <org> --json
pass
else:
# Real failure — job didn't complete
raise RuntimeError(payload.get("message", "Unknown error"))
```
## Inspecting Results
After a job completes (or partially fails), fetch detailed results:
```bash
sf data bulk results --job-id <JOB_ID> --target-org myorg --json
```
Returns:
```json
{
"result": {
"processedRecords": 19852,
"successfulRecords": 19277,
"failedRecords": 575,
"status": "JobComplete",
"operation": "update",
"object": "Account",
"successFilePath": "<JOB_ID>-success-records.csv",
"failedFilePath": "<JOB_ID>-failed-records.csv"
}
}
```
**Side effect:** This command writes `<JOB_ID>-success-records.csv` and `<JOB_ID>-failed-records.csv` to the **current working directory**. These can be large (3+ MB for 18K rows).
The failed records CSV includes the error reason per row:
```
"sf__Id","sf__Error",Id,My_Field__c
"","UNABLE_TO_LOCK_ROW:unable to obtain exclusive access to this record or 200 records: 001xxx,001yyy,...:--","001xxx","value"
"","INVALID_CROSS_REFERENCE_KEY:invalid cross reference id:--","001zzz","value"
```
### Clean Up Result Files
```bash
rm -f <JOB_ID>-success-records.csv <JOB_ID>-failed-records.csv
```
## Sandbox Considerations
When running bulk operations against a sandbox:
- **`INVALID_CROSS_REFERENCE_KEY`** errors are expected for record IDs that exist in production but not in the sandbox (accounts created after the last sandbox refresh, or deleted in sandbox). This is normal — compare success count to total to assess coverage.
- Sandbox refresh resets data but not metadata. Custom fields created in production should exist in sandbox after refresh.
- Test with a small subset first (`head -100 upload.csv > test.csv`) before running the full batch.
## Examples
### Update a Custom Field on Accounts
```bash
# Prepare CSV with LF line endings (Python)
python -c "
import csv
with open('update.csv', 'w', newline='') as f:
w = csv.DictWriter(f, ['Id','My_Field__c'], lineterminator='\n')
w.writeheader()
w.writerow({'Id': '001xxx', 'My_Field__c': '42.50'})
"
# Upload
sf data update bulk \
--file update.csv \
--sobject Account \
--target-org production \
--line-ending LF \
--wait 10 \
--json 2>&1 | tail -50
```
### Upsert by External ID
```bash
sf data upsert bulk \
--file contacts.csv \
--sobject Contact \
--external-id External_Id__c \
--target-org production \
--line-ending LF \
--wait 10 \
--json 2>&1 | tail -50
```
### Delete Records
```bash
# CSV needs only the Id column
echo "Id" > delete.csv
echo "001xxx" >> delete.csv
sf data delete bulk \
--file delete.csv \
--sobject Account \
--target-org sandbox \
--line-ending LF \
--wait 10 \
--json 2>&1 | tail -50
```
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.