Direct Style Scalaのロゴ

Direct Style Scala

組織
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.

概要

公開者VirtusLab
リポジトリscala-skill
スキル名direct-style-scala
スター
79
フォーク
3
同梱ファイル
25
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 25個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    VirtusLabがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Direct Style Scala」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/VirtusLab/scala-skill/tree/master/direct-style-scala/skills/direct-style-scala
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

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
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDirect Style Scalaを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にDirect Style Scalaを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Direct Style Scalaは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

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

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「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.

TypingMindでDirect Style Scalaを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Direct Style Scalaはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDirect Style Scalaをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/VirtusLab/scala-skill/tree/master/direct-style-scala/skills/direct-style-scalaを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Direct Style Scalaを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Direct Style Scalaで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDirect Style Scalaを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Direct Style Scala」は無料ですか?

VirtusLabがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇