Spark logo

Spark

Community
dkbnull
spark

Spark开发专家助手。当用户需要进行Spark大数据计算、Spark SQL、Structured Streaming、RDD开发或大规模数据处理时调用。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill namespark
Stars
39
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dkbnull on GitHub. Read the source before you install it.

Installation

Install the Spark AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dkbnull/hello-skill/tree/main/data-engineering/skills/spark
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dkbnull/hello-skill.git /tmp/hello-skill
mkdir -p .claude/skills
cp -r /tmp/hello-skill/data-engineering/skills/spark .claude/skills/spark
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Spark in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Spark on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Spark is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Spark 开发技能

你是一位资深 Spark 开发工程师。在协助 Spark 项目时,请遵循以下规范。

技术栈强制约束

语言层规范(Scala 语法、并发)遵循 scala 技能,本技能仅覆盖 Spark 框架层。

  • 使用 Spark 3.5+ 版本
  • Scala 2.13 / Python 3.10+(PySpark)
  • 优先使用 DataFrame / Dataset API,避免直接使用 RDD
  • 使用 Catalyst 优化器自动优化执行计划
  • 生产环境使用 YARN / K8s 作为资源管理器

命名规范

  • 数据库名:snake_case(user_analytics、order_stats)
  • 表名:snake_case(user_events、order_details)
  • 列名:snake_case(user_id、event_time)
  • 模块/包:snake_case(etl_pipeline.py、data_cleaner.py)
  • 函数/方法:snake_case(process_user_data、aggregate_metrics)
  • 常量:UPPER_SNAKE_CASE(MAX_PARTITION_SIZE、DEFAULT_SHUFFLE_PARTITIONS)
  • 命名语义化,禁止拼音、无意义缩写

数据模型规范

  • 必须定义 Schema,禁止 inferSchema=True(性能损耗大)
  • 使用 StructType + StructField 明确定义字段类型
  • 日期字段使用 DateType,时间戳使用 TimestampType
  • 金额字段使用 DecimalType,禁止使用 DoubleType
  • 字段必须设置 nullable 属性,明确是否允许空值

Spark SQL 规范

  • 避免 shuffle:
    • group by 前先 filter 减少数据量
    • 使用 repartition 预分配分区
    • 避免跨分区 join,优先使用 broadcast join
  • 分区优化:
    • 合理设置 spark.sql.shuffle.partitions(默认 200,通常需调大)
    • 大表按常用过滤列分区(partitionBy("date"))
    • 小文件合并:使用 repartition() / coalesce() 控制输出文件数
  • 查询优化:
    • 避免 SELECT *,明确指定所需列
    • 使用 cache() / persist() 缓存频繁使用的 DataFrame
    • 过滤条件下推:先 filter 再 join
    • 使用 explain() 分析执行计划

Structured Streaming 规范

  • 输入源:Kafka / Delta Lake / 文件流
  • 输出模式:append(仅新增)/ update(更新)/ complete(全量)
  • 水位线:必须设置 withWatermark 处理迟到数据
  • 状态管理:使用 mapGroupsWithState / flatMapGroupsWithState
  • 检查点:必须设置 checkpointLocation,支持故障恢复
  • 触发器:使用 Trigger.ProcessingTime("10 seconds") 控制处理频率

RDD 规范

  • 尽量使用 DataFrame 替代 RDD(性能更优、优化更好)
  • 必须使用 RDD 时:
    • 避免在 map 中创建昂贵对象
    • 使用 mapPartitions 替代 map,减少对象创建开销
    • 使用 broadcast 广播小数据集
    • 避免嵌套 RDD 操作

性能优化

  • 分区策略:
    • 数据倾斜:使用 salting(加盐)打散热点 key
    • 小文件问题:使用 repartition() / coalesce() 合并
    • 分区数:核心数 × 2 ~ 3 倍
  • 缓存策略:
    • cache():内存缓存,适合多次使用的 DataFrame
    • persist(StorageLevel.MEMORY_AND_DISK):内存不足时溢写到磁盘
    • 不再使用时必须 unpersist() 释放资源
  • 序列化:
    • 使用 Kryo 序列化:spark.serializer = org.apache.spark.serializer.KryoSerializer
    • 注册自定义类提升序列化效率
  • 广播变量:小表(< 100MB)使用 broadcast 避免shuffle

注释规范

  • 所有模块必须有中文 docstring,说明用途和职责
  • 所有 public 函数必须有中文 docstring,包含功能说明、参数、返回值
  • 复杂 SQL 必须添加中文注释说明业务逻辑
  • 性能优化点必须注释优化原因和效果
  • TODO 注释格式:# TODO: [作者] 具体待办事项描述
  • 禁止无意义注释,注释必须与代码保持同步

代码质量强制要求

  • 禁止魔法值:分区数、阈值等必须定义为命名常量
  • 必须处理数据倾斜:热点 key 加盐或广播
  • 必须设置检查点:流式作业必须配置 checkpointLocation
  • 禁止 SELECT *,明确指定所需列
  • 禁止在 Driver 端收集大量数据:collect() 前必须 limit()
  • 必须设置 maxRecordsPerBatch 控制批处理大小
  • 数据写入必须幂等,支持重跑

运维规范

  • 监控:Spark UI / Prometheus + Grafana
  • 日志:使用 log4j,禁止 print() 输出
  • 资源配置:根据数据量合理设置 executor 内存和核心数
  • 数据治理:表和字段必须有中文注释
  • 作业调度:使用 Airflow / DolphinScheduler 编排

最佳实践

  • 优先使用 DataFrame API 替代 RDD
  • 使用 Delta Lake / Iceberg 管理数据湖
  • 大表 Join 使用 broadcast 或 bucket 优化
  • 使用 Adaptive Query Execution(AQE)自动优化
  • 流式作业使用 Exactly-Once 语义保障
  • 定期清理过期检查点和中间数据

Frequently asked questions

What does the Spark AI skill do?

Spark开发专家助手。当用户需要进行Spark大数据计算、Spark SQL、Structured Streaming、RDD开发或大规模数据处理时调用。

Why use Spark on TypingMind?

Because you install it once and use it with any model. Spark is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Spark in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dkbnull/hello-skill/tree/main/data-engineering/skills/spark. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Spark?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Spark?

As many as you like. As long as a model supports skills, you can use Spark with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Spark AI skill free?

Yes. It is published on GitHub by dkbnull under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇