/dak:gcp-managed-spark-upgradesfrom dak
Upgrades Spark workloads on Google Cloud Managed Service for Apache Spark (Dataproc) clusters and Serverless to a newer image or runtime version. Supports static compatibility analysis, code upgrade, build checks, and optional verification runs.
Ships in dak. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
pysparkJob, Serverless batch field
pysparkBatch. Status: Supported. Analysis reference:
pyspark_analysis.md.sparkJob, Serverless batch field
sparkBatch. Status: Supported. Analysis references:
scala_analysis.md for Scala sources and
java_analysis.md for Java sources (both for a
project with both), plus
jvm_build_reference.md, which every
Scala/Java job uses for its jars, Java runtime, dependencies, packaging, and
build checks.sparkSqlJob, Serverless batch field
sparkSqlBatch. Status: Not yet supported.sparkRJob, Serverless batch field
sparkRBatch. Status: Not yet supported.pysparkNotebookBatch. Status: Not yet supported.If the workload's job type isn't Supported, stop: tell the user which job
types are currently supported, and don't change code, create clusters, or submit
jobs. Non-Spark jobs (e.g. hiveJob, pigJob) are out of scope.
Everything else in this skill applies to every supported job type. Checks that depend on the job type live in its analysis references and in the parts of the other references labeled with the job type (e.g. "For PySpark", "For Scala/Java").
gcloud dataproc …) and many docs URLs still say
dataproc.<major>.<minor>.<sub-minor>-<distro> (e.g.
2.2.50-debian12).<major>.<minor> only (e.g. 2.2): every batch runs the newest
sub-minor of its runtime, which can't be pinned.<major>.<minor> part of a version. The same track can run a
different Spark version on clusters and on Serverless.<skill_dir>: The directory that contains this SKILL.md. Script paths
below are relative to it.<app_id>: The sanitized job name used in temporary paths: the job's
main code file name without its extension (the main .py file for PySpark;
for Scala/Java, the main JAR name, or the main class's simple name),
lowercased, with every character other than a-z, 0-9, _, and -
replaced by _ (e.g. daily_orders for daily_orders.py,
order-metrics-app for order-metrics-app.jar).<target_path>: The Target GCS path, gs://<TARGET_BUCKET>/<prefix>.
It receives the final code and report; temporary verification artifacts are
staged under it.Zero defaults. Take every input from the user or from the source
job/batch (its describe output or audit logs). Never take values from
local gcloud configuration (e.g. gcloud config get-value project),
environment variables, or project defaults such as the default network:
Managed Spark silently fills in omitted values (default runtime, default
subnet), so a guessed value produces a run that looks valid but tests the
wrong environment. A value the user supplied or the source job/batch
actually used is not a default, even if it is named default. Record where
each value came from in the report.
Compatibility changes only. Change only what the target version
requires: removed or deprecated APIs, dependency versions, Spark properties,
and edits that keep the source behavior on the target (for example, stating
explicitly a default that the target changed, or casting an argument to the
type that the target now enforces). Don't change business logic, filters,
joins, schemas, or production input/output paths. Prefer code changes over
the flags that restore the previous behavior (e.g. spark.sql.legacy.*),
because later Spark releases can remove those flags; use a flag only when
the code can't keep the old behavior or can't be edited, and list every flag
in the report.
Edit a local working copy. Never overwrite the source objects in GCS, and don't push to a Git remote unless the user asks. Step 1.3 describes how to get the working copy. If a write to the Target GCS path would replace one of the job's source objects or go into a production input or output location, ask for another Target GCS path first.
Isolate verification output. A verification run must never write to
production destinations. Send every output to
<target_path>/test-output_<app_id>_temp/: pass that path through job
arguments or Spark properties when the job accepts them; otherwise submit a
temporary copy of the job's code whose output paths are redirected, named
<name>_<app_id>_temp (for PySpark, <script>_<app_id>_temp.py; for
Scala/Java, <jar_name>_<app_id>_temp.jar compiled from a temporary copy
whose output paths are redirected). For an output that isn't a storage path
(e.g. a BigQuery or Hive table), ask the user for a test destination. Never
put temporary paths into the working copy, so the final code keeps its
production paths.
Approvals. There are two checkpoints: applying code changes (before Step 1.6) and running a verification job/batch, which costs money (Step 2.1). A checkpoint is approved when either:
Otherwise, ask the user whether they want to automatically approve all remaining steps or confirm at each checkpoint, and wait for the answer. Unless automatic approval is active, Checkpoint 2 also needs the user to confirm or change the verification configuration you present in Step 2.1, even if they asked for the verification. When automatic approval is active, apply the code changes, then, once all Step 2 inputs are supplied and valid, present the verification configuration and run Step 2, retries included, without waiting for a reply. Automatic approval never relaxes the input gates or rule 4, and an analysis-only request never turns into code changes or a verification run.
Temporary names. Name every temporary file or directory you create,
locally or in GCS, <name>_<app_id>_temp (files inside such a directory
need no extra suffix), so that concurrent upgrades don't collide. Temporary
GCP resources use upg-verify-<unique-id> instead, because cluster names
and batch IDs allow only lowercase letters, digits, and hyphens.
One token per flag. Write each long option that takes a value as a
single --flag=value token (e.g. --version=2.2): some command wrappers,
including test harnesses, treat a standalone --version token as a request
for the tool's own version.
gs://<bucket>/<prefix>. Serverless: Same.
Needed before: Step 1. If not provided: Ask.<major>.<minor>[.<sub-minor>][-<distro>];
Step 1.4 resolves a missing sub-minor or validates a given one. Serverless:
<major>.<minor> only. Needed before: Step 1. If not provided: Ask.gs://… path, or Git URL
(optionally with a branch, tag, commit, or subdirectory). Serverless: Same.
Needed before: Step 1. If not provided: Take it from the Job/Batch ID;
otherwise ask.<major>.<minor>.<sub-minor>-<distro>.
Serverless: <major>.<minor>. Needed before: Step 1. If not provided: Take
it from the Job/Batch ID; otherwise ask.NO for a standard image.
Serverless: —. Needed before: Step 2. If not provided: Ask. If the source
cluster used a custom image, Step 2 needs one built for the target version,
or NO for a standard image (see "Discover the source" in
cluster_input_validations.md).NO is acceptable if using the standard runtime environment).[!IMPORTANT]
All GCP operations require active authentication. If you encounter authentication errors, ask the user to run
gcloud auth loginandgcloud auth application-default login. If an account is active but a call returns403, diagnose missing IAM roles instead.
The scripts in <skill_dir>/scripts/ (resolve_version.py and
fetch_migration_notes.py) use only the Python standard library. Run them with
uv run; if uv isn't installed, use python3 instead. Don't read their
source: the commands in this skill show how to call them, and --help lists
their options.
Classify and discover. Determine the deployment (cluster or Serverless) and the job type.
.py means PySpark; .scala, .java, or .jar means Scala/Java);
note that a Job/Batch ID is never required for static code analysis and
upgrade.Input gate. Check which inputs are supplied (or discovered in Step 1.1):
Project ID, Region, Target GCS path,
Temporary GCS staging location) are missing or if the user asked not
to run gcloud commands. Instead, perform the full local static
compatibility analysis and local build checks first, and in your
response also:
Target Project ID, Target Region,
Temporary GCS staging location, Target GCS bucket
(Target GCS path), Subnet, and Custom image URI (for clusters,
noting NO is acceptable if using a standard image) or
Custom container image (for Serverless when no Batch ID is given,
noting NO is acceptable).<major>.<minor>
(e.g. 1.5) without a Job ID, explain that the full
<major>.<minor>.<sub-minor>-<distro> version (or confirmation of a
specific sub-minor and OS distro) is needed for exact component
delta analysis, while completing the track-level compatibility
analysis meanwhile.Project ID, Region, Target GCS path,
Target version, Source code location, and Source version must be
supplied and pass the access checks in the deployment's input-validation
reference (skip gcloud access checks whenever the user instructs not
to run gcloud commands). If any mandatory input needed to obtain the
source code or versions is missing or inaccessible, stop and ask for the
missing inputs above.Get a local working copy (rule 3).
Local path: confirm it exists. If it is inside a Git repository and not in an evaluation/staging workspace, create a working branch before editing. When remediating a local file (Step 1.6), apply the compatibility changes directly to that local file (keeping its original production input/output paths intact); never leave the user-specified local file un-remediated by only editing a separate copy.
GCS path: download the main code file and every code dependency or
auxiliary file the job references (for PySpark: pythonFileUris,
fileUris, and archiveUris; for Scala/Java: mainJarFileUri,
jarFileUris, fileUris, and archiveUris, or source files and build
manifests if inspecting/rebuilding source) into src_<app_id>_temp/
with gcloud storage cp -r, and carry fileUris forward to Step 2.
Git URL: clone into <repo_name>_<app_id>_temp, check out the
requested branch, tag, or commit, then create the working branch:
git clone <REPO_URL> <repo_name>_<app_id>_temp
git -C <repo_name>_<app_id>_temp checkout <REF>
git -C <repo_name>_<app_id>_temp checkout -b spark-upgrade-<target_version>
Confirm that the job's source files and dependency manifests are present. If a Git repository and the job's GCS objects both exist and differ, ask which one is the source of truth.
Resolve versions.
Target version: run the script.
uv run <skill_dir>/scripts/resolve_version.py --type=cluster --version=<target_version> --distro=<distro_or_family>
uv run <skill_dir>/scripts/resolve_version.py --type=serverless --version=<major.minor>
--distro=ubuntu for a 2.0.85-ubuntu18 source) so the OS doesn't
change silently; if the source distro is unknown too, ask. Record
the result: Step 2 pins it.<major>.<minor>. Serverless has no sub-minor to resolve or pin.Source version: never resolve it with the script. The source is whatever the job actually ran.
Map the source and target to Spark versions with spark_migration_reference.md, and look up the component versions (Java, Scala, Python, connectors, preinstalled libraries) as described in its Component Versions section.
Scan and run baseline build checks.
fetch_migration_notes.py), and the Java runtime, connector, and
GPU/RAPIDS checks. For a Serverless upgrade from runtime 1.x/2.x to 3.x,
also report the platform changes in
serverless_input_validations.md.file:line, build-check results, and the planned changes.Upgrade and build against the target.
Run this step only when the user requested verification, accepted the offer in Step 1.6, or asked to automatically approve the full workflow (rule 5).
ClassNotFoundException, NoSuchMethodError, NoClassDefFoundError,
IncompatibleClassChangeError), Java version errors
(UnsupportedClassVersionError, InaccessibleObjectException,
Unrecognized VM option), duplicate data sources
(Multiple sources found), SQL/Catalyst errors (ParseException,
AnalysisException, SparkArithmeticException,
SparkNumberFormatException, SparkDateTimeException), serialization
errors, import or dependency errors (for PySpark, ImportError or
ModuleNotFoundError), and GPU driver or RAPIDS errors. Fix the code,
re-run the build checks, and retry with a new job/batch ID: at most 3
retries._temp paths, no test-only logic.<app_id>_<source_version>_<target_version>_spark_upgrade_report.md, with
secrets (e.g. passwords or tokens in job arguments or properties) redacted,
covering:
<major>.<minor>);file:line, including every legacy flag
added;fetch_migration_notes.py
index), and any guide reported as not checked;_temp paths in GCS).gcloud storage cp: the final code
(for PySpark, the job's main file and code dependencies, changed or not,
keeping their relative layout; for Scala/Java, the changed source tree and
build definition in their original layout plus, when the build checks
passed, the rebuilt jar under its clean release name rather than
<jar_name>_<app_id>_temp.jar—see
jvm_build_reference.md)
and the report. Delete migration_notes_<app_id>_temp/ once the report is
written. Keep the local working copy (src_<app_id>_temp/ or local files)
and the local report
(<app_id>_<source_version>_<target_version>_spark_upgrade_report.md) in
the local workspace after uploading—do not delete them unless the user asks.
For an analysis-only request, upload only the report. For a Git source, also
leave the changes on the spark-upgrade-<target_version> branch (don't push
unless the user asks) and name the branch in the report.roles/dataproc.viewer;
roles/storage.objectViewer on target/code buckets;
roles/logging.viewer for audit-log fallback.roles/dataproc.editor,
roles/iam.serviceAccountUser on VM SA, roles/storage.objectUser on
target/staging bucket. VM SA: roles/dataproc.worker + data roles.roles/dataproc.editor + roles/iam.serviceAccountUser; workload SA
needs roles/dataproc.worker + roles/storage.objectAdmin + data
roles. Runtime 3.x: user needs roles/dataproc.serverlessEditor + data
roles (or roles/iam.serviceAccountUser with a custom SA that has
roles/dataproc.serverlessNode + data roles).roles/storage.objectUser on the bucket of
the Target GCS path.references/cluster_input_validations.md (opens in a new tab)references/cluster_verifications.md (opens in a new tab)references/java_analysis.md (opens in a new tab)references/jvm_build_reference.md (opens in a new tab)references/pyspark_analysis.md (opens in a new tab)references/scala_analysis.md (opens in a new tab)references/serverless_input_validations.md (opens in a new tab)references/serverless_verifications.md (opens in a new tab)references/spark_migration_reference.md (opens in a new tab)scripts/fetch_migration_notes.py (opens in a new tab)scripts/resolve_version.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
spark-upgrade, dataproc, gcp-migration, pyspark, scala-spark
npx claudepluginhub googlecloudplatform/data-agent-kit-plugin --plugin dak41 skills in this plugin
/accidental-data-loss-prevention**STOP AND VERIFY**: Before running any command or tool that results in irreversible data loss, you MUST obtain explicit user consent.
When in doubt, ask. It is better to wait for confirmation than to accidentally delete production data or critical project assets.
Use this for:
- SQL: DROP TABLE/VIEW/SCHEMA/DATABASE, TRUNCATE, or broad DELETE (missing WHERE or using 1=1).
- Cloud Storage: gsutil rm or gcloud storage rm targeting production data or critical buckets.
- Infrastructure: gcloud projects delete, deleting Spanner/BigQuery/Dataproc resources, deleting secrets, or KMS key destruction.
/bigquery-ai-mlLeverages BigQuery's built-in machine learning and GenAI capabilities for advanced data analytics. Use when you need to write SQL queries that perform time-series forecasting, predict values, detect outliers or anomalies, find key drivers, perform semantic search or vector search, classify text, calculate similarity, summarize content, translate language, evaluate models, filter by semantic conditions, measure the causal effect of an intervention, compute correlations between columns, generate descriptive statistics and table distribution profiles, detect change points or structural breaks, extract trend or seasonality components, or leverage generative AI capabilities in BigQuery. Do not use for general BigQuery dataset, table, or job management requests.Other plugins' skills for the same job