Direct Style Scala logo

Direct Style Scala

Organization
VirtusLab
direct-style-scala

Scala coding style, tooling, and functional programming guidance, with dedicated sections on direct-style Scala, Ox structured concurrency, and synchronous Tapir. Auto-load for any task involving Scala code, especially when using direct-style or "plain" Scala.

Overview

PublisherVirtusLab
Repositoryscala-skill
Skill namedirect-style-scala
Stars
79
Forks
3
Bundled files
25
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 25 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by VirtusLab on GitHub. Read the source before you install it.

Installation

Install the Direct Style Scala AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/VirtusLab/scala-skill/tree/master/direct-style-scala/skills/direct-style-scala
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/VirtusLab/scala-skill.git /tmp/scala-skill
mkdir -p .claude/skills
cp -r /tmp/scala-skill/direct-style-scala/skills/direct-style-scala .claude/skills/direct-style-scala
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Direct Style Scala in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Direct Style Scala on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Direct Style Scala is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Scala tooling

  • Drive the build with sbt commands. Projects use sbt 2, which differs from sbt 1:
    • sbt connects to a background server by default; don't add --client. The server keeps the environment of its first start; sbt shutdown to reset it.
    • multiple commands must be one quoted argument: sbt "clean ; compile ; test"
    • test only runs failed, new or affected tests; testFull runs all
    • sbt run starts the app in a separate JVM; killing sbt doesn't stop it, kill that JVM. unknown event: sbt/clientJob means the sbt runner is too old.
    • build.sbt is Scala 3: no postfix calls, slash syntax only (Test / compile). Bare settings apply to all subprojects (no ThisBuild /). Tasks are cached: wrap side-effecting custom tasks in Def.uncached.
    • outputs are in target/out/jvm/scala-<version>/<project>/
  • resolve dependency versions from https://repo1.maven.org/maven2/<group-with-slashes>/<artifact>/maven-metadata.xml, including the suffix (com/softwaremill/ox/core_3; sbt plugins: _sbt2_3). Take the latest stable <version>; <release> may be a prerelease (RC, M<n>, SNAP, alpha, beta, NIGHTLY). NEVER use search.maven.org/solrsearch (stale by months). Find unknown coordinates via https://index.scala-lang.org/api/autocomplete?q=<name>.
  • before committing, ALWAYS run sbt scalafmtAll
  • the project MUST compile with zero warnings. Ensure build.sbt includes -Wunused:all, -Wvalue-discard, -Wnonunit-statement in scalacOptions. Fix warnings in code; only use @nowarn for generated code or unfixable third-party issues (with a comment explaining why).

Coding style

  • ALWAYS use braceless syntax — do not use {}
  • responsibilities in code MUST be segregated between appropriately named entities
  • before creating or moving a .scala file, decide its package, filename, and each top-level declaration's visibility (narrowest the call sites allow). Read Code Organization and Visibility when adding packages/modules or widening visibility.
  • each function MUST handle exactly one concern — either a single logical operation, or a short orchestration of named steps.
  • use Ox .pipe/.tap (import ox.*) to drop single-use vals that only feed the next line; keep a named val when the name documents intent.
  • tests MUST be targeted — each test covers exactly one scenario. No overlapping or redundant tests.
  • every public function, val, and given MUST have an explicit return type — this prevents accidental signature drift during refactors.

Performance

  • NEVER materialize unbounded data in memory — stream with Flow or page.
  • virtual threads are never preempted: long CPU-bound work needs computeIntensive or cede() — see CPU-intensive work.

Direct-style Scala

  • in Tapir, wire logic with .handle / .handleSecurity / .handleSuccess — NEVER .serverLogic* (it needs an effect wrapper).
  • ALWAYS use Ox for threading, channels, and async coordination — not raw threads, queues, locks, or lifecycle flags. See Use Ox primitives.
  • decide the owning scope before writing concurrent code: prefer a local supervised per request/job; return the fork's result, never an object owning running forks. Read Scope propagation before taking (using Ox) / (using ResourceScope) or forking from a factory.
  • a fork blocked reading a subprocess pipe, stdin, a file, or other classic java.io stream is NOT ended by scope cancellation — shutdown deadlocks. BEFORE driving a subprocess or reading a blocking external stream (socket, SSE), read Subprocesses and External Streams.

Functional programming

Worked examples: Domain Modeling.

  • use pure functions, immutable data, higher-order functions, ADTs. NEVER use shared mutable state.
  • var declarations MUST be inside methods (e.g. processing loops), never as class fields. Class-level vars break reasoning and testability. The sole exception is mutable state encapsulated by an Ox Actor, which serialises every invocation onto a single thread — the actor is what makes the field safe to hold (see Concurrency and Inter-Thread Communication). Use only immutable collections (Map, Set, List) — never mutable.Map, mutable.Set, mutable.Buffer (mutable collections are fine in test fakes).
  • model state as an immutable case class; transitions are pure state => state functions; confine the var to the smallest scope.
  • APIs MUST be lawful: pass Clock, Random, and UUID generation explicitly (parameter or constructor) — never call them inside methods.
  • use type-safe domain modelling: design types so invalid data CANNOT be constructed — enums, ADTs, opaque types, Option for absence (never null), smart constructors returning Either (not require)
  • wrap String, Int, Long, and Boolean domain values in opaque types or enums — NEVER use raw primitives for domain concepts (identifiers, quantities, configuration values).
  • replace Boolean parameters and return values with two-case enums.
  • recoverable failures: return Either[E, T] — never throw, require, or bare try/catch. Exceptions only for unrecoverable errors that end the current request/message.
  • define typed error hierarchies — NEVER use stringly-typed errors.

Use-Case Guide

BEFORE writing code that uses Tapir, Ox, or sttp, or touches a topic listed below, read the relevant chapter(s) in full. Follow every API and > Required / > Important callout exactly — do NOT substitute another approach. Read the chapter file from this skill's directory, or with a raw HTTP GET from the base URL below — never via a tool that summarises the page (summaries drop callouts and exact API calls). https://raw.githubusercontent.com/virtuslab/scala-skill/refs/heads/master/direct-style-scala/skills/direct-style-scala/

Application Structure

Error Handling

  • Error Handling — Fail ADT, either/.ok(), transactEither, .catching, nesting rules
  • Error Output Customisation — JSON error responses, Fail → status code mapping, failOutput, defaultHandlers
  • Decode Failure Handling — DefaultDecodeFailureHandler, onDecodeFailureNextEndpoint, custom messages, hideEndpointsWithAuth

HTTP & Endpoints

Data & Integration

  • SQL Persistence — Magnum, @Table, DbCodec, Repo/TableInfo, sql interpolation, Flyway, HikariCP
  • Sending Emails — EmailScheduler, SMTP/Mailgun/dummy senders, templates, batch sending
  • Kafka Streaming — KafkaFlow.subscribe, mapPar, KafkaDrain, offset commits, transactional produce-and-commit, graceful shutdown

Testing & Observability

  • Testing HTTP Endpoints — TapirSyncStubInterpreter, SttpClientInterpreter, public and secured endpoints in-process
  • OpenTelemetry Observability — SDK auto-config, Tapir/sttp instrumentation, custom metrics, PropagatingVirtualThreadFactory, MDC correlation

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Direct Style Scala AI skill do?

Scala coding style, tooling, and functional programming guidance, with dedicated sections on direct-style Scala, Ox structured concurrency, and synchronous Tapir. Auto-load for any task involving Scala code, especially when using direct-style or "plain" Scala.

Why use Direct Style Scala on TypingMind?

Because you install it once and use it with any model. Direct Style Scala is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Direct Style Scala in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/VirtusLab/scala-skill/tree/master/direct-style-scala/skills/direct-style-scala. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Direct Style Scala?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Direct Style Scala?

As many as you like. As long as a model supports skills, you can use Direct Style Scala with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Direct Style Scala AI skill free?

It is published on GitHub by VirtusLab. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇