agentleFS
tkollehtkolleh/skills/scala/SKILL.md

scala

Skill1 starsChanged 3 months agoMITView on GitHub

Use whenever reading, writing, reviewing, or navigating Scala or Java code, or working anywhere in a Scala/Java project (build.sbt, *.scala, *.java files, sbt/Bloop/BSP setup). Enforces preferred tool order for code search and compile/test, plus house style for collections, sbt workflow, and returns.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use a long-running sbt shell session (or sbt --client) for compile and test.

    line 32
  2. Distinctive:

    If this returns nothing, stop and report it rather than guessing at an install path.

    line 42
  3. Distinctive:

    Before any Scala/Java symbol lookup, usage search, "does this pattern appear elsewhere" check, or "where is X defined" question — even …

    line 46
  4. Very specific:

    Use the ast-grep skill (or the sg/ast-grep CLI directly if no skill wrapper exists in your host) when the question is about a code shape …

    line 84
  5. Very specific:

    If your environment exposes start_metals_mcp (start_metals_mcp is a shell function), which is Metals-backed for Scala — …

    line 92
  6. Very specific:

    Use plain grep/ripgrep only when all the tools above have been exhausted or are unavailable, or for files outside Scala/Java entirely …

    line 106
  7. Very specific:

    Don't use .iterator unless really necessary.

    line 122
  8. Very specific:

    Prefer for-loops over map/flatMap, unless they fit in one line (one, or at most two, calls).

    line 124
  9. Very specific:

    Don't call .toList unless it's necessary.

    line 125
  10. Very specific:

    After adding a dependency to build.sbt, ALWAYS run the import-build tool.

    line 126
  11. Very specific:

    Use sbt --client instead of sbt to connect to a running sbt server for faster execution.

    line 127
  12. Distinctive:

    NEVER use non-local returns.

    line 128

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

What this skill enforces

Two hard rules for working in Scala/Java projects, both aimed at the same problem: generic, language-agnostic tool defaults (a cold sbt invocation per command, grep) are slow or semantically blind compared to Scala-aware tools and usage patterns that already exist in this environment. Following the generic default "because it's obvious" silently produces slower feedback loops or missed call sites — this skill exists so that doesn't happen by default.

  1. Compile and test through the build tool's own BSP server — prefer it over defaulting to Bloop.
  2. Code search/navigation MUST follow this fallback order: scalex → ast-grep → semantic/LSP tool (if available) → grep. This order is unconditional — it applies even when you already know which file to look in.

This skill is agent-agnostic: it names capabilities (a Scala symbol-intelligence CLI, a structural pattern-matching CLI, an optional semantic/LSP layer) rather than assuming one specific host's plugin or MCP ecosystem. Use whichever concrete tool your environment provides for each role — see the invocation notes under each tool below for how that resolves in Claude Code specifically.

Compile and test: prefer the build tool's BSP server over Bloop

Use a long-running sbt shell session (or sbt --client) for compile and test. Prefer the build tool's own BSP server over defaulting to Bloop — if your editor/agent integration drives BSP, point it at sbt's BSP server rather than letting it fall back to Bloop.

Precondition — check before running anything:

which sbt

If this returns nothing, stop and report it rather than guessing at an install path.

Search and navigate: ordered, unconditional fallback

Before any Scala/Java symbol lookup, usage search, "does this pattern appear elsewhere" check, or "where is X defined" question — even inside a single file whose location you already know — work through these tools in order. Do not skip ahead to grep or a bare file read on the theory that a lookup is "too simple" to need them; that shortcut has produced missed call sites before (Scala's implicits, extension methods, and type hierarchies are exactly the things a plain text search misses).

1. scalex — primary

scalex is a Scalameta-based Scala/Java code-intelligence CLI (find definition/implementations/ usages/imports/members) — a real semantic parser, not regex or a generic grammar, and it needs no compile step or build server. Reach for it first for:

  • scalex def <symbol> — find where something is defined
  • scalex impl <trait> — find implementations
  • scalex refs <symbol> — find all usages, categorized (extended-by, imported-by, used-as-type, usage, comment)
  • scalex imports <symbol> — dependency/import graph
  • scalex members <symbol> — list members of a class/trait/object

Invocation: in Claude Code, this is available as the scalex:scalex plugin skill — load it for exact syntax (it resolves to a versioned bootstrap script, not a bare scalex binary on PATH). In OpenCode or any other host, use whatever local scalex skill/plugin/CLI installation is configured; if none is installed, say so explicitly rather than silently skipping to ast-grep.

Do not which scalex as a precondition check. Unlike sbt, scalex typically has no bare PATH binary — it's resolved via a plugin/skill bootstrap, so a which scalex will often report "not found" even when scalex is fully available. Treating that as "scalex unavailable, fall through to ast-grep" is a false negative, not a legitimate fallback trigger. The only reliable precondition is trying the actual scalex invocation for your host and seeing what happens.

When scalex won't answer it: it only indexes top-level declarations in git-tracked .scala/.java files. If a symbol is local to a method body, a function parameter, a pattern binding, in a file with parse errors, or not yet git added, scalex will report "not found" — that's the signal to fall through to ast-grep, not a dead end.

2. ast-grep — structural fallback

Use the ast-grep skill (or the sg/ast-grep CLI directly if no skill wrapper exists in your host) when the question is about a code shape rather than a named symbol (e.g. "find all Try { } blocks", "find every case class with more than 5 fields"), or when scalex returned "not found" for a reason listed above. ast-grep matches AST structure via tree-sitter, ignoring formatting differences, and works without any indexing step.

3. Semantic/LSP tool — compiler-accurate confirmation (if available)

If your environment exposes start_metals_mcp (start_metals_mcp is a shell function), which is Metals-backed for Scala — find_referencing_symbols, find_implementations, get_diagnostics_for_file, you must use it because neither scalex nor ast-grep does real type-checking:

  • Implicit/given resolution (which instance the compiler actually selects)
  • Type alias resolution across files
  • Cross-package ambiguous-name disambiguation (two packages both defining Config)
  • Compiler diagnostics for a file

This tier is genuinely optional — if no such tool is configured in your host, skip straight to step 4 rather than blocking on it. There is no separate standalone Metals CLI step to run; where this capability exists, it's exposed through a broader tool (an MCP server, an LSP client), not a dedicated Metals binary.

4. grep / ripgrep — last resort only

Use plain grep/ripgrep only when all the tools above have been exhausted or are unavailable, or for files outside Scala/Java entirely (config, docs, build scripts). A plain file read is fine once a location has already been confirmed by one of the tools above — it is not a substitute for the confirmation step itself.

Relationship to other codebase-search conventions

A host or project may already have its own general codebase-search rule (e.g. ast-grep → semantic tool → ripgrep) for non-Scala languages. For Scala/Java specifically, this skill's order — scalex first — supersedes that default: scalex's Scalameta-based symbol resolution is more precise than tree-sitter pattern matching for named-symbol questions, which are the majority of Scala navigation asks. ast-grep remains the right tool the moment the question shifts from "where is X" to "find code shaped like this."

Scala style

  • Don't use .iterator unless really necessary. Prefer working with higher-order functions, like filter, map, flatMap, directly on collections.
  • Prefer for-loops over map/flatMap, unless they fit in one line (one, or at most two, calls).
  • Don't call .toList unless it's necessary.
  • After adding a dependency to build.sbt, ALWAYS run the import-build tool.
  • Use sbt --client instead of sbt to connect to a running sbt server for faster execution.
  • NEVER use non-local returns.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.