Use agent4s to find a definition in Scala or Java, see who implements a trait, or preview the edits for a rename. It reads Git-tracked source files and returns file paths and line numbers. You can query a freshly cloned project before compiling it.
The launcher supports macOS (Apple Silicon or Intel), Linux x86-64 and Windows x64 with Git Bash. Install the plugin from your terminal with Claude Code 2.1.292 or later.
claude plugin install agent4s --marketplace scala-digest/agent4sOn earlier versions with plugin support, run claude plugin marketplace add scala-digest/agent4s and then claude plugin install agent4s@agent4s-marketplace.
Start a Claude Code session in a Scala repository and try this prompt.
/agent4s:agent4s Where does this project start? Show the entry points with their files and line numbers.
In agent4s's own repository, you should find the CLI's main in src/cli.scala and the benchmark's bench in src/bench.scala. To repeat the lookup below in chat, ask “Where is WorkspaceIndex defined?” Run /agent4s:setup if you want Claude to save project-specific notes in CLAUDE.md.
codex plugin marketplace add scala-digest/agent4s
codex plugin add agent4s@agent4s-marketplaceOpen a new session in your Scala project and ask “Use agent4s to find the entry points and show their source locations.”
The launcher downloads and verifies the pinned native binary on first use. You need Git, Bash, curl and either sha256sum or shasum. On Windows, run the launcher from Git Bash.
git clone https://github.com/scala-digest/agent4s.git
cd agent4s
./agent4s def WorkspaceIndex --verboseThe result includes the class declaration in src/index/workspace.scala and its line number.
Use -w to point the launcher at a different checkout. Replace the path below with the root of your Scala project.
./agent4s overview --concise -w /path/to/your/projectOn Windows x64, download scalex-windows-x64.exe and run it from PowerShell, for example .\scalex-windows-x64.exe overview --concise. Release assets use the engine's original name, scalex. The launcher pins agent4s v0.6.0, built on Scalex 1.41.0. Run ./agent4s --version to check the engine. Native downloads
To run from source in this checkout, use ./mill run def WorkspaceIndex or mill.bat run def WorkspaceIndex on Windows.
The examples below are arguments after ./agent4s. Substitute names from your project.
| Your question | Query | What you get |
|---|---|---|
| Where is this type defined? | def com.example.UserService --verbose |
File, line and declared signature |
| Who implements the trait? | impl UserService |
Types whose declarations extend it |
| How does this method work? | body findUser --in UserServiceLive --imports |
The source of the method and its file's imports |
| Where does the name appear? | refs UserService --count |
Match counts by category. Drop --count for locations. |
| What would a rename change? | rename UserService AccountService |
A preview of edits. Add --apply to write them. |
| Which tests mention this type? | coverage UserService |
Matching lines in test files |
For more queries, run ./agent4s help. The command reference covers filters, package exploration, call graphs, scaffolding and static checks. Command reference
| Task | Skill |
|---|---|
| Navigate | /agent4s:agent4s looks up symbols and follows relationships. |
| Review | /agent4s:audit reviews code health. /agent4s:bug-hunt inspects static findings. /agent4s:critique evaluates design. |
| Refactor | /agent4s:simplify reduces complexity. /agent4s:extract pulls out shared code. /agent4s:normalize aligns code with project conventions. |
| Prepare a change for review | /agent4s:harden improves error handling. /agent4s:polish tidies names, imports and docs. |
| Configure a project | /agent4s:setup saves project notes. /agent4s:semanticdb configures compiler metadata. |
| Maintain the plugin | /agent4s:doctor diagnoses problems. /agent4s:upgrade updates the installation. /agent4s:submit reports feedback. |
Clients that support the Model Context Protocol can run the same CLI as a local server. For example, add this entry to .cursor/mcp.json, replacing the command with the absolute path to the launcher in your clone or the downloaded executable.
{
"mcpServers": {
"agent4s": {
"command": "/absolute/path/to/agent4s/agent4s",
"args": ["mcp"]
}
}
}Reload the client and look for scalex_def in its tools. Call it with workspace set to the absolute path of the agent4s checkout and query set to WorkspaceIndex. You should get the same source location as in the CLI example.
- agent4s parses Scala 2, Scala 3 and Java declarations. It caches the index in
.scalex/index.bin. For untracked files, local variables and generated code, check the source or build output. refsmatches names in source text. Two types with the same name can appear in one result.unusedreports candidates to review andcoverageshows mentions in tests.- If your compiler emits SemanticDB,
rename --semanticcan use compiler-resolved symbols, andcall-graph --semanticcan use them for outgoing calls. Read the diagnostic on stderr to see when the engine falls back to text matching.
Read about the index and its measured cold and warm performance, or use the repository's action in CI. Architecture · Benchmarks · GitHub Action
Built on scalex by Tu Nguyen, with Scalameta, JavaParser and graph layout code adapted from ascii-graphs. scalex · Contributing · MIT license