agentsclimarketplace

Run1 scala trait and class design

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-claude-haiku-4-5/python-scala-translation/run1_scala-trait-and-class-design

[COLM'26] SkillLearnBench is the first benchmark for evaluating continual learning methods that automatically generate agent skills.

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_scala-trait-and-class-design

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

What its author says it does

Copied from the file, not written here

How to structure abstract base classes, trait hierarchies, and inheritance patterns in Scala for the tokenizer domain.

SKILL.md

1.3 KB, 249 tokens by cl100k_base, as published. Nobody here has run it

Trait vs Class Design

When to Use Traits

  • Define contracts/interfaces: BaseTokenizer should likely be a trait
  • Mix multiple behaviors: traits allow multiple inheritance of type and behavior
  • Create sealed trait hierarchies: sealed trait TokenType

When to Use Classes

  • When you need constructor parameters that aren't part of the type contract
  • When you need mutable state (rare in Scala, but sometimes necessary)
  • For concrete implementations that extend traits

Proper Abstraction for Tokenizer Hierarchy

Base Abstraction

trait BaseTokenizer {
  def tokenize(input: String): List[Token]
  // Other abstract methods
}

Concrete Implementations

class StringTokenizer extends BaseTokenizer {
  override def tokenize(input: String): List[Token] = {
    // implementation
  }
}

Factory/Builder Pattern

  • Use companion object's apply method for construction
  • Use builder for complex configuration
  • Avoid passing too many parameters to constructors

Extension Methods

  • For adding utility functions, use Scala 3 extension methods or implicit classes (Scala 2.13)
  • Example: add methods to existing classes without inheritance

What ships with it

Read from the repository

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

Keep looking

Skills are one crate of 326,984. 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.