python-dev
Python development guidance with code quality standards, error handling, testing practices, and environment management. Use whenโฆ
Databricks development guidance including Python SDK, Databricks Connect, CLI, and REST API. Use when working with databricks-sdk, databricks-connect, or Databricks APIs.
Claude Code
$ npx -y skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk --agent claude-code
Codex
$ npx skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk -a codex -y
Cursor
$ npx skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk -a cursor -y
Gemini CLI
$ npx skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk -a gemini-cli -y
GitHub Copilot
$ npx skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk -a github-copilot -y
OpenCode
$ npx skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk -a opencode -y
Windsurf
$ npx skills add databricks-solutions/ai-dev-kit --skill databricks-python-sdk -a windsurf -y
name: databricks-python-sdk description: "Databricks development guidance including Python SDK, Databricks Connect, CLI, and REST API. Use when working with databricks-sdk, databricks-connect, or Databricks APIs."
This skill provides guidance for Databricks SDK, Databricks Connect, CLI, and REST API.
**SDK Documentation:** https://databricks-sdk-py.readthedocs.io/en/latest/ **GitHub Repository:** https://github.com/databricks/databricks-sdk-py
---
---
Use `databricks-connect` for running Spark code locally against a Databricks cluster.
from databricks.connect import DatabricksSession
# Auto-detects 'DEFAULT' profile from ~/.databrickscfg
spark = DatabricksSession.builder.getOrCreate()
# With explicit profile
spark = DatabricksSession.builder.profile("MY_PROFILE").getOrCreate()
# Use spark as normal
df = spark.sql("SELECT * FROM catalog.schema.table")
df.show()**IMPORTANT:** Do NOT set `.master("local[*]")` - this will cause issues with Databricks Connect.
---
For operations not yet in SDK or overly complex via SDK, use direct REST API:
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
# Direct API call using authenticated client
response = w.api_client.do(
method="GET",
path="/api/2.0/clusters/list"
)
# POST with body
response = w.api_client.do(
method="POST",
path="/api/2.0/jobs/run-now",
body={"job_id": 123}
)**When to use:** Prefer SDK methods when available. Use `api_client.do` for:
---
# Check version (should be >= 0.278.0) databricks --version # Use specific profile databricks --profile MY_PROFILE clusters list # Common commands databricks clusters list databricks jobs list databricks workspace ls /Users/me
---
The SDK documentation follows a predictable URL pattern:
Base: https://databricks-sdk-py.readthedocs.io/en/latest/
Workspace APIs: /workspace/{category}/{service}.html
Account APIs: /account/{category}/{service}.html
Authentication: /authentication.html
DBUtils: /dbutils.html| Category | Services | |----------|----------| | `compute` | clusters, cluster_policies, command_execution, instance_pools, libraries | | `catalog` | catalogs, schemas, tables, volumes, functions, storage_credentials, external_locations | | `jobs` | jobs | | `sql` | warehouses, statement_execution, queries, alerts, dashboards | | `serving` | serving_endpoints | | `vectorsearch` | vector_search_indexes, vector_search_endpoints | | `pipelines` | pipelines | | `workspace` | repos, secrets, workspace, git_credentials | | `files` | files, dbfs | | `ml` | experiments, model_registry |
---
**Doc:** https://databricks-sdk-py.readthedocs.io/en/latest/authentication.html
DATABRICKS_HOST=https://your-workspace.cloud.databricks.com DATABRICKS_TOKEN=dapi... # Personal Access Token
# Auto-detect credentials from environment
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
# Explicit token auth
w = WorkspaceClient(
host="https://your-workspace.cloud.databricks.com",
token="dapi..."
)
# Azure Service Principal
w = WorkspaceClient(
host="https://adb-xxx.azuredatabricks.net",
azure_workspace_resource_id="/subscriptions/.../resourceGroups/.../providers/Microsoft.Databricks/workspaces/...",
azure_tenant_id="tenant-id",
azure_client_id="client-id",
azure_client_secret="secret"
)
# Use a named profile from ~/.databrickscfg
w = WorkspaceClient(profile="MY_PROFILE")---
**Doc:** https://databricks-sdk-py.readthedocs.io/en/latest/workspace/compute/clusters.html
# List all clusters
for cluster in w.clusters.list():
print(f"{cluster.cluster_name}: {cluster.state}")
# Get cluster details
cluster = w.clusters.get(cluster_id="0123-456789-abcdef")
# Create a cluster (returns Wait object)
wait = w.clusters.create(
cluster_name="my-cluster",
spark_version=w.clusters.select_spark_version(latest=True),
node_type_id=w.clusters.select_node_type(local_disk=True),
num_workers=2
)
cluster = wait.result() # Wait for cluster to be running
# Or use create_and_wait for blocking call
cluster = w.clusters.create_and_wait(
cluster_name="my-cluster",
spark_version="14.3.x-scala2.12",
node_type_id="i3.xlarge",
num_workers=2,
timeout=timedelta(minutes=30)
)
# Start/stop/delete
w.clusters.start(cluster_id="...").result()
w.clusters.stop(cluster_id="...")
w.clusters.delete(cluster_id="...")**Doc:** https://databricks-sdk-py.readthedocs.io/en/latest/workspace/jobs/jobs.html
from databricks.sdk.service.jobs import Task, NotebookTask
# List jobs
for job in w.jobs.list():
print(f"{job.job_id}: {job.settings.name}")
# Create a job
created = w.jobs.create(
name="my-job",
tasks=[
Task(
task_key="main",
notebook_task=NotebookTask(notebook_path="/Users/me/notebook"),
existing_cluster_id="0123-456789-abcdef"
)
]
)
# Run a job now
run = w.jobs.run_now_and_wait(job_id=created.job_id)
print(f"Run completed: {run.state.result_state}")
# Get run output
output = w.jobs.get_run_output(run_id=๐ฃ A big step forward: AI Dev Kit skills are now official Databricks AI Tools The skills from this AI Dev Kit repository are now delivered as part of Databricks AI Tools, a Databricks engineering-owned repository, built and maintained in close collaboration
Python development guidance with code quality standards, error handling, testing practices, and environment management. Use whenโฆ
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, orโฆ
Ask which skill or flow fits your situation. A router over the skills in this repo.