agentsclimarketplace

Run2 scala idiomatic patterns

Skill cxcscmu/SkillLearnBench/skills/b2-self-feedback-claude-opus-4-6/python-scala-translation/run2_scala-idiomatic-patterns

Idiomatic Scala patterns for translating Python code including enums, case classes, and naming conventions.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run2_scala-idiomatic-patterns

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.2 KB, 252 tokens by cl100k_base, as published. Nobody here has run it

Idiomatic Scala Patterns

Enums (Scala 2.13)

Use sealed abstract class with companion object containing case objects:

sealed abstract class TokenType(val value: String)
object TokenType {
  case object STRING extends TokenType("string")
}

Case Classes for Immutable Data

  • Python @dataclass(frozen=True) -> Scala case class
  • Use copy() for creating modified instances
  • Default params replace field(default_factory=...)

Naming Conventions

  • camelCase for methods/fields: tokenize_batch -> tokenizeBatch
  • PascalCase for types: same in both languages
  • Avoid _ prefix for private fields; use private modifier

Avoid var and return

  • Use Option chains, match, and foldLeft instead of mutable vars
  • Use expression-oriented style: every block returns a value
  • Prefer val over var wherever possible

Pattern Matching over isinstance

Python isinstance(value, (str, bytes)) becomes Scala pattern matching:

value match {
  case s: String => ...
  case d: Double => ...
}

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.