agent-instructions
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what…
Use when building distributed data pipelines with Apache Spark. Covers partitioning, shuffles, skew, joins, caching, and reading the Spark UI to find why a job is slow. Trigger on "spark job is slow", "one task takes forever", "executor out of memory", "too many small files". Do
Claude Code
$ npx -y skills add nimadorostkar/Claude-Skills-collection --skill spark --agent claude-code
Codex
$ npx skills add nimadorostkar/Claude-Skills-collection --skill spark -a codex -y
Cursor
$ npx skills add nimadorostkar/Claude-Skills-collection --skill spark -a cursor -y
Gemini CLI
$ npx skills add nimadorostkar/Claude-Skills-collection --skill spark -a gemini-cli -y
GitHub Copilot
$ npx skills add nimadorostkar/Claude-Skills-collection --skill spark -a github-copilot -y
OpenCode
$ npx skills add nimadorostkar/Claude-Skills-collection --skill spark -a opencode -y
Windsurf
$ npx skills add nimadorostkar/Claude-Skills-collection --skill spark -a windsurf -y
name: spark description: Use when building distributed data pipelines with Apache Spark. Covers partitioning, shuffles, skew, joins, caching, and reading the Spark UI to find why a job is slow. Trigger on "spark job is slow", "one task takes forever", "executor out of memory", "too many small files". Do not use for data that fits on one machine — see the pandas skill. metadata: category: data version: 1.0.0 tags: [spark, distributed, etl, shuffle, skew]
Write Spark jobs whose cost is understood. Almost all Spark performance problems are one of three things: too much shuffle, skewed partitions, or reading far more data than the query needs.
1. **Read the plan first** — `df.explain(True)`. Every `Exchange` is a shuffle, and a shuffle writes to disk and crosses the network. It is the dominant cost. 2. **Prune early** — Select the columns and filter the rows you need before joining, not after. With Parquet, this pushes down to the file reader and never reads the data at all. 3. **Broadcast the small side** — A join where one side fits in memory (roughly under 100 MB) should be a broadcast join. That eliminates the shuffle entirely. 4. **Find the skew** — In the Spark UI, look at the task duration distribution within a stage. If the max is 50x the median, one partition holds most of the data. That single task is your job's runtime. 5. **Mitigate the skew** — Salting the key, or enabling adaptive query execution's skew join handling. 6. **Cache only what is reused** — Caching a DataFrame used once costs memory and gains nothing.
**Prune, broadcast, and avoid the shuffle:**
from pyspark.sql import functions as F
# Costly: joins the full orders table, then filters. The shuffle moves
# everything, including the rows about to be discarded.
result = (
orders.join(customers, "customer_id")
.filter(F.col("created_at") >= "2026-01-01")
.select("order_id", "segment", "total_cents")
)
# Better: filter and project first (pushed into the Parquet reader), and
# broadcast the small dimension so the large side is never shuffled.
result = (
orders
.filter(F.col("created_at") >= "2026-01-01") # predicate pushdown
.select("order_id", "customer_id", "total_cents") # projection pushdown
.join(F.broadcast(customers.select("customer_id", "segment")), "customer_id")
)**Diagnosing and fixing skew:**
# Symptom in the Spark UI: stage 7 has 200 tasks; 199 finish in ~4s and one
# runs for 22 minutes. That one task is the entire job's runtime.
# Confirm: one key dominates.
orders.groupBy("customer_id").count().orderBy(F.desc("count")).show(5)
# +------------+---------+
# | customer_id| count|
# +------------+---------+
# | cus_bulk_01| 41200000| <-- 68% of all rows: a single bulk-import account
# | cus_9f2a3b | 18400|
# Fix: salt the hot key so it spreads across partitions.
SALTS = 64
orders_salted = orders.withColumn(
"salt",
F.when(F.col("customer_id") == "cus_bulk_01",
(F.rand() * SALTS).cast("int")).otherwise(F.lit(0)),
)
customers_exploded = customers.withColumn(
"salt",
F.explode(F.when(F.col("customer_id") == "cus_bulk_01",
F.array([F.lit(i) for i in range(SALTS)])).otherwise(F.array(F.lit(0)))),
)
result = orders_salted.join(customers_exploded, ["customer_id", "salt"])A curated library of 137 production-grade skills for Claude and other AI coding agents. Every skill follows one structure, speaks with one voice, and earns its place by changing what the agent does.
Use when writing project instructions for a coding agent (CLAUDE.md, AGENTS.md, or equivalent). Covers what belongs in them, what…
Use when an agent needs state that survives a session or a context compaction. Covers what to persist, file-based memory,…
Use when automating agent behavior with lifecycle hooks. Covers hook events, deterministic enforcement of rules the model should…
Use when packaging skills, commands, hooks, and MCP servers into a distributable plugin. Covers manifest structure, bundling,…
Use when writing a new skill for an AI agent. Covers scoping, description writing for reliable triggering, progressive…
Use when reviewing or improving an existing agent skill. Covers triggering accuracy, content quality, redundancy with the base…
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.