scala-generics

scala-generics is a skill for Claude Code, Codex from cxcscmu/SkillLearnBench. It costs 22 tokens per session (1,042 once invoked), scanned A, original, MIT.

A guide to Scala generic types for Python developers. It explains how Scala expresses reusable types, including covariance, contravariance, invariance, and type limits.

In plain words
What is it for?
Use it when converting Python TypeVars, generic classes, consumers, containers, or union constraints to Scala 2.13.
Why use it?
It clarifies type relationships that Python often leaves implicit, reducing mistakes when designing or translating generic Scala code.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/cxcscmu/skilllearnbench/scala-generics
Any agent
npx skills add cxcscmu/SkillLearnBench --skill scala-generics
Clone the repo
git clone --depth 1 https://github.com/cxcscmu/SkillLearnBench

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for scala-generics

README.md
[![agentmods](https://agentmods.dev/badge/skills/cxcscmu/skilllearnbench/scala-generics.svg)](https://agentmods.dev/skills/cxcscmu/skilllearnbench/scala-generics)
Your own site
<a href="https://agentmods.dev/skills/cxcscmu/skilllearnbench/scala-generics"><img src="https://agentmods.dev/badge/skills/cxcscmu/skilllearnbench/scala-generics.svg" alt="Measured on agentmods" height="20"></a>
Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,042 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00022 $0.01042
Opus 5 $0.00011 $0.00521
Sonnet 5 $0.00004 $0.00208
Haiku 4.5 $0.00002 $0.00104

Measured 4d ago against content hash 313cbb97c7e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

scala-generics scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/b1-one-shot-claude-haiku-4-5/python-scala-translation/scala-generics/SKILL.md · 131 lines

How it starts

The opening of the file, as written. The whole thing — 131 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Scala Generics and Type System for Python Developers

Core Concepts

Variance (Key Difference from Python)

Python has no explicit variance system. Scala requires explicit declarations:

Covariance (+T) - "out" position, can return subtypes:

class Container[+T](items: Seq[T]) {
  def get: T = items.head  // OK - returning subtype
  // def set(t: T): Unit   // ERROR - would be contravariant
}

Contravariance (-T) - "in" position, can accept supertypes:

class Consumer[-T] {
  def consume(t: T): Unit  // OK - accepting supertype
  // def produce: T         // ERROR - would be covariant
}

Invariance (T) - exact type, no variance:

class Handler[T] {
  def get: T
  def set(t: T): Unit  // Both OK - invariant
}

Translation Pattern

Python Scala Notes
TypeVar("T") [T] Invariant by default
TypeVar("T_co", covariant=True) [+T] Covariant, out-position only
TypeVar("T_contra", contravariant=True) [-T] Contravariant, in-position only
TypeVar("T", int, float) [T <: Int | Float] Upper bound (Scala 3) or sealed trait
Generic[T] [T] Class definition
Union[A, B] A | B (Scala 3) or sealed trait Use sealed traits for compatibility

Type Bounds

// Upper bound - T must be subtype of Ordered
class Comparable[T <: Ordered[T]]

// Lower bound - T must be supertype of String
class Container[T >: String]

// Context bound (implicit evidence)
class Serializable[T: Format]

Higher-Kinded Types (Scala's advantage)

Python's TypeVar("F") for type constructors cannot express true HKTs. Scala can use type lambdas:

// Scala 2.13 with kind-projector
type Functor[F[_]] = {
  def map[A, B](fa: F[A], f: A => B): F[B]
}

// Or in Scala 3
def map[F[_], A, B](fa: F[A], f: A => B): F[B]

Translation Examples

Generic Container (Python)

class TokenContainer(Generic[T_co]):
    def __init__(self, items: Sequence[T_co]) -> None:
        self._items: tuple[T_co, ...] = tuple(items)

    def get_all(self) -> tuple[T_co, ...]:
        return self._items

Read the full file on GitHub · 131 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 131 lines · 22 tokens per session scan A 313cbb97c7e5

Subscribe to this mod's changes

scala-generics is a skill published in the GitHub repository cxcscmu/SkillLearnBench (82 stars, last pushed 1mo ago), licensed MIT. It adds 22 tokens to every session and 1,042 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

Tradução para Espanhol Sul Americano

Traduz textos do português para o espanhol, especificamente utilizando o dialeto fluente sul americano.

ECNU-ICALK/AutoSkill · 29 tokens

logistics-rules-to-optimization

Translate logistics and operations rules into optimization variables and constraints. Use when an operations problem describes vehicles, routes, depots, pickups, dropoffs, inventory, capacity, assignments, time windows, service targets, penalties, resource limits, or other business rules that need to become an…

Raidriar7170/hermes-skilleval · 66 tokens

logistics-rules-to-optimization

Translate logistics and operations rules into optimization variables and constraints. Use when an operations problem describes vehicles, routes, depots, pickups, dropoffs, inventory, capacity, assignments, time windows, service targets, penalties, resource limits, or other business rules that need to become an…

Raidriar7170/hermes-skilleval · 66 tokens

translator

你是一个专业的中英翻译助手。请遵循以下规范:.

lizhiyao/oh-my-knowledge · 0 tokens

i18n-localization

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

vudovn/ag-kit · 27 tokens

portfolio

Cross-chain DeFi portfolio discovery, rebalancing suggestions, and NEAR Intent construction. Activates when the user pastes a wallet address or asks about yield/positions/rebalancing. Bootstraps a per-user "portfolio" project, aggregates positions across all the user's addresses inside one project, and offers a…

suyoumo/ClawProBench · 69 tokens