databricks/databricks-agent-skills/databricks-execution-compute
Claude Code and agent skill by databricks/databricks-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Execute code and manage compute on Databricks: run Python/Scala/SQL/R via serverless, classic, or interactive clusters, and create/resize/delete clusters and SQL warehouses.
Install
npx vskill@latest install databricks/databricks-agent-skills/databricks-execution-computeSKILL.md
The same SKILL.md was published earlier as databricks/databricks-agent-skills/databricks-execution-compute.
Databricks Execution & Compute
Run code on Databricks. Four execution modes—choose based on workload. Most examples below use the Databricks CLI (Databricks Sandbox is SDK-driven); see the databricks-core skill for install and authentication.
Execution Mode Decision Matrix
| Aspect | Databricks Connect ⭐ | Serverless Job | Interactive Cluster | Databricks Sandbox | |
|---|---|---|---|---|---|
| Use for | Spark code (ETL, data gen) | Heavy processing (ML) | State across tool calls, Scala/R | Untrusted / agent-generated code, isolated env | |
| Startup | Instant | ~25-50s cold start | ~5min if stopped | ~1s (warm start) | |
| State | Within Python process | None | Via context_id | Home dir persisted across stop/restart | |
| Languages | Python (PySpark) | Python, SQL | Python, Scala, SQL, R | Any (general Linux shell) | |
| Dependencies | withDependencies() | CLI with environments spec | Install on cluster | Install in sandbox, or spec.environment.image_uri (UC container artifact) for a custom image |
Decision Flow
Main decision point: if you're using Declarative Automation Bundles (DABs) then follow the instructions of the `databricks-dabs` skill first. In short, you can use databricks bundle run to run code associated with jobs, pipelines, and other resources. This can be recognized by looking for a databricks.yml file in the project root. If these resources don't exist, or if you're not using DABs, then proceed with the below.
Prefer Databricks Connect for all spark-based workload, then serverless.
How to Run Code
Read the reference file for your chosen mode before proceeding.
Databricks Connect (run locally, prefer when it's pure spark code) → reference
Serverless Job → reference
Pure CLI flow: upload a local file as a workspace notebook, fire a one-time run with databricks jobs submit (create + run in one call, ephemeral — no Jobs UI entry, no retry), then poll + fetch the result. The local file must be a Databricks source notebook — top line # Databricks notebook source (Python) or -- Databricks notebook source (SQL).
1. Upload the local file as a workspace notebook. TARGET_PATH is positional; --file is the local path.
databricks workspace import /Workspace/Users/<user>/.ai_dev_kit/train --file /local/path/to/train.py --format SOURCE --language PYTHON --overwrite
2. Submit the run. Use --no-wait to get {"run_id": N} back immediately; drop it to block until terminated. `"client": "4"` is required for dependencies to install ("1" silently ignores them).
databricks jobs submit --no-wait --json @submit.json
3. Check state / wait for completion. Life-cycle: PENDING → RUNNING → TERMINATED (or SKIPPED / INTERNAL_ERROR). Only read .state.result_state (SUCCESS / FAILED / CANCELED) once life-cycle is TERMINATED.
databricks jobs get-run <RUN_ID> | jq '{state: .state.life_cycle_state, result: .state.result_state, duration_ms: .execution_duration, url: .run_page_url, task_run_id: .tasks[0].run_id}'
4. Fetch the output / error. Gotcha: get-run-output takes the task run_id (.tasks[0].run_id), NOT the parent run_id from submit. notebook_output.result is the string passed to dbutils.notebook.exit().
databricks jobs get-run-output <TASK_RUN_ID> | jq '{result: .notebook_output.result, error, error_trace}'
Always use dbutils.notebook.exit(<string>) in the notebook — print() is not captured by get-run-output. For JSON results: dbutils.notebook.exit(json.dumps({...})) then parse .notebook_output.result client-side.
Interactive Cluster → reference
Avoid by default — prefer Serverless Job. Only use an interactive cluster when:
- you have an existing classic cluster already running and available, or
- you need live, stateful execution across multiple calls (debugging via an execution context), or
- the user explicitly asks for it.
Interactive clusters are slow to start (3-8 min) and cost money while running. Don't start one implicitly.
Databricks Sandbox → skill
Isolated serverless environment for running untrusted or agent-generated code, driven through the Databricks SDK. Prefer it for agent tool-execution and ephemeral build/test environments rather than Spark workloads. See the `databricks-sandbox` skill for lifecycle, command execution, and file operations.
CLI Command Map
All compute lifecycle and code-execution actions go through the Databricks CLI. Headline commands:
| Action | Command | |
|---|---|---|
| Upload local file as workspace notebook | databricks workspace import <WORKSPACE_PATH> --file <LOCAL> --format SOURCE --language PYTHON --overwrite | |
| Run serverless code (upload + submit + wait) | databricks jobs submit --json @submit.json (see Serverless Job section above; with --no-wait for async) | |
| Get run state / wait | databricks jobs get-run <RUN_ID> (poll .state.life_cycle_state) | |
| Fetch run output | databricks jobs get-run-output <TASK_RUN_ID> | |
| List clusters | databricks clusters list --output json | |
| Get cluster details | databricks clusters get <CLUSTER_ID> | |
| Start / restart / terminate cluster | databricks clusters start/restart/delete <CLUSTER_ID> | |
| Permanently delete cluster | databricks clusters permanent-delete <CLUSTER_ID> | |
| Create cluster | databricks clusters create --json '{...}' (see 3-interactive-cluster.md) | |
| List node types / Spark versions | databricks clusters list-node-types / databricks clusters spark-versions | |
| Execute code on a running cluster | databricks api post /api/1.2/contexts/create + databricks api post /api/1.2/commands/execute (see 3-interactive-cluster.md) | |
| SQL warehouses | databricks warehouses create/list/get/start/stop/edit/delete (see SQL Warehouses below) |
SQL Warehouses
All ID-taking commands use positional arg (no --id flag). Use databricks warehouses list to find an ID.
Sizes: 2X-Small, X-Small, Small, Medium, Large, X-Large, 2X-Large, 3X-Large, 4X-Large. Types: set "warehouse_type": "PRO" (default) or "CLASSIC" in the JSON body.
Related Skills
- [databricks-synthetic-data-gen](../databricks-synthetic-data-gen/SKILL.md) — Data generation using Spark + Faker
- databricks-jobs — Production job orchestration
- [databricks-dbsql](../databricks-dbsql/SKILL.md) — SQL warehouse and AI functions
- [databricks-sandbox](../databricks-sandbox/SKILL.md) — Isolated serverless sandboxes for untrusted / agent-generated code
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/databricks-execution-compute/SKILL.md
Popularity
- Repository stars
- 373
- Repository forks
- 95
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/databricks/databricks-agent-skills/databricks-execution-compute)