Logo vun Direct Style Scala

Direct Style Scala

Organisatioun
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.

Iwwersiicht

EditeurVirtusLab
Repositoryscala-skill
Skill-Nummdirect-style-scala
Stären
79
Forks
3
Matgeliwwert Fichieren
25
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 25 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum VirtusLab op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Direct Style Scala an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/VirtusLab/scala-skill/tree/master/direct-style-scala/skills/direct-style-scala
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Direct Style Scala an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Direct Style Scala automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Direct Style Scala net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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.

Firwat Direct Style Scala op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Direct Style Scala besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Direct Style Scala an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/VirtusLab/scala-skill/tree/master/direct-style-scala/skills/direct-style-scala an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Direct Style Scala benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Direct Style Scala benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Direct Style Scala domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Direct Style Scala gratis?

De Skill gëtt vum VirtusLab op GitHub publizéiert. Kuckt am Repository no de Lizenzbedéngungen. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇