Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 1.68 KB

File metadata and controls

28 lines (22 loc) · 1.68 KB

Scala Code Rules

For any Scala (.scala, .sc, .mill) source questions, file operations, search, or analysis, use ScalaSemantic MCP tools before shell text tools. Preferably compile code before usage, therefore more SclaSemantic functions could be used with better result. If sources are not indexed - need to launch project compilation

  1. NEVER use generic text/file-reading, viewing, or searching tools (whether built-in agent tools like view_file/grep_search, or shell commands like rg/grep/cat/sed) on .scala, .sc, .mill files.
  2. ALWAYS use the custom tools provided by the scala-semantic MCP server:
    • To read/view the contents of a file: Use the annotated_source MCP tool.
    • For all other queries (searching, finding usages, hierarchies, etc.): Select the appropriate tool from the registered scala-semantic MCP tools.
  3. Exceptions: You may use generic tools on non-Scala files (such as .sbt, .json, .md), or if the scala-semantic MCP tools are completely failing/unavailable.
  4. ALWAYS call set_workspace_root with the new absolute path before any other scala-semantic tool call after changing working directories (worktree switch, cd, subproject entry, or subagent cwd change). If unsure, call get_workspace_root first. This is a discipline rule, not a harness-enforced guarantee.

Scala CLI SemanticDB

Enable with Scala CLI directives: --semanticdb

Not raw scalac flags:

//> using semanticdb
//> using semanticdbSourceroot .

Avoid //> using options -Ysemanticdb and //> using options -sourceroot:..

If SemanticDB tools report an empty index, verify generation with: find .scala-build -name '*.semanticdb'