Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Language-specific super-code guidelines for scala.
.claude/skills/lingxling-scala/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 23% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 141% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 75% | 0% |
| case-09 | ✓→✗ | ▼ Worse | 61% | 0% |
| case-19 | ✓→✗ | ▼ Worse | 50% | 0% |
scala// ❌ 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)
scala// ❌ 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)
scala// ❌ Manual fold when sum/product works var total = 0 for (o <- orders) total += o.amount // ✅ val total = orders.map(_.amount).sum
scala// ❌ Using head on potentially empty collection val first = items.head // throws on empty // ✅ val first = items.headOption // returns Option[T]
scala// ❌ 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.
scala// ❌ 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 }
scala// ❌ 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" }
scala// ❌ 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)
scala// ❌ 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)
scala// ❌ 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// ❌ (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 }
scala// ❌ Null checks val name: String = if (user != null) user.name else "Unknown" // ✅ val name = Option(user).map(_.name).getOrElse("Unknown")
scala// ❌ .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 => ... }
scala// ❌ 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
scala// ❌ 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]
scala// ❌ (Scala 2) Implicit conversion that hides bugs implicit def stringToInt(s: String): Int = s.toInt // ✅ — extension methods instead of implicit conversions extension (s: String) def toIntSafe: Option[Int] = s.toIntOption
scala// ❌ (Scala 2) Implicit parameter with broad type def query(sql: String)(implicit conn: Connection): ResultSet // ✅ (Scala 3) def query(sql: String)(using conn: Connection): ResultSet
scala// ❌ Importing implicits from everywhere import com.lib.implicits._ // ✅ — import only what you need import com.lib.given // or specific: import com.lib.{given ExecutionContext}
scala// ❌ Thread.sleep in production code Thread.sleep(5000) // ✅ — use scheduler / timer abstraction import scala.concurrent.duration._ system.scheduler.scheduleOnce(5.seconds)(doWork())
scala// ❌ Blocking inside Future Future { val result = blockingHttpCall() // starves thread pool process(result) } // ✅ Future { blocking { val result = blockingHttpCall() } // or use a dedicated blocking ExecutionContext }
scala// ❌ Awaiting futures in a loop for (f <- futures) Await.result(f, Duration.Inf) // ✅ val all = Future.sequence(futures) all.map(results => process(results))
Prefer Future.sequence/Future.traverse over manual await loops.
| Anti-pattern | Preferred | |---|---| | .get on Option/Try | .getOrElse / pattern match | | null | Option | | isInstanceOf + asInstanceOf | pattern matching | | Implicit conversions (Scala 2) | extension methods (Scala 3) | | var for accumulation | val + functional transforms | | return keyword | last expression is the return value | | Mutable collections by default | immutable collections | | Any / AnyRef parameters | generics with type bounds | | Deeply nested for comprehensions | break into named values | | Tuple instead of case class | case class for anything with semantic meaning | | Await.result in production | compose with map/flatMap |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-20 | pass→pass | 8,277 | 7,939 | -4% | 1 | 1 | 0% | 1,763 | 3,568 | +102% | 0 | 0 | — |
case-01 | fail→pass | 18,281 | 12,843 | -30% | 1 | 1 | 0% | 3,497 | 4,289 | +23% | 0 | 0 | — |
case-02 | fail→fail | 13,458 | 14,064 | +5% | 1 | 1 | 0% | 2,851 | 4,369 | +53% | 0 | 0 | — |
case-03 | pass→pass | 9,659 | 5,911 | -39% | 1 | 1 | 0% | 1,555 | 2,859 | +84% | 0 | 0 | — |
case-04 | fail→fail | 12,766 | 5,891 | -54% | 1 | 1 | 0% | 2,135 | 3,192 | +50% | 0 | 0 | — |
case-05 | pass→pass | 7,486 | 3,999 | -47% | 1 | 1 | 0% | 1,039 | 2,696 | +159% | 0 | 0 | — |
case-06 | pass→pass | 5,498 | 2,709 | -51% | 1 | 1 | 0% | 1,138 | 2,476 | +118% | 0 | 0 | — |
case-07 | fail→pass | 5,747 | 4,890 | -15% | 1 | 1 | 0% | 1,203 | 2,902 | +141% | 0 | 0 | — |
case-08 | pass→pass | 9,240 | 4,711 | -49% | 1 | 1 | 0% | 1,772 | 2,781 | +57% | 0 | 0 | — |
case-09 | pass→fail | 10,724 | 7,889 | -26% | 1 | 1 | 0% | 2,137 | 3,431 | +61% | 0 | 0 | — |
case-10 | pass→pass | 5,527 | 2,937 | -47% | 1 | 1 | 0% | 1,021 | 2,521 | +147% | 0 | 0 | — |
case-11 | pass→pass | 5,792 | 2,513 | -57% | 1 | 1 | 0% | 1,145 | 2,441 | +113% | 0 | 0 | — |
case-12 | fail→fail | 11,046 | 7,492 | -32% | 1 | 1 | 0% | 2,128 | 3,398 | +60% | 0 | 0 | — |
case-13 | pass→pass | 7,172 | 5,590 | -22% | 1 | 1 | 0% | 1,370 | 2,802 | +105% | 0 | 0 | — |
case-14 | pass→pass | 7,385 | 3,974 | -46% | 1 | 1 | 0% | 1,366 | 2,677 | +96% | 0 | 0 | — |
case-15 | pass→pass | 6,848 | 4,483 | -35% | 1 | 1 | 0% | 1,409 | 2,833 | +101% | 0 | 0 | — |
case-16 | pass→pass | 11,580 | 9,542 | -18% | 1 | 1 | 0% | 2,149 | 3,923 | +83% | 0 | 0 | — |
case-17 | pass→pass | 5,949 | 3,689 | -38% | 1 | 1 | 0% | 1,150 | 2,635 | +129% | 0 | 0 | — |
case-18 | fail→pass | 7,896 | 5,677 | -28% | 1 | 1 | 0% | 1,641 | 2,869 | +75% | 0 | 0 | — |
case-19 | pass→fail | 15,335 | 11,301 | -26% | 1 | 1 | 0% | 2,721 | 4,084 | +50% | 0 | 0 | — |
case-21 | fail→fail | 13,880 | 8,368 | -40% | 1 | 1 | 0% | 2,828 | 3,547 | +25% | 0 | 0 | — |
case-22 | pass→pass | 11,559 | 7,367 | -36% | 1 | 1 | 0% | 2,374 | 3,497 | +47% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +5 percentage points is the difference between those two pass rates over the 22 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.