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
- NEVER use generic text/file-reading, viewing, or searching tools (whether built-in agent tools like
view_file/grep_search, or shell commands likerg/grep/cat/sed) on.scala,.sc,.millfiles. - ALWAYS use the custom tools provided by the
scala-semanticMCP server:- To read/view the contents of a file: Use the
annotated_sourceMCP tool. - For all other queries (searching, finding usages, hierarchies, etc.): Select the appropriate tool from the registered
scala-semanticMCP tools.
- To read/view the contents of a file: Use the
- Exceptions: You may use generic tools on non-Scala files (such as
.sbt,.json,.md), or if thescala-semanticMCP tools are completely failing/unavailable. - ALWAYS call
set_workspace_rootwith the new absolute path before any otherscala-semantictool call after changing working directories (worktree switch,cd, subproject entry, or subagent cwd change). If unsure, callget_workspace_rootfirst. This is a discipline rule, not a harness-enforced guarantee.
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'