Skip to main content
skill Claude Code CX Codex Cursor

spark-optimization — Claude Code skill: Spark tuning

This skill helps diagnose slow Apache Spark jobs and tune partitioning, caching, shuffle, and memory. Use it when scaling data-processing pipelines.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add wshobson/agents
/plugin install data-engineering@claude-code-workflows
Open on GitHub

What spark-optimization does

spark-optimization focuses on the causes of slow Apache Spark jobs: excess shuffle, data skew, poor partition sizing, memory pressure, and unnecessary UDFs. It covers AQE, broadcast joins, built-in functions, and columnar formats such as Parquet and Delta.

The package includes a Spark execution model, a PySpark SparkSession setup example, and guidance for checking Spark UI. More worked patterns are stored in references/details.md. Install it when you maintain or troubleshoot Spark pipelines; it adds little value to projects that do not use Apache Spark.

What it helps with

  • trace the cause of a slow Spark job
  • choose a better partitioning strategy
  • reduce shuffle and data skew
  • tune executor and memory settings
  • replace unnecessary UDFs with built-in functions

Example prompts for the agent

  • Inspect this Apache Spark job and identify the sources of excess shuffle.
  • Review this PySpark pipeline for caching, broadcast joins, and partition sizing.
  • Set up a SparkSession for Parquet input and an aggregate without collecting a large dataset.

How to install spark-optimization

1Plugin marketplace

/plugin marketplace add wshobson/agents
/plugin install data-engineering@claude-code-workflows

This installs the whole data-engineering plugin with all its skills

2Skills CLI (Vercel)

npx skills add wshobson/agents --skill spark-optimization -a claude-code

3Manually: put the files in place

~/.claude/skills/spark-optimization/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/spark-optimization/

From the same set213

The whole set →
typescript-advanced-types Seth Hobson Guides an agent through advanced TypeScript types, from generics to conditional and mapped types. Use it for typed libraries, API clients, or strict configuration objects. Claude Code CX Codex Cursor 92,169installs tailwind-design-system Seth Hobson Helps build design systems with Tailwind CSS v4, from theme tokens to component variants. Use it when a project needs shared UI patterns. Claude Code CX Codex Cursor 70,180installs brand-landingpage Travis D. Elliott This skill interviews you about the product and its visual direction, then builds a landing page through Stitch. Use it when there’s no established design yet. Claude Code CX Codex Cursor 39,476installs python-testing-patterns Seth Hobson This skill guides Python testing with pytest, fixtures and mocks. Use it when building a test suite or tracking down failing checks. Claude Code CX Codex Cursor 36,943installs python-performance-optimization Seth Hobson This skill profiles Python code to locate CPU and memory bottlenecks. Use it when an application responds slowly or consumes too many resources. Claude Code CX Codex Cursor 35,675installs nextjs-app-router-patterns Seth Hobson This skill covers Next.js App Router patterns for rendering, routing, and data fetching. Use it when starting an App Router project or moving from Pages Router. Claude Code CX Codex Cursor 32,529installs api-design-principles Seth Hobson Use this skill to plan or review REST and GraphQL APIs. It helps when writing a specification or setting API conventions for a team. Claude Code CX Codex Cursor 30,348installs code-review-excellence Seth Hobson This skill guides pull request reviews, catches logic and security issues, and helps teams give specific feedback. Use it for review standards or developer mentoring. Claude Code CX Codex Cursor 30,193installs

Similar

prisma-client-api prisma Complete Prisma Client API reference for database queries, CRUD operations, and filtering. Triggers on findMany, create, update, delete, and $transaction. Claude Code CX Codex Cursor +1 389,500installs prisma-cli prisma Prisma ORM 7 CLI reference for AI agents. Guides client generation, schema migrations, and local database workflows while preventing accidental data loss. Claude Code CX Codex Cursor +1 386,800installs prisma-postgres prisma A deprecated compatibility name for prisma-postgres-setup. Use it only when explicitly invoked; new projects should select prisma-postgres-setup instead. Claude Code CX Codex Cursor +1 380,400installs prisma-postgres-setup prisma Provisions or connects a Prisma Postgres database and links it to your app. Useful for spinning up dev databases quickly or wiring connections in Vercel and v0. Claude Code CX Codex Cursor +1 374,900installs xlsx official anthropics Creates, reads, edits, and converts spreadsheet files. Use it when the requested deliverable is an Excel workbook or another tabular file. Claude Code Claude.ai 187,223installs google-agents-cli-observability official Google This skill guides you through tracing and monitoring AI agents, including ADK agents. Use it when you need to inspect agent execution or monitor a deployed agent. Claude Code CX Codex Cursor +1 509,900installs caveman-evidence-review JuliusBrussee A read-only skill reviews Caveman Cloud evidence on LLM spend, traces, and routing. Use it to see where a project’s model budget goes. Claude Code CX Codex Cursor +1 103,500installs migration JuliusBrussee Enforces reversible, compatibility-safe transitions for schema, data, and API updates. Useful whenever data loss or rollout downtime is unacceptable. Claude Code CX Codex Cursor +1 102,900installs

Questions about spark-optimization

How do I install spark-optimization in Claude Code?

Run npx skills add wshobson/agents --skill spark-optimization -a claude-code. The skill file is placed at ~/.claude/skills/spark-optimization/SKILL.md.

What does spark-optimization do?

It helps tune Apache Spark jobs by addressing shuffle, skew, partition sizing, memory, caching, joins, and serialization choices.

Which Spark tools and formats does it cover?

The material covers PySpark, Spark UI, AQE, Parquet, Delta, and KryoSerializer. It also discusses caching and adaptive partition coalescing.

Source text

SKILL.md · MIT
---
name: spark-optimization
description: Optimize Apache Spark jobs with partitioning, caching, shuffle optimization, and memory tuning. Use when improving Spark performance, debugging slow jobs, or scaling data processing pipelines.
---

# Apache Spark Optimization

Production patterns for optimizing Apache Spark jobs including partitioning strategies, memory management, shuffle optimization, and performance tuning.

## When to Use This Skill

- Optimizing slow Spark jobs
- Tuning memory and executor configuration
- Implementing efficient partitioning strategies
- Debugging Spark performance issues
- Scaling Spark pipelines for large datasets
- Reducing shuffle and data skew

## Core Concepts

### 1. Spark Execution Model

```
Driver Program
    ↓
Job (triggered by action)
    ↓
Stages (separated by shuffles)
    ↓
Tasks (one per partition)
```

### 2. Key Performance Factors

| Factor            | Impact                | Solution                      |
| ----------------- | --------------------- | ----------------------------- |
| **Shuffle**       | Network I/O, disk I/O | Minimize wide transformations |
| **Data Skew**     | Uneven task duration  | Salting, broadcast joins      |
| **Serialization** | CPU overhead          | Use Kryo, columnar formats    |
| **Memory**        | GC pressure, spills   | Tune executor memory          |
| **Partitions**    | Parallelism           | Right-size partitions         |

## Quick Start

```python
from pyspark.sql import SparkSession
from pyspark.sql import functions as F

# Create optimized Spark session
spark = (SparkSession.builder
    .appName("OptimizedJob")
    .config("spark.sql.adaptive.enabled", "true")
    .config("spark.sql.adaptive.coalescePartitions.enabled", "true")
    .config("spark.sql.adaptive.skewJoin.enabled", "true")
    .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
    .config("spark.sql.shuffle.partitions", "200")
    .getOrCreate())

# Read with optimized settings
df = (spark.read
    .format("parquet")
    .option("mergeSchema", "false")
    .load("s3://bucket/data/"))

# Efficient transformations
result = (df
    .filter(F.col("date") >= "2024-01-01")
    .select("id", "amount", "category")
    .groupBy("category")
    .agg(F.sum("amount").alias("total")))

result.write.mode("overwrite").parquet("s3://bucket/output/")
```

## Detailed patterns and worked examples

Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.

## Best Practices

### Do's

- **Enable AQE** - Adaptive query execution handles many issues
- **Use Parquet/Delta** - Columnar formats with compression
- **Broadcast small tables** - Avoid shuffle for small joins
- **Monitor Spark UI** - Check for skew, spills, GC
- **Right-size partitions** - 128MB - 256MB per partition

### Don'ts

- **Don't collect large data** - Keep data distributed
- **Don't use UDFs unnecessarily** - Use built-in functions
- **Don't over-cache** - Memory is limited
- **Don't ignore data skew** - It dominates job time
- **Don't use `.count()` for existence** - Use `.take(1)` or `.isEmpty()`

© Seth Hobson · MIT · wshobson/agents

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor