Scavenger finds dead code in running JVM applications. Attach a Java agent, let your service handle real traffic, and Scavenger shows which methods were never invoked β by package, class and method, across applications and environments. No code changes, no rebuild.
- Why runtime analysis?
- How it works
- Features
- Requirements
- Quick start
- Reading the results
- Ask from your AI coding agent (MCP)
- Going to production
- Documentation
- Contributing
Your IDE flags a method as unused only when nothing references it. In a long-lived service most dead code is still referenced: an endpoint no client calls anymore, a branch behind a feature flag that never flips, a batch step for a product that was retired. Static analysis cannot tell these apart from live code. Runtime data can β it shows code that is reachable but never reached.
Scavenger records which methods of your packages are invoked and keeps that record over weeks or months, so the decision to delete is backed by what actually ran.
Scavenger started from Codekvast, the first tool to bring runtime dead-code analysis to Java. It rewrites most of the code, with a new UI and more elaborate instrumentation.
βββββββββββββββββββββββββββ codebase, invocations βββββββββββββββ ββββββββββββββββ
β Your JVM application β ββββββ gRPC, ~2 min βββββΆ β Collector β ββββΆ β Database β
β + scavenger-agent-java β β :8080 β β H2 / MySQL / β
βββββββββββββββββββββββββββ βββββββββββββββ β Vitess β
ββββββββ¬ββββββββ
β
Browser βββββ web UI, snapshots βββββ βββββββββββββββ β
βββββββββββββββββ API β βββββββββββββ
AI agent βββββ MCP βββββββββββββββββββ β :8081 β
βββββββββββββββ
- At startup the agent scans your application for the methods in the configured
packages(the codebase) and instruments them with Byte Buddy. - It records which of those methods are invoked and publishes them to the collector β first about 10 seconds after startup, then about every 2 minutes.
- The API serves the web UI, where you take snapshots: which methods were invoked in the applications and environments you pick. It also embeds an MCP server for AI coding agents.
- No code changes β a
-javaagentflag and a configuration file. - Any JVM language running on Java 8 or later. An agent for Java 7 (no longer maintained) and a Python agent (beta) are also available.
- Workspaces, applications and environments β collect
dev,stagingandprodseparately and combine them in one snapshot. - Snapshots with a package tree, a usage treemap and the last invocation time of every method.
- Call-stack tracking (optional,
callStackTraceMode) to see which method calls which. - MCP server so AI coding agents can check "is this method used?" against real usage
(on
develop, not yet released). - H2 to try it out, MySQL or Vitess for production.
| Component | Requirement |
|---|---|
| Collector, API | JDK 25 or later |
| Java agent | An application on Java 8 or later (integration-tested on 8, 11, 17, 21 and 25) |
| Database | H2 (embedded, for trying out), MySQL or Vitess |
| Network | Agents β Collector 8080 (HTTP and gRPC). Users β API 8081 (UI, REST, MCP) |
Run everything on one machine with the embedded H2 database.
# the latest release
VERSION=$(curl -fsSLo /dev/null -w '%{url_effective}' https://github.com/naver/scavenger/releases/latest | sed 's|.*/v||')
curl -fLO https://github.com/naver/scavenger/releases/download/v$VERSION/scavenger-collector-$VERSION.jar
curl -fLO https://github.com/naver/scavenger/releases/download/v$VERSION/scavenger-api-$VERSION.jar
curl -fLO https://github.com/naver/scavenger/releases/download/v$VERSION/scavenger-agent-java-$VERSION.jarjava -Dspring.profiles.active=h2 -jar scavenger-collector-$VERSION.jar# in another terminal
java -Dspring.profiles.active=h2 \
-Dscavenger.collector-server-url=http://localhost:8080 \
-jar scavenger-api-$VERSION.jarImportant
Use the h2 profile on both. With it, the collector keeps its data in ~/.scavenger/db and
serves it on port 9091, where the API connects β so start the collector first. Without the
profile, each process gets its own in-memory database and the UI never sees agent data.
Open http://localhost:8081/scavenger and click Create workspace.
On the workspace dashboard, click Show Scavenger configuration file generator, fill in appName
and packages, and download scavenger.conf.
The downloaded file looks like this:
serverUrl = http://localhost:8080
apiKey = <your workspace license key>
appName = demo
packages = com.example.demo
excludeConstructors = true
environment = localpackages takes comma-separated package names; their subpackages are included. Every key can also
be set as a system property (-Dscavenger.apiKey=...) or an environment variable
(SCAVENGER_API_KEY=...). A system property wins over an environment variable, which wins over
the file β handy for keeping the license key out of the file.
java -javaagent:scavenger-agent-java-$VERSION.jar \
-Dscavenger.configuration=scavenger.conf \
-jar your-app.jarAbout 10 seconds after startup the agent reports for the first time, and the application appears on the dashboard:
Use your application for a while, then open Snapshots and click Create.
Warning
The snapshot's Packages field is an Ant-style pattern with . as the separator. Write
com.example.demo.** β a bare com.example.demo matches nothing and gives an empty snapshot.
Leave the field empty to include everything.
Open the snapshot to get the view at the top of this page. In the treemap, green areas contain invoked methods (brighter means a larger share was invoked) and black areas contain none; the table lists the invoked share per package or class. A snapshot is computed when it is created: click Refresh in the snapshot to include newer invocations.
"Never invoked" is evidence, not a verdict. Before deleting code, check that:
- The observation window covers rare paths β month-end batches, yearly jobs and failover code run on their own schedule.
- Every instance and environment runs the agent β the dashboard lists each connected JVM, and a snapshot covers only the applications and environments you selected.
- The data is current β a snapshot does not update by itself, so refresh it, and check Last polled at on the dashboard to see that the agents are still reporting.
Note
The MCP server is on develop and not in a release yet. To try it, build the API from source with
./gradlew assemble -p scavenger-api and run scavenger-api/build/libs/scavenger-api-*-SNAPSHOT.jar
in place of the released API jar β it works on the same database.
The API embeds an MCP server at /scavenger/mcp, so an agent
such as Claude Code, Cursor or Codex can check real usage before it suggests deleting code. Register
it with your workspace license key, e.g. in Claude Code's .mcp.json:
{
"mcpServers": {
"scavenger": {
"type": "http",
"url": "http://localhost:8081/scavenger/mcp",
"headers": { "X-Scavenger-License-Key": "${SCAVENGER_LICENSE_KEY}" }
}
}
}Then ask in plain language β "Is TestService.call() still used?", "Which methods in
com.example.demo were never invoked?". The agent picks from five read-only tools:
| Tool | Answers |
|---|---|
list_scopes |
Which applications and environments exist, and how long each has been collecting |
is_method_used |
Is this method invoked anywhere? |
get_method_callers |
Who calls this method? (needs callStackTraceMode) |
get_stale_methods |
Which methods were never invoked, or not for N days? |
get_pr_impact |
Usage of up to 200 methods at once, e.g. those a pull request touches |
Every answer carries coverage β when collection started and when an agent last reported β so the
agent can tell "unused" from "not observed yet". A response from the quick-start run above:
See the MCP server guide for every argument, the response format and the deployment checklist.
- Database β run the collector and the API with
-Dspring.profiles.active=mysqland thespring.datasource.*properties. See the installation guide. - Collector URL β set the API's
scavenger.collector-server-urlto the address your agents reach: the configuration generator writes it intoserverUrl. - Access control β the API has no built-in authentication and its REST API returns workspace
license keys. Keep the UI and
/scavenger/api/**behind your SSO or proxy; if you expose MCP, route only/scavenger/mcp(see the MCP guide). - Agent tuning β once collection works, set
asyncCodeBaseScanMode=trueso the codebase scan no longer delays startup. For Spring and Lombok code,excludeConstructors=trueandexcludeGetterSetter=trueremove methods that are always called or generated. All options are in the configuration reference.
| Guide | Contents |
|---|---|
| Installation | Collector and API profiles, MySQL, every agent option |
| User guide | Workspaces, configuration files, snapshots |
| MCP server | Tools, response format, deployment and security |
| Python agent (beta) | Installing and configuring the Python agent |
| Debugging the agent | Attaching a debugger to the agent |
| Module | Role |
|---|---|
scavenger-agent-java |
Java agent: scans the codebase and reports invocations |
scavenger-collector |
Receives agent data, stores it and cleans up stale data |
scavenger-api |
REST API, web UI host and MCP server |
scavenger-frontend |
Web UI, bundled into the API |
scavenger-agent-python |
Python agent (beta) |
scavenger-old-agent-java |
Agent for Java 7 (no longer maintained) |
scavenger-demo |
Sample application for tests and local runs |
Scavenger welcomes any contributions from users.
Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests:
- Fork the repo and create your branch from develop.
- If you've added code that should be tested, add tests.
- Ensure the test suite passes.
- Issue that pull request!
Found a bug or have an idea? Please open an issue.
For transparency and insight into our release cycle, and to strive to maintain backward compatibility, Scavenger will be maintained under the Semantic Versioning guidelines to the greatest extent possible.
Releases will be numbered in the following format:
`<major>.<minor>.<patch>`
Release will be constructed based on the following guidelines:
- Breaking backward compatibility bumps the major (and resets the minor and patch)
- New additions without breaking backward compatibility bump the minor (and reset the patch)
- Bug fixes and small enhancement. changes bump the patch
Copyright 2023-present NAVER Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



