scala
Enables your agent to code in Scala. Useful for processing large volumes of data and distributed systems. It helps build robust and scalable applications.
What it does
This guide teaches how to write more efficient and clear Scala code. It shows examples of using language features to avoid common mistakes and make code easier to read and maintain.
When to use it
- ✓When learning to program in Scala.
- ✓When reviewing existing Scala code.
- ✓When looking for ways to improve your Scala code.
Example of what to ask your AI
“How can I write cleaner Scala code for handling lists?”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
The guide compares 'bad' code examples with 'good' ones using specific Scala features. It focuses on collections, error handling, and other best practices.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add sickn33/agentic-awesome-skills --skill scalaOr download just the file:
curl -L https://raw.githubusercontent.com/sickn33/agentic-awesome-skills/main/plugins/agentic-awesome-skills-claude/skills/super-code/scala/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from GitHub.
Scala: Idiomatic Efficiency Reference
When to Use
- Use this skill when the task matches this description: Language-specific super-code guidelines for scala.
Table of Contents
- Collections & Functional Transforms
- Pattern Matching
- Case Classes & ADTs
- Option & Error Handling
- Implicits & Given/Using
- Concurrency
- Anti-patterns specific to Scala
1. Collections & Functional Transforms {#collections}
// ❌ Imperative accumulation
val result = new ArrayBuffer[String]()
for (item <- items) {
if (item.isActive) result += item.name.toUpperCase
}
// ✅
val result = items.filter(_.isActive).map(_.name.toUpperCase)
// ❌ Manual grouping
val grouped = mutable.Map[String, List[Item]]()
for (item <- items) {
grouped(item.category) = grouped.getOrElse(item.category, Nil) :+ item
}
// ✅
val grouped = items.groupBy(_.category)
// ❌ Manual fold when sum/product works
var total = 0
for (o <- orders) total += o.amount
// ✅
val total = orders.map(_.amount).sum
// ❌ Using head on potentially empty collection
val first = items.head // throws on empty
// ✅
val first = items.headOption // returns Option[T]
// ❌ Chaining filter + head for find
val found = items.filter(_.id == targetId).head
// ✅
val found = items.find(_.id == targetId) // returns Option[T]
Use view for lazy evaluation on large collections to avoid intermediate allocations.
2. Pattern Matching {#patterns}
// ❌ if-else chain for type dispatch
if (shape.isInstanceOf[Circle]) {
val c = shape.asInstanceOf[Circle]
c.radius * c.radius * Math.PI
} else if (shape.isInstanceOf[Rect]) { ... }
// ✅
shape match {
case Circle(r) => r * r * Math.PI
case Rect(w, h) => w * h
}
// ❌ Nested match with identical fallthrough
x match {
case 1 => "low"
case 2 => "low"
case 3 => "mid"
case _ => "high"
}
// ✅
x match {
case 1 | 2 => "low"
case 3 => "mid"
case _ => "high"
}
// ❌ Match to extract then use
val result = opt match {
case Some(x) => x.toString
case None => "N/A"
}
// ✅
val result = opt.map(_.toString).getOrElse("N/A")
// or:
val result = opt.fold("N/A")(_.toString)
3. Case Classes & ADTs {#case-classes}
// ❌ Regular class for data
class User(val name: String, val age: Int) {
override def equals(obj: Any): Boolean = ...
override def hashCode(): Int = ...
override def toString: String = ...
}
// ✅
case class User(name: String, age: Int)
// ❌ Sealed trait with unrelated case objects
sealed trait Result
case class Success(value: Int) extends Result
case class Failure(error: String) extends Result
case object Unknown extends Result // what does "Unknown" mean?
// ✅ — each variant should carry the data it represents
sealed trait Result[+A]
case class Success[A] (value: A) extends Result[A]
case class Failure(error: Throwable) extends Result[Nothing]
// ❌ (Scala 3) Verbose enum
sealed trait Color
object Color {
case object Red extends Color
case object Green extends Color
case object Blue extends Color
}
// ✅ (Scala 3)
enum Color { case Red, Green, Blue }
4. Option & Error Handling {#option}
// ❌ Null checks
val name: String = if (user != null) user.name else "Unknown"
// ✅
val name = Option(user).map(_.name).getOrElse("Unknown")
// ❌ .get on Option (defeats the purpose)
val name = userOpt.get // throws if None
// ✅
val name = userOpt.getOrElse("default")
// or: userOpt.map(process).getOrElse(fallback)
// or: userOpt match { case Some(u) => ... case None => ... }
// ❌ Try with .get
val result = Try(parse(input)).get // throws on failure
// ✅
val result = Try(parse(input)) match {
case Success(v) => v
case Failure(e) => handleError(e)
}
// or: Try(parse(input)).getOrElse(default)
// or: Try(parse(input)).toEither
// ❌ Using exceptions for expected failures
def findUser(id: String): User = {
val user = db.query(id)
if (user == null) throw new NotFoundException(id)
user
}
// ✅ — Option for absence, Either for expected errors
def findUser(id: String): Option[User] = db.query(id)
// or:
def findUser(id: String): Either[AppError, User]
5. Implicits & Given/Using {#implicits}
// ❌ (Scala 2) Implicit conversion that hides bugs
…
FAQ
What is 'Pattern Matching'?
It's a powerful way to check and extract data from structures concisely, like a smarter 'if' statement.
Why avoid '.get' on Option?
Using '.get' can cause errors if the value doesn't exist. It's better to use '.getOrElse' or 'match' to handle cases where a value might be missing.
What are 'Case Classes'?
These are simple classes designed to hold data, which come with useful features like built-in comparison and string representation.
Details
Original description by the author
Language-specific super-code guidelines for scala.
Popularity
- GitHub stars
- 48k
- Ranking position
- #4285
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
00-andruia-consultant
Helps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
sickn33/agentic-awesome-skills
007
Lets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
sickn33/agentic-awesome-skills
10-andruia-skill-smith
Helps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
sickn33/agentic-awesome-skills
20-andruia-niche-intelligence
Lets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
sickn33/agentic-awesome-skills
Similar skills
benchmark-optimization-loop
Has your agent improve something's speed in a measured way. It tests multiple versions and chooses the fastest one that still works correctly.
affaan-m/ECC
change-impact
Helps your agent analyze the impact of code changes before making them. It compares the planned vs. actual results afterward, covering paths, data, tests, and documentation. Useful for risky or system-wide changes.
affaan-m/ECC
click-path-audit
Lets your agent trace all user buttons and interactions to find bugs. It finds issues where functions seem to work alone but fail together. Useful when bugs persist even after debugging.
affaan-m/ECC