Skip to main content
skill CX Codex

scala-expert — Claude Code skill: Scala, Akka, Cats and ZIO

scala-expert is a Claude Code skill with a Scala reference the agent reads before writing code, covering immutability, pattern matching, monads, typed Akka actors and stream pipelines.

Apache-2.0 226 installs ★ 45 updated 2026-10-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add personamanagmentlayer/pcl --skill scala-expert -a claude-code
Open on GitHub

What scala-expert does

The skill hands the agent a Scala reference to work from: immutability, case classes, traits, pattern matching, for-comprehensions. Then the functional layer, with functors, applicatives, monads and type classes shown through Cats.

SKILL.md is mostly code. A typed Akka actor with command and response hierarchies plus an ask. A stream that throttles, recovers from a thrown exception and fans work out through mapAsync. Akka HTTP routes bound to spray-json formats. The agent lifts the shape of those examples into your codebase.

Bash is limited to scala and sbt, alongside Read, Write and Edit. If sbt isn't installed, the build command fails before the agent gets anywhere.

What it helps with

  • Explain what a for-comprehension over Option and Future returns
  • Move error handling from exceptions to Either
  • Sketch a typed Akka actor with a request-response pair
  • Add throttle and recovery to a stream
  • Bind Akka HTTP routes to spray-json formats

Example prompts for the agent

  • Rewrite findUser to return Option instead of null and show the getOrElse version
  • Build a typed Akka actor for orders with commands, replies and an ask
  • Make this stream survive a failure on the fifth element

How to install scala-expert

1Skills CLI (Vercel)

npx skills add personamanagmentlayer/pcl --skill scala-expert -a claude-code

2Manually: put the files in place

~/.claude/skills/scala-expert/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/scala-expert/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about scala-expert

How to install scala-expert in Claude Code?

Run npx skills add personamanagmentlayer/pcl --skill scala-expert -a claude-code. The skill file lands at ~/.claude/skills/scala-expert/SKILL.md.

What does scala-expert do?

It guides the agent through Scala code: case classes, pattern matching, monads, Cats type classes, Akka actors and streams, Akka HTTP routes.

Which tools does the skill allow?

Read, Write, Edit and Bash restricted to the scala and sbt commands. Without sbt installed, the build command will not run.

Source text

SKILL.md · Apache-2.0
---
name: scala-expert
version: 1.1.0
description: >-
  Expert-level Scala, functional programming, Akka, and reactive systems. Use when the user
  mentions functional programming, Akka, Cats, or ZIO, or when the task involves Scala
  Fundamentals, Reactive Systems, or Scala Style.
category: languages
tags: [scala, functional-programming, akka, cats, zio]
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(scala:*, sbt:*)
---

# Scala Expert

Expert guidance for Scala development, functional programming, Akka actors, and reactive systems.

## Core Concepts

### Scala Fundamentals

- Immutability
- Pattern matching
- Case classes
- Traits and mixins
- Implicit conversions
- For comprehensions

### Functional Programming

- Higher-order functions
- Monads (Option, Either, Try)
- Functors and Applicatives
- Type classes
- Pure functions
- Referential transparency

### Reactive Systems

- Akka actors
- Akka Streams
- Akka HTTP
- Play Framework
- Cats Effect
- ZIO

## Scala Basics

```scala
// Case classes
case class User(id: String, name: String, email: String, age: Int)

// Pattern matching
def processUser(user: User): String = user match {
  case User(_, name, _, age) if age < 18 => s"$name is a minor"
  case User(_, name, _, age) if age >= 65 => s"$name is a senior"
  case User(_, name, _, _) => s"$name is an adult"
}

// Options instead of null
def findUser(id: String): Option[User] = {
  database.get(id)
}

val userName = findUser("123") match {
  case Some(user) => user.name
  case None => "Unknown"
}

// Or using map
val name = findUser("123").map(_.name).getOrElse("Unknown")

// For comprehensions
def getUserWithPosts(userId: String): Option[(User, List[Post])] = {
  for {
    user <- findUser(userId)
    posts <- findPosts(userId)
  } yield (user, posts)
}

// Traits and mixins
trait Serializable {
  def toJson: String
}

trait Loggable {
  def log(message: String): Unit = println(s"[LOG] $message")
}

case class Person(name: String, age: Int) extends Serializable with Loggable {
  def toJson: String = s"""{"name":"$name","age":$age}"""
}

// Implicit classes (extension methods)
implicit class StringOps(s: String) {
  def isValidEmail: Boolean = s.contains("@") && s.contains(".")
}

"[email protected]".isValidEmail // true
```

## Functional Programming

```scala
import cats._
import cats.implicits._

// Functor
val numbers = List(1, 2, 3, 4, 5)
val doubled = numbers.map(_ * 2)

// Applicative
val result = (Option(1), Option(2), Option(3)).mapN { (a, b, c) =>
  a + b + c
}

// Monad (flatMap)
def fetchUser(id: String): Future[Option[User]] = ???
def fetchPosts(userId: String): Future[List[Post]] = ???

val userWithPosts: Future[Option[(User, List[Post])]] = {
  fetchUser("123").flatMap {
    case Some(user) =>
      fetchPosts(user.id).map(posts => Some((user, posts)))
    case None =>
      Future.successful(None)
  }
}

// Or with for-comprehension
val result: Future[Option[(User, List[Post])]] = for {
  userOpt <- fetchUser("123")
  posts <- fetchPosts(userOpt.map(_.id).getOrElse(""))
} yield userOpt.map(user => (user, posts))

// Either for error handling
sealed trait Error
case class NotFound(id: String) extends Error
case class ValidationError(message: String) extends Error

def validateUser(user: User): Either[Error, User] = {
  if (user.email.isValidEmail) Right(user)
  else Left(ValidationError("Invalid email"))
}

def saveUser(user: User): Either[Error, User] = {
  for {
    validated <- validateUser(user)
    saved <- database.save(validated)
  } yield saved
}

// Type classes
trait Show[A] {
  def show(a: A): String
}

object Show {
  def apply[A](implicit sh: Show[A]): Show[A] = sh

  implicit val stringShow: Show[String] = new Show[String] {
    def show(s: String): String = s
  }

  implicit val intShow: Show[Int] = new Show[Int] {
    def show(i: Int): String = i.toString
  }

  implicit def listShow[A: Show]: Show[List[A]] = new Show[List[A]] {
    def show(list: List[A]): String = {
      list.map(Show[A].show).mkString("[", ", ", "]")
    }
  }
}

def print[A: Show](a: A): Unit = {
  println(Show[A].show(a))
}
```

## Akka Actors

```scala
import akka.actor.typed._
import akka.actor.typed.scaladsl._

// Actor definition
object UserActor {
  sealed trait Command
  final case class GetUser(id: String, replyTo: ActorRef[Response]) extends Command
  final case class CreateUser(user: User, replyTo: ActorRef[Response]) extends Command

  sealed trait Response
  final case class UserFound(user: User) extends Response
  final case class UserNotFound(id: String) extends Response
  final case class UserCreated(user: User) extends Response

  def apply(): Behavior[Command] = {
    Behaviors.setup { context =>
      var users = Map.empty[String, User]

      Behaviors.receiveMessage {
        case GetUser(id, replyTo) =>
          users.get(id) match {
            case Some(user) =>
              replyTo ! UserFound(user)
            case None =>
              replyTo ! UserNotFound(id)
          }
          Behaviors.same

        case CreateUser(user, replyTo) =>
          users = users + (user.id -> user)
          replyTo ! UserCreated(user)
          Behaviors.same
      }
    }
  }
}

// Using the actor
val system: ActorSystem[UserActor.Command] =
  ActorSystem(UserActor(), "user-system")

import akka.actor.typed.scaladsl.AskPattern._
import akka.util.Timeout
import scala.concurrent.duration._

implicit val timeout: Timeout = 3.seconds

val response: Future[UserActor.Response] =
  system.ask(ref => UserActor.GetUser("123", ref))
```

## Akka Streams

```scala
import akka.stream._
import akka.stream.scaladsl._
import akka.actor.ActorSystem

implicit val system = ActorSystem("streams")
implicit val materializer = ActorMaterializer()

// Simple stream
val source = Source(1 to 10)
val flow = Flow[Int].map(_ * 2)
val sink = Sink.foreach[Int](println)

source.via(flow).runWith(sink)

// Backpressure handling
val throttled = Source(1 to 100)
  .throttle(10, 1.second)
  .map { n =>
    println(s"Processing $n")
    n * 2
  }
  .runWith(Sink.ignore)

// Error handling
val resilient = Source(1 to 10)
  .map { n =>
    if (n == 5) throw new Exception("Error at 5")
    n * 2
  }
  .recover {
    case e: Exception => -1
  }
  .runWith(Sink.seq)

// Parallelism
val parallel = Source(1 to 100)
  .mapAsync(parallelism = 4) { n =>
    Future {
      // Async operation
      Thread.sleep(100)
      n * 2
    }
  }
  .runWith(Sink.seq)
```

## Akka HTTP

```scala
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import spray.json.DefaultJsonProtocol._

// JSON protocol
case class User(id: String, name: String, email: String)

object JsonProtocol {
  implicit val userFormat = jsonFormat3(User)
}

import JsonProtocol._

// Routes
val routes =
  pathPrefix("api") {
    pathPrefix("users") {
      get {
        path(Segment) { userId =>
          // GET /api/users/:userId
          complete(findUser(userId))
        } ~
        pathEnd {
          // GET /api/users
          complete(getAllUsers())
        }
      } ~
      post {
        pathEnd {
          // POST /api/users
          entity(as[User]) { user =>
            complete(createUser(user))
          }
        }
      }
    }
  }

// Start server
val bindingFuture = Http().newServerAt("localhost", 8080).bind(routes)
```

## Cats Effect / ZIO

```scala
import cats.effect._
import cats.effect.implicits._

// Pure functional effects with Cats Effect
def fetchUser(id: String): IO[User] = IO {
  // Effectful computation
  database.get(id)
}

def saveUser(user: User): IO[Unit] = IO {
  database.save(user)
}

val program: IO[Unit] = for {
  user <- fetchUser("123")
  updated = user.copy(name = "Updated")
  _ <- saveUser(updated)
} yield ()

// Error handling
val safeProgram: IO[Either[Throwable, Unit]] = program.attempt

// Parallel execution
val parallel: IO[List[User]] = {
  List("1", "2", "3")
    .parTraverse(id => fetchUser(id))
}

// ZIO
import zio._

def fetchUserZIO(id: String): Task[User] = ZIO.attempt {
  database.get(id)
}

val zioProgram: Task[Unit] = for {
  user <- fetchUserZIO("123")
  _ <- Console.printLine(s"Found user: ${user.name}")
} yield ()
```

## Best Practices

### Functional Programming

- Prefer immutability
- Use pure functions
- Avoid side effects
- Use Option/Either over null/exceptions
- Leverage type classes
- Use for-comprehensions
- Apply functional composition

### Scala Style

- Follow naming conventions
- Use case classes for data
- Prefer vals over vars
- Use pattern matching
- Avoid null
- Use implicits carefully
- Write idiomatic code

### Performance

- Use lazy evaluation
- Stream large datasets
- Avoid unnecessary allocations
- Use tail recursion
- Profile before optimizing
- Consider parallelism

## Anti-Patterns

❌ Using null
❌ Mutable state everywhere
❌ God objects
❌ Excessive implicits
❌ Not handling errors
❌ Blocking operations
❌ Not using type safety

## Resources

- Scala Documentation: https://docs.scala-lang.org/
- Akka Documentation: https://doc.akka.io/
- Cats: https://typelevel.org/cats/
- ZIO: https://zio.dev/
- Functional Programming in Scala (Red Book)

© personamanagmentlayer · Apache-2.0 · personamanagmentlayer/pcl

Similar skills

All skills for Programming languages →

From the same set104

The whole set →
biological-expert biological-expert configures the coding agent for computational biology, genetics, and sequence analysis. It assists with DNA parsing, alignment, and variant annotation. CX Codex +1 235installs security-expert security-expert is a Claude Code skill that provides application security guidance for OWASP checks, vulnerability reviews, and secure coding. It covers tasks involving authentication, encryption, or access control. CX Codex +1 231installs aws-expert The aws-expert skill guides AWS architecture, security, and cost decisions. Use it for cloud, DevOps, infrastructure, or serverless work. CX Codex +1 230installs aerospace-expert The aerospace-expert skill gives coding agents aerospace context for flight systems, maintenance, safety, and aviation software. Use it when those domains shape the task. CX Codex +1 228installs standards-expert standards-expert gives the agent a working reference on ISO management systems — processes, risk scoring, audits — for teams preparing a certification. CX Codex +1 226installs flask-expert flask-expert guides Python work with Flask apps, REST APIs, extensions, and deployment. Use it when a task involves Jinja2, Flask structure, authentication, or API design. CX Codex +1 225installs csharp-expert The csharp-expert skill guides agents through modern C# work with .NET, ASP.NET Core, LINQ, and async code. Use it for backend services and enterprise application patterns. CX Codex +1 221installs maritime-expert The maritime-expert skill gives an agent maritime domain knowledge for vessel tracking, port operations, cargo systems, and shipping software. CX Codex +1 221installs

Project sponsors

Companies that keep this analytics open