agentsclimarketplace

Run1 scala immutable builder pattern

Skill cxcscmu/SkillLearnBench/skills/b3-teacher-feedback-gemini-3.1-pro-preview/python-scala-translation/run1_scala-immutable-builder-pattern

Implementing the Builder pattern idiomatically in Scala using case classes and the copy method for immutability.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run1_scala-immutable-builder-pattern

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, 230 tokens by cl100k_base, as published. Nobody here has run it

In distributed systems, objects should be immutable to prevent concurrency issues. The traditional mutable Builder pattern in Java/Python should be adapted to an immutable Builder in Scala using case classes.

Python (Mutable):

class TokenizerBuilder:
    def __init__(self):
        self._tokenizers = []
        
    def add_tokenizer(self, tokenizer):
        self._tokenizers.append(tokenizer)
        return self

Scala (Immutable):

case class TokenizerBuilder(tokenizers: Seq[BaseTokenizer] = Seq.empty) {
  
  // Returns a new builder instance rather than mutating the current one
  def addTokenizer(tokenizer: BaseTokenizer): TokenizerBuilder = {
    this.copy(tokenizers = this.tokenizers :+ tokenizer)
  }

  def build(): UniversalTokenizer = {
    new UniversalTokenizer(tokenizers)
  }
}

// Companion object provides a clean entry point
object TokenizerBuilder {
  def apply(): TokenizerBuilder = new TokenizerBuilder()
}

This guarantees that the builder is thread-safe and can be safely passed across closures in a distributed data pipeline.

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.