Agent skill

Python Scala Idioms

by benchflow-ai in benchflow-ai/skillsbench

Guide for writing idiomatic Scala when translating from Python.

Apache-2.0Auto-check passedWriting & Content

Install Python Scala Idioms

skills CLI
$ npx skills add benchflow-ai/skillsbench --skill python-scala-idioms -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install benchflow-ai/skillsbench python-scala-idioms --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/benchflow-ai/skillsbench.git skills-src && mkdir -p .claude/skills && cp -r skills-src/tasks/python-scala-translation/environment/skills/python-scala-idioms .claude/skills/python-scala-idioms && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
python-scala-idioms
GitHub stars
1.8k
Token cost
~1.9k tokens
SKILL.md length
212 words
Files
1
Skills in repo
178
Repo updated
First seen
Licence
Apache-2.0

At a glance

Guide for writing idiomatic Scala when translating from Python.

  • Works in 5 steps: Prefer immutability - Use val over var,… → Expression-based - Everything returns a… → Type safety - Leverage Scala's type… → …
  • The goal is not just syntactic translation but producing clean
  • SKILL.md covers Core Principles, Immutability First, Expression-Based Style and Sealed Hierarchies for Domain…, plus 9 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Python Scala Idioms is an agent skill from benchflow-ai/skillsbench. Guide for writing idiomatic Scala when translating from Python. Use when the goal is not just syntactic translation but producing clean, idiomatic Scala code. Covers immutability, expression-based style, sealed hierarchies, and common Scala conventions.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Writing & Content, covering Translation. It works with Python. The repository describes itself as: SkillsBench evaluates how well skills work and how effective agents are at using them. The licence is Apache-2.0.

When your agent uses it

  • The goal is not just syntactic translation but producing clean
  • Idiomatic Scala code

Example prompts

  • “/python-scala-idioms”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Prefer immutability - Use val over var, immutable collections
  2. Expression-based - Everything returns a value, minimize statements
  3. Type safety - Leverage Scala's type system, avoid Any
  4. Pattern matching - Use instead of if-else chains
  5. Avoid null - Use Option, Either, Try

What it can do on your machine

Read from SKILL.md and the folder at commit 9a1f4dd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are scala and python).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Python Scala Idioms loads about 1.9k tokens when it runs. Until then it costs about 68 tokens; SKILL.md has 212 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~68
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from benchflow-ai/skillsbench at commit 9a1f4dd, republished under its Apache-2.0 licence (© benchflow-ai). 212 words, ~1,878 tokens.

Download SKILL.mdSave it as .claude/skills/python-scala-idioms/SKILL.md (or your agent's skills folder).
name
python-scala-idioms
description
Guide for writing idiomatic Scala when translating from Python. Use when the goal is not just syntactic translation but producing clean, idiomatic Scala code. Covers immutability, expression-based style, sealed hierarchies, and common Scala conventions.

Python to Idiomatic Scala Translation

Core Principles

When translating Python to Scala, aim for idiomatic Scala, not literal translation:

  1. Prefer immutability - Use val over var, immutable collections
  2. Expression-based - Everything returns a value, minimize statements
  3. Type safety - Leverage Scala's type system, avoid Any
  4. Pattern matching - Use instead of if-else chains
  5. Avoid null - Use Option, Either, Try

Immutability First

python
# Python - mutable by default
class Counter:
    def __init__(self):
        self.count = 0

    def increment(self):
        self.count += 1
        return self.count
scala
// Scala - immutable approach
case class Counter(count: Int = 0) {
  def increment: Counter = copy(count = count + 1)
}

// Usage
val c1 = Counter()
val c2 = c1.increment  // Counter(1)
val c3 = c2.increment  // Counter(2)
// c1 is still Counter(0)

Expression-Based Style

python
# Python - statement-based
def get_status(code):
    if code == 200:
        status = "OK"
    elif code == 404:
        status = "Not Found"
    else:
        status = "Unknown"
    return status
scala
// Scala - expression-based
def getStatus(code: Int): String = code match {
  case 200 => "OK"
  case 404 => "Not Found"
  case _ => "Unknown"
}

// No intermediate variable, match is an expression

Sealed Hierarchies for Domain Modeling

python
# Python - loose typing
def process_payment(method: str, amount: float):
    if method == "credit":
        # process credit
        pass
    elif method == "debit":
        # process debit
        pass
    elif method == "crypto":
        # process crypto
        pass
scala
// Scala - sealed trait for exhaustive matching
sealed trait PaymentMethod
case class CreditCard(number: String, expiry: String) extends PaymentMethod
case class DebitCard(number: String) extends PaymentMethod
case class Crypto(walletAddress: String) extends PaymentMethod

def processPayment(method: PaymentMethod, amount: Double): Unit = method match {
  case CreditCard(num, exp) => // process credit
  case DebitCard(num) => // process debit
  case Crypto(addr) => // process crypto
}
// Compiler warns if you miss a case!

Replace Null Checks with Option

python
# Python
def find_user(id):
    user = db.get(id)
    if user is None:
        return None
    profile = user.get("profile")
    if profile is None:
        return None
    return profile.get("email")
scala
// Scala - Option chaining
def findUser(id: Int): Option[String] = for {
  user <- db.get(id)
  profile <- user.profile
  email <- profile.email
} yield email

// Or with flatMap
def findUser(id: Int): Option[String] =
  db.get(id)
    .flatMap(_.profile)
    .flatMap(_.email)

Prefer Methods on Collections

python
# Python
result = []
for item in items:
    if item.active:
        result.append(item.value * 2)
scala
// Scala - use collection methods
val result = items
  .filter(_.active)
  .map(_.value * 2)

Avoid Side Effects in Expressions

python
# Python
items = []
for x in range(10):
    items.append(x * 2)
    print(f"Added {x * 2}")
scala
// Scala - separate side effects
val items = (0 until 10).map(_ * 2).toList
items.foreach(x => println(s"Value: $x"))

// Or use tap for debugging
val items = (0 until 10)
  .map(_ * 2)
  .tapEach(x => println(s"Value: $x"))
  .toList

Use Named Parameters for Clarity

python
# Python
def create_user(name, email, admin=False, active=True):
    pass

user = create_user("Alice", "alice@example.com", admin=True)
scala
// Scala - named parameters work the same
def createUser(
  name: String,
  email: String,
  admin: Boolean = false,
  active: Boolean = true
): User = ???

val user = createUser("Alice", "alice@example.com", admin = true)

// Case class with defaults is often better
case class User(
  name: String,
  email: String,
  admin: Boolean = false,
  active: Boolean = true
)

val user = User("Alice", "alice@example.com", admin = true)

Scala Naming Conventions

PythonScala
snake_case (variables, functions)camelCase
SCREAMING_SNAKE (constants)CamelCase or PascalCase
PascalCase (classes)PascalCase
_privateprivate keyword
__very_privateprivate[this]
python
# Python
MAX_RETRY_COUNT = 3
def calculate_total_price(items):
    pass

class ShoppingCart:
    def __init__(self):
        self._items = []
scala
// Scala
val MaxRetryCount = 3  // or final val MAX_RETRY_COUNT
def calculateTotalPrice(items: List[Item]): Double = ???

class ShoppingCart {
  private var items: List[Item] = Nil
}

Avoid Returning Unit

python
# Python - None return is common
def save_user(user):
    db.save(user)
    # implicit None return
scala
// Scala - consider returning useful information
def saveUser(user: User): Either[Error, UserId] = {
  db.save(user) match {
    case Right(id) => Right(id)
    case Left(err) => Left(err)
  }
}

// Or at minimum, use Try
def saveUser(user: User): Try[Unit] = Try {
  db.save(user)
}

Use Apply for Factory Methods

python
# Python
class Parser:
    def __init__(self, config):
        self.config = config

    @classmethod
    def default(cls):
        return cls(Config())
scala
// Scala - companion object with apply
class Parser(config: Config)

object Parser {
  def apply(config: Config): Parser = new Parser(config)
  def apply(): Parser = new Parser(Config())
}

// Usage
val parser = Parser()  // Calls apply()
val parser = Parser(customConfig)

Cheat Sheet: Common Transformations

Python PatternIdiomatic Scala
if x is Nonex.isEmpty or pattern match
if x is not Nonex.isDefined or x.nonEmpty
x if x else defaultx.getOrElse(default)
[x for x in xs if p(x)]xs.filter(p)
[f(x) for x in xs]xs.map(f)
any(p(x) for x in xs)xs.exists(p)
all(p(x) for x in xs)xs.forall(p)
next(x for x in xs if p(x), None)xs.find(p)
dict(zip(keys, values))keys.zip(values).toMap
isinstance(x, Type)x.isInstanceOf[Type] or pattern match
try: ... except: ...Try { ... } or pattern match
Mutable accumulator loopfoldLeft / foldRight
for i, x in enumerate(xs)xs.zipWithIndex

Anti-Patterns to Avoid

scala
// DON'T: Use null
val name: String = null  // Bad!

// DO: Use Option
val name: Option[String] = None

// DON'T: Use Any or type casts
val data: Any = getData()
val name = data.asInstanceOf[String]

// DO: Use proper types and pattern matching
sealed trait Data
case class UserData(name: String) extends Data
val data: Data = getData()
data match {
  case UserData(name) => // use name
}

// DON'T: Nested if-else chains
if (x == 1) ... else if (x == 2) ... else if (x == 3) ...

// DO: Pattern matching
x match {
  case 1 => ...
  case 2 => ...
  case 3 => ...
}

// DON'T: var with mutation
var total = 0
for (x <- items) total += x

// DO: fold
val total = items.sum
// or
val total = items.foldLeft(0)(_ + _)

© benchflow-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in tasks/python-scala-translation/environment/skills/python-scala-idioms of benchflow-ai/skillsbench.

Open the folder on GitHubat commit 9a1f4dd

Compare with similar skills

Python Scala Idioms next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Python Scala Idioms compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Python Scala Idioms this skillbenchflow-ai/skillsbench1.8k—~1.9kAutomated safety check: PassApache-2.0
China Travel Kittczyliu/china-travel-kit194—~1.3kAutomated safety check: PassMIT
Technology Searchfreestylefly/wesight943—~3.3kAutomated safety check: PassMIT
Translate Popython/python-docs-zh-tw284—~793Automated safety check: PassCustom licence
Obs Build LogsNuitka/Nuitka15k—~849Automated safety check: PassAGPL-3.0
Update Gui TranslationsArduPilot/MethodicConfigurator163—~1.5kAutomated safety check: PassGPL-3.0

Similar skills

  • China Travel Kit

    tczyliu/china-travel-kit

    Research and plan first-time independent trips in China with bilingual, source-aware city data and official live-check entry points.

    194 GitHub stars~1.3k tokensUpdated 1 mo ago
    Writing & ContentAuto-check passed
  • Technology Search

    freestylefly/wesight

    Search tech blogs, developer forums, and IT media (TechCrunch, Hacker News, 36氪, etc.) for software and hardware industry updates with heat ranking and EN↔CN translation.

    943 GitHub stars~3.3k tokensUpdated 7 days ago
    Writing & ContentAuto-check passed
  • Translate Po

    python/python-docs-zh-tw

    Official

    Translates PO file entries from English to Traditional Chinese (zhTW) following project conventions.

    284 GitHub stars~793 tokensUpdated 3 days ago
    Writing & ContentAuto-check passed
  • Obs Build Logs

    Nuitka/Nuitka

    Access and diagnose openSUSE Build Service (OBS) package build logs.

    15k GitHub stars~849 tokensUpdated yesterday
    Writing & ContentAuto-check passed
  • Update Gui Translations

    ArduPilot/MethodicConfigurator

    Update existing GUI translations using AI assistance. An agent skill from ArduPilot/MethodicConfigurator.

    163 GitHub stars~1.5k tokensUpdated yesterday
    Writing & ContentAuto-check passed
  • Check Terminology

    python/python-docs-zh-tw

    Official

    Checks terminology consistency against project glossary and identifies zhCN terms that need conversion to zhTW.

    284 GitHub stars~705 tokensUpdated 3 days ago
    Writing & ContentAuto-check passed

More from benchflow-ai/skillsbench

All 178 skills in this repo
  • Lean4 Memories

    benchflow-ai/skillsbench

    This skill should be used when working on Lean 4 formalization projects to maintain persistent memory of successful proof patterns, failed approaches, project conventions, and user preferences…

    1.8k GitHub stars~3.2k tokensUpdated 2 mo ago
    Auto-check passed
  • Senior Data Engineer

    benchflow-ai/skillsbench

    World-class data engineering skill for building scalable data pipelines, ETL/ELT systems, real-time streaming, and data infrastructure.

    1.8k GitHub stars~5.9k tokensUpdated 2 mo ago
    Auto-check passed
  • Ac Branch Pi Model

    benchflow-ai/skillsbench

    AC branch pi-model power flow equations (P/Q and |S|) with transformer tap ratio and phase shift, matching acopf-math-model.md and MATPOWER branch fields.

    1.8k GitHub stars~1.1k tokensUpdated 2 mo ago
    Auto-check passed
  • Civ6lib

    benchflow-ai/skillsbench

    Civilization 6 district mechanics library. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~1.7k tokensUpdated 2 mo ago
    Auto-check passed
  • D3 Visualization

    benchflow-ai/skillsbench

    Build deterministic, verifiable data visualizations with D3.js (v6).

    1.8k GitHub stars~1.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Dc Power Flow

    benchflow-ai/skillsbench

    DC power flow analysis for power systems. An agent skill from benchflow-ai/skillsbench.

    1.8k GitHub stars~717 tokensUpdated 2 mo ago
    Auto-check passed

Works with

Questions about Python Scala Idioms

What does Python Scala Idioms do?

Guide for writing idiomatic Scala when translating from Python. Python Scala Idioms is an agent skill from benchflow-ai/skillsbench. Guide for writing idiomatic Scala when translating from Python.

When should I use Python Scala Idioms?

Python Scala Idioms fits situations like: the goal is not just syntactic translation but producing clean; idiomatic Scala code.

How do I install Python Scala Idioms in Claude Code?

Run `npx skills add benchflow-ai/skillsbench --skill python-scala-idioms -a claude-code`. Or copy the skill folder (tasks/python-scala-translation/environment/skills/python-scala-idioms in benchflow-ai/skillsbench) into .claude/skills/python-scala-idioms in your project. Claude Code loads it when a task matches its description.

How do I install Python Scala Idioms in Codex?

Run `npx skills add benchflow-ai/skillsbench --skill python-scala-idioms -a codex`. Or copy the skill folder (tasks/python-scala-translation/environment/skills/python-scala-idioms in benchflow-ai/skillsbench) into .agents/skills/python-scala-idioms in your project. Codex loads it when a task matches its description.

Can I use Python Scala Idioms in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add benchflow-ai/skillsbench --skill python-scala-idioms -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/python-scala-idioms, .gemini/skills/python-scala-idioms, .github/skills/python-scala-idioms and .opencode/skills/python-scala-idioms in your project.

What does Python Scala Idioms need to run?

SKILL.md names no scripts, command-line tools or credentials: Python Scala Idioms is instructions for the agent only. Our summary lists: Python 3.

Does Python Scala Idioms access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Python Scala Idioms safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Python Scala Idioms use?

Python Scala Idioms is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Python Scala Idioms use?

About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Python Scala Idioms?

Skills that share tags, products or a category with Python Scala Idioms: China Travel Kit (tczyliu/china-travel-kit, 194 stars), Technology Search (freestylefly/wesight, 943 stars), Translate Po (python/python-docs-zh-tw, 284 stars) and Obs Build Logs (Nuitka/Nuitka, 15k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Python Scala Idioms?

benchflow-ai (a GitHub organization) maintains it in benchflow-ai/skillsbench, which has 1,832 GitHub stars. The repository holds 178 skills in this directory. The repository was last updated on July 23, 2026.

Source: benchflow-ai/skillsbench on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.