Build Scala Service
Purpose
Implement Scala backend behavior with Scala as a first-class JVM path.
The practical decision is how to use immutable data, explicit effects or futures, clear module boundaries, and focused tests without translating Java service patterns into Scala syntax.
When To Use
- Use this skill when the repository is Scala-first and the task changes backend behavior.
- Use this skill when the user asks for functional JVM backend work and repo context does not point elsewhere.
- Use this skill when
choose-service-shape routes implementation to Scala.
- Use Java guidance instead for Java-dominant backend modules, and Android guidance for Android app/platform work.
Source Check
Use repo-local JVM files, checked-out dependency sources, Dash MCP or Dash HTTP for installed JVM docsets, and then official or canonical documentation when Dash/local coverage is missing or stale:
Use framework documentation for framework-specific behavior. Translate documentation rules into concrete code, test, or validation decisions.
Implementation Workflow
- Inspect the existing Scala shape:
- Scala version
- SBT, Gradle, or Maven project layout
- package and module names
- framework entry points
- effect model, future model, or synchronous style
- test framework
- formatting and lint expectations
- Model data functionally:
- prefer immutable case classes for product data
- use sealed traits or enums for closed alternatives
- use
Option for expected absence
- use
Either, validated values, or the repo's effect error channel for recoverable domain errors
- avoid
null unless interoperating with Java or a framework API that requires it
- Keep behavior composable:
- write small pure functions for domain transformations where practical
- keep routing, request decoding, and response encoding at the edge
- pass dependencies explicitly through the repository's existing pattern
- avoid abstracting with typeclasses unless the abstraction has more than one real use or matches local style
- Preserve the async/effect model:
- use
Future if the project is Future-based
- use the repository's established effect system when one exists
- do not introduce Cats Effect, ZIO, Akka/Pekko, or another runtime for one feature
- keep resource acquisition, cancellation, retries, and timeouts explicit around external dependencies
- Add focused tests:
- test pure domain behavior directly
- add route or integration tests when serialization, auth, persistence, or framework behavior changed
- preserve ScalaTest, MUnit, Weaver, or repository-selected style
Framework Boundaries
Preserve the existing framework unless the user asks for a framework decision.
- Keep http4s, ZIO HTTP, Akka/Pekko, Play, Spring, or framework-specific code at the service edge.
- Keep domain and validation code framework-light when it will be reused or tested independently.
- Do not make one framework's module structure the default for another framework.
Validation
Use server-side-jvm:build-tooling-workflow to choose exact commands.
Common validation shapes:
- SBT module:
sbt module/test
- SBT full check:
sbt test
- Gradle Scala module:
./gradlew :module:test
- Maven Scala module:
mvn -pl module -am test
Run broader validation before commit, push, PR, release, or cross-module behavior changes.
Output Shape
Return:
Changed behavior: the Scala service behavior or API changed.
Functional boundary: pure domain, effectful service, route edge, persistence adapter, config, or test.
Data model: case classes, sealed traits/enums, options, eithers, validated values, or existing convention.
Effect model: synchronous, Future, Cats Effect, ZIO, Akka/Pekko, or existing runtime.
Validation: exact build and test commands and results.
Guardrails
- Do not treat Scala as Java with different syntax.
- Do not introduce an effect system, framework, or typeclass abstraction without a real project reason.
- Do not use
null or exceptions for ordinary domain flow unless local conventions require it.
- Do not convert Java modules to Scala unless the user asks.
- Do not make Android app/platform concerns part of this skill.
1---2name: build-scala-service3description: Implement and maintain idiomatic Scala backend services, including immutable data modeling, algebraic data types, options/eithers, effect or future-based async boundaries, framework routing, module design, tests, and functional service structure.4license: Apache-2.05---67# Build Scala Service89## Purpose1011Implement Scala backend behavior with Scala as a first-class JVM path.1213The practical decision is how to use immutable data, explicit effects or futures, clear module boundaries, and focused tests without translating Java service patterns into Scala syntax.1415## When To Use1617- Use this skill when the repository is Scala-first and the task changes backend behavior.18- Use this skill when the user asks for functional JVM backend work and repo context does not point elsewhere.19- Use this skill when `choose-service-shape` routes implementation to Scala.20- Use Java guidance instead for Java-dominant backend modules, and Android guidance for Android app/platform work.2122## Source Check2324Use repo-local JVM files, checked-out dependency sources, Dash MCP or Dash HTTP for installed JVM docsets, and then official or canonical documentation when Dash/local coverage is missing or stale:2526- [Scala documentation](https://docs.scala-lang.org/)27- [Scala 3 Book](https://docs.scala-lang.org/scala3/book/introduction.html)28- [SBT Reference Manual](https://www.scala-sbt.org/1.x/docs/)29- [ScalaTest User Guide](https://www.scalatest.org/user_guide)30- [MUnit documentation](https://scalameta.org/munit/)3132Use framework documentation for framework-specific behavior. Translate documentation rules into concrete code, test, or validation decisions.3334## Implementation Workflow35361. Inspect the existing Scala shape:37 - Scala version38 - SBT, Gradle, or Maven project layout39 - package and module names40 - framework entry points41 - effect model, future model, or synchronous style42 - test framework43 - formatting and lint expectations442. Model data functionally:45 - prefer immutable case classes for product data46 - use sealed traits or enums for closed alternatives47 - use `Option` for expected absence48 - use `Either`, validated values, or the repo's effect error channel for recoverable domain errors49 - avoid `null` unless interoperating with Java or a framework API that requires it503. Keep behavior composable:51 - write small pure functions for domain transformations where practical52 - keep routing, request decoding, and response encoding at the edge53 - pass dependencies explicitly through the repository's existing pattern54 - avoid abstracting with typeclasses unless the abstraction has more than one real use or matches local style554. Preserve the async/effect model:56 - use `Future` if the project is Future-based57 - use the repository's established effect system when one exists58 - do not introduce Cats Effect, ZIO, Akka/Pekko, or another runtime for one feature59 - keep resource acquisition, cancellation, retries, and timeouts explicit around external dependencies605. Add focused tests:61 - test pure domain behavior directly62 - add route or integration tests when serialization, auth, persistence, or framework behavior changed63 - preserve ScalaTest, MUnit, Weaver, or repository-selected style6465## Framework Boundaries6667Preserve the existing framework unless the user asks for a framework decision.6869- Keep http4s, ZIO HTTP, Akka/Pekko, Play, Spring, or framework-specific code at the service edge.70- Keep domain and validation code framework-light when it will be reused or tested independently.71- Do not make one framework's module structure the default for another framework.7273## Validation7475Use `server-side-jvm:build-tooling-workflow` to choose exact commands.7677Common validation shapes:7879- SBT module: `sbt module/test`80- SBT full check: `sbt test`81- Gradle Scala module: `./gradlew :module:test`82- Maven Scala module: `mvn -pl module -am test`8384Run broader validation before commit, push, PR, release, or cross-module behavior changes.8586## Output Shape8788Return:89901. `Changed behavior`: the Scala service behavior or API changed.912. `Functional boundary`: pure domain, effectful service, route edge, persistence adapter, config, or test.923. `Data model`: case classes, sealed traits/enums, options, eithers, validated values, or existing convention.934. `Effect model`: synchronous, `Future`, Cats Effect, ZIO, Akka/Pekko, or existing runtime.945. `Validation`: exact build and test commands and results.9596## Guardrails9798- Do not treat Scala as Java with different syntax.99- Do not introduce an effect system, framework, or typeclass abstraction without a real project reason.100- Do not use `null` or exceptions for ordinary domain flow unless local conventions require it.101- Do not convert Java modules to Scala unless the user asks.102- Do not make Android app/platform concerns part of this skill.