Agent skill

Python Scala Functional

by benchflow-ai in benchflow-ai/skillsbench

Guide for translating Python code to functional Scala style.

Apache-2.0Auto-check passedWriting & Content

Install Python Scala Functional

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

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

GitHub CLI
$ gh skill install benchflow-ai/skillsbench python-scala-functional --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-functional .claude/skills/python-scala-functional && 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-functional
GitHub stars
1.8k
Token cost
~2k tokens
SKILL.md length
36 words
Files
1
Skills in repo
178
Repo updated
First seen
Licence
Apache-2.0

At a glance

Guide for translating Python code to functional Scala style.

  • Converting Python code involving higher-order functions
  • SKILL.md covers Higher-Order Functions, Decorators → Function…, Pattern Matching and Option Handling (None/null…, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Aiming for idiomatic functional Scala with pattern matching

What it does

Python Scala Functional is an agent skill from benchflow-ai/skillsbench. Guide for translating Python code to functional Scala style. Use when converting Python code involving higher-order functions, decorators, closures, generators, or when aiming for idiomatic functional Scala with pattern matching, Option handling, and monadic operations.

Its SKILL.md is about 2k 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

  • Converting Python code involving higher-order functions
  • Aiming for idiomatic functional Scala with pattern matching
  • Option handling
  • Monadic operations

Example prompts

  • “/python-scala-functional”

Requirements

  • Python 3

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 python and scala).

    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 Functional loads about 2k tokens when it runs. Until then it costs about 74 tokens; SKILL.md has 36 words of instructions outside code blocks.

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

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). 36 words, ~1,995 tokens.

Download SKILL.mdSave it as .claude/skills/python-scala-functional/SKILL.md (or your agent's skills folder).
name
python-scala-functional
description
Guide for translating Python code to functional Scala style. Use when converting Python code involving higher-order functions, decorators, closures, generators, or when aiming for idiomatic functional Scala with pattern matching, Option handling, and monadic operations.

Python to Scala Functional Programming Translation

Higher-Order Functions

python
# Python
def apply_twice(f, x):
    return f(f(x))

def make_multiplier(n):
    return lambda x: x * n

double = make_multiplier(2)
result = apply_twice(double, 5)  # 20
scala
// Scala
def applyTwice[A](f: A => A, x: A): A = f(f(x))

def makeMultiplier(n: Int): Int => Int = x => x * n

val double = makeMultiplier(2)
val result = applyTwice(double, 5)  // 20

Decorators → Function Composition

python
# Python
def log_calls(func):
    def wrapper(*args, **kwargs):
        print(f"Calling {func.__name__}")
        result = func(*args, **kwargs)
        print(f"Finished {func.__name__}")
        return result
    return wrapper

@log_calls
def add(a, b):
    return a + b
scala
// Scala - function composition
def logCalls[A, B](f: A => B, name: String): A => B = { a =>
  println(s"Calling $name")
  val result = f(a)
  println(s"Finished $name")
  result
}

val add = (a: Int, b: Int) => a + b
val loggedAdd = logCalls(add.tupled, "add")

// Alternative: using by-name parameters
def withLogging[A](name: String)(block: => A): A = {
  println(s"Calling $name")
  val result = block
  println(s"Finished $name")
  result
}

Pattern Matching

python
# Python (3.10+)
def describe(value):
    match value:
        case 0:
            return "zero"
        case int(x) if x > 0:
            return "positive int"
        case int(x):
            return "negative int"
        case [x, y]:
            return f"pair: {x}, {y}"
        case {"name": name, "age": age}:
            return f"{name} is {age}"
        case _:
            return "unknown"
scala
// Scala - pattern matching is more powerful
def describe(value: Any): String = value match {
  case 0 => "zero"
  case x: Int if x > 0 => "positive int"
  case _: Int => "negative int"
  case (x, y) => s"pair: $x, $y"
  case List(x, y) => s"list of two: $x, $y"
  case m: Map[_, _] if m.contains("name") =>
    s"${m("name")} is ${m("age")}"
  case _ => "unknown"
}

// Case class pattern matching (preferred)
sealed trait Result
case class Success(value: Int) extends Result
case class Error(message: String) extends Result

def handle(result: Result): String = result match {
  case Success(v) if v > 100 => s"Big success: $v"
  case Success(v) => s"Success: $v"
  case Error(msg) => s"Failed: $msg"
}

Option Handling (None/null Safety)

python
# Python
def find_user(user_id: int) -> Optional[User]:
    user = db.get(user_id)
    return user if user else None

def get_user_email(user_id: int) -> Optional[str]:
    user = find_user(user_id)
    if user is None:
        return None
    return user.email

# Chained operations
def get_user_city(user_id: int) -> Optional[str]:
    user = find_user(user_id)
    if user is None:
        return None
    address = user.address
    if address is None:
        return None
    return address.city
scala
// Scala - Option monad
def findUser(userId: Int): Option[User] = db.get(userId)

def getUserEmail(userId: Int): Option[String] =
  findUser(userId).map(_.email)

// Chained operations with flatMap
def getUserCity(userId: Int): Option[String] =
  findUser(userId)
    .flatMap(_.address)
    .map(_.city)

// For-comprehension (cleaner for multiple operations)
def getUserCity(userId: Int): Option[String] = for {
  user <- findUser(userId)
  address <- user.address
  city <- Option(address.city)
} yield city

// Getting values out
val email = getUserEmail(1).getOrElse("no-email@example.com")
val emailOrThrow = getUserEmail(1).get  // Throws if None

Generators → Iterators/LazyList

python
# Python
def fibonacci():
    a, b = 0, 1
    while True:
        yield a
        a, b = b, a + b

# Take first 10
fibs = list(itertools.islice(fibonacci(), 10))
scala
// Scala - LazyList (was Stream in Scala 2.12)
def fibonacci: LazyList[BigInt] = {
  def loop(a: BigInt, b: BigInt): LazyList[BigInt] =
    a #:: loop(b, a + b)
  loop(0, 1)
}

val fibs = fibonacci.take(10).toList

// Alternative: Iterator
def fibonacciIterator: Iterator[BigInt] = new Iterator[BigInt] {
  private var (a, b) = (BigInt(0), BigInt(1))
  def hasNext: Boolean = true
  def next(): BigInt = {
    val result = a
    val newB = a + b
    a = b
    b = newB
    result
  }
}

Try/Either for Error Handling

python
# Python - exceptions
def parse_int(s: str) -> int:
    try:
        return int(s)
    except ValueError:
        return 0

# Python - Optional for errors
def safe_parse_int(s: str) -> Optional[int]:
    try:
        return int(s)
    except ValueError:
        return None
scala
// Scala - Try monad
import scala.util.{Try, Success, Failure}

def parseInt(s: String): Try[Int] = Try(s.toInt)

val result = parseInt("123") match {
  case Success(n) => s"Got: $n"
  case Failure(e) => s"Error: ${e.getMessage}"
}

// Chaining Try operations
val doubled = parseInt("123").map(_ * 2)

// Either for custom error types
def parsePositive(s: String): Either[String, Int] = {
  Try(s.toInt).toEither
    .left.map(_ => "Not a number")
    .flatMap { n =>
      if (n > 0) Right(n)
      else Left("Must be positive")
    }
}

Function Composition

python
# Python
def compose(f, g):
    return lambda x: f(g(x))

def pipe(*functions):
    def inner(x):
        result = x
        for f in functions:
            result = f(result)
        return result
    return inner

# Usage
add_one = lambda x: x + 1
double = lambda x: x * 2
pipeline = pipe(add_one, double, add_one)  # (x + 1) * 2 + 1
scala
// Scala - built-in composition
val addOne: Int => Int = _ + 1
val double: Int => Int = _ * 2

// compose: f.compose(g) = f(g(x))
val composed = addOne.compose(double)  // addOne(double(x))

// andThen: f.andThen(g) = g(f(x))
val pipeline = addOne.andThen(double).andThen(addOne)  // (x + 1) * 2 + 1

Currying and Partial Application

python
# Python
from functools import partial

def add(a, b, c):
    return a + b + c

add_5 = partial(add, 5)
result = add_5(3, 2)  # 10
scala
// Scala - curried functions
def add(a: Int)(b: Int)(c: Int): Int = a + b + c

val add5 = add(5) _  // Partially applied
val result = add5(3)(2)  // 10

// Converting between curried and uncurried
val uncurried = Function.uncurried(add _)
val curried = (uncurried _).curried

// Multiple parameter lists
def fold[A, B](init: B)(list: List[A])(f: (B, A) => B): B =
  list.foldLeft(init)(f)

val sum = fold(0)(List(1, 2, 3))(_ + _)

Tail Recursion

python
# Python - no tail call optimization
def factorial(n):
    if n <= 1:
        return 1
    return n * factorial(n - 1)

# Workaround: iterative
def factorial_iter(n):
    result = 1
    for i in range(2, n + 1):
        result *= i
    return result
scala
// Scala - tail recursion with annotation
import scala.annotation.tailrec

def factorial(n: Int): BigInt = {
  @tailrec
  def loop(n: Int, acc: BigInt): BigInt = {
    if (n <= 1) acc
    else loop(n - 1, n * acc)
  }
  loop(n, 1)
}

Implicit Conversions and Type Classes

python
# Python - no direct equivalent
# Duck typing provides flexibility
scala
// Scala - type classes via implicits (Scala 2) or given/using (Scala 3)

// Scala 3
trait Show[A]:
  def show(a: A): String

given Show[Int] with
  def show(a: Int): String = s"Int: $a"

def display[A](a: A)(using s: Show[A]): String = s.show(a)

// Scala 2
trait Show[A] {
  def show(a: A): String
}

implicit val intShow: Show[Int] = new Show[Int] {
  def show(a: Int): String = s"Int: $a"
}

def display[A](a: A)(implicit s: Show[A]): String = s.show(a)

© 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-functional of benchflow-ai/skillsbench.

Open the folder on GitHubat commit 9a1f4dd

Compare with similar skills

Python Scala Functional 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 Functional compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Python Scala Functional this skillbenchflow-ai/skillsbench1.8k—~2kAutomated 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 today
    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 Functional

What does Python Scala Functional do?

Guide for translating Python code to functional Scala style. Python Scala Functional is an agent skill from benchflow-ai/skillsbench. Guide for translating Python code to functional Scala style.

When should I use Python Scala Functional?

Python Scala Functional fits situations like: converting Python code involving higher-order functions; aiming for idiomatic functional Scala with pattern matching; option handling; monadic operations.

How do I install Python Scala Functional in Claude Code?

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

How do I install Python Scala Functional in Codex?

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

Can I use Python Scala Functional 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-functional -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-functional, .gemini/skills/python-scala-functional, .github/skills/python-scala-functional and .opencode/skills/python-scala-functional in your project.

What does Python Scala Functional need to run?

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

Does Python Scala Functional 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 Functional 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 Functional use?

Python Scala Functional 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 Functional use?

About 2k tokens (SKILL.md is roughly 8k 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 Functional?

Skills that share tags, products or a category with Python Scala Functional: 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 Functional?

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.