sbt-build-test
Skill4 starsChanged 8 months agoMITView on GitHub
Use for ANY SBT operation: compile, test, coverage, publishLocal, dependency discovery, cross-repo builds. Handles multi-repo dependency chains automatically — detects upstream repos, publishes them in correct order, clears caches, and rebuilds. Uses an isolated build cache so normal sbt is never affected.
In this repository10 other files it gives its agents.
- bitbucket-managerSkill
- codebase-analyzerSkill
- codex-subagentSkill
- confluence-publisherSkill
- eks-pod-opsSkill
- jenkins-managerSkill
- jira-managerSkill
- review-promptsSkill
- skill-creatorSkill
- super-reviewSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Use this skill when you need to:
- Distinctive: line 21
Fix stale state: after upstream changes
- Very specific: line 33
Create <workspace>/.sbt-workspace.conf only when you need overrides:
- Very specific: line 99
Use the exact scoped project ID reported by sbt_status.sh for subproject names.
- Very specific: line 101
rootPaths auto-detection: When --sbt-env dev is requested but the project has rootPaths/remoteCache settings AND external ProjectRef …
- Very specific: line 235
Use
sbt_status.shbefore guessing dependency order: Do not guess publish order. - Very specific: line 241
All SBT caches (Ivy, Coursier, SBT boot, SBT global) are isolated inside SBT_BUILD_CACHE_ROOT (default: ~/.sbt-build-cache).
≈ “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.
Files
SBT Multi-Repo Build & Test
Four commands for all SBT operations: build, status, refresh, reset.
When to use this skill
Use this skill when you need to:
- Compile or test any SBT project (single or multi-project)
- Collect scoped coverage while bypassing stale remote-cache pulls
- Publish local artifacts for downstream validation
- Understand dependencies between workspace repos
- Fix stale state after upstream changes
- Inspect test results from JUnit XML reports
Prerequisites
- SBT and the required JDK installed (default: Java 17).
- SBT repos under one workspace root, or define overrides in
.sbt-workspace.conf. python3available for test report parsing and workspace graph helpers.~/.ivy2/.credentialspresent if the workspace resolves private artifacts.
Configuration
Create <workspace>/.sbt-workspace.conf only when you need overrides:
.java_version=17
.group_id=com.acme
shared-models=/absolute/path/to/shared-modelsSee references/CONFIG.md for full schema.
Commands
sbt_build.sh — Compile, test, publishLocal
The single command for all build operations. Accepts one project, several, or --all for the entire workspace. Automatically handles preflight, upstream dep publishing, log capture, and JUnit XML test report parsing.
bash <skill_dir>/scripts/sbt_build.sh <project-dir>... [options] -- <sbt-commands>
bash <skill_dir>/scripts/sbt_build.sh --all [options] -- <sbt-commands>| Option | Description |
--all | Build all workspace projects in dependency order |
--workspace-dir <dir> | Override workspace directory |
--artifact-version <ver> | Set ARTIFACT_VERSION for publishLocal |
--sbt-env <value> | Pass -Dsbt_env=<value> to SBT |
--tail <lines> | Lines of log tail to show (default: 60) |
--auto-publish-deps | Auto-publishLocal missing AND stale workspace deps before building |
--continue-on-error | Keep going when a project fails (useful with --all) |
--fresh | Force fresh SBT process (no server reuse) — use when SBT returns stale results |
--coverage | Enable scoverage for the requested command, disable remote-cache pulls for the scoped project, and emit coverageReport |
--no-remote-cache | Disable remote-cache pulls for this run and clear local target/scala-* directories first |
--skip-preflight | Skip Java/cache pre-check (for repeated calls) |
Examples:
# Compile one project
bash <skill_dir>/scripts/sbt_build.sh /path/to/service -- compile
# Run all tests (auto-parses JUnit XML reports)
bash <skill_dir>/scripts/sbt_build.sh /path/to/service -- test
# Test a specific subproject
bash <skill_dir>/scripts/sbt_build.sh /path/to/service -- "core / test"
# Collect coverage for a specific subproject test
bash <skill_dir>/scripts/sbt_build.sh /path/to/service --coverage -- "aws / testOnly com.example.AwsUserPaginationTest"
# Compile with auto-publish of missing upstream deps
bash <skill_dir>/scripts/sbt_build.sh /path/to/service --auto-publish-deps -- compile
# Compile several projects
bash <skill_dir>/scripts/sbt_build.sh /path/to/svc-a /path/to/svc-b -- compile
# Compile all workspace projects in dependency order
bash <skill_dir>/scripts/sbt_build.sh --all -- compile
# Compile + test everything with auto-publish
bash <skill_dir>/scripts/sbt_build.sh --all --auto-publish-deps -- test
# Publish locally at a specific version
bash <skill_dir>/scripts/sbt_build.sh /path/to/library --artifact-version 0.532.0 -- publishLocalUse the exact scoped project ID reported by sbt_status.sh for subproject names. In multi-project builds the ID may differ from the published artifact name (e.g. myModule vs my-module).
rootPaths auto-detection: When --sbt-env dev is requested but the project has rootPaths/remoteCache settings AND external ProjectRef entries, the skill auto-falls back to non-dev mode. No manual intervention needed.
Coverage mode: --coverage keeps the user command as a normal SBT argument, but wraps it with setup/teardown commands in the same session: it disables maybePullRemoteCache, clears target/scala-*, scopes clean/coverageReport when a subproject is specified, and forces Test / fork := false so scoverage measurements are written in-process.
sbt_status.sh — Discover dependencies and workspace state
Single command for all discovery and diagnostics.
bash <skill_dir>/scripts/sbt_status.sh <project-dir> [options]| Option | Description |
--workspace | Full workspace preflight + dependency graph |
--plan-change <repo> | Plan impact of a cross-repo change |
--verify <artifact> | Verify artifact resolution source |
--workspace-dir <dir> | Override workspace directory |
--json | JSON output (workspace and plan-change modes) |
Default (no flags): Discovers the project's cross-repo dependencies, workspace artifacts, transitive deps, dirty repo warnings, version variables, and build configuration.
Examples:
# What does this project depend on?
bash <skill_dir>/scripts/sbt_status.sh /path/to/service
# Full workspace state: preflight + all repos + dependency graph
bash <skill_dir>/scripts/sbt_status.sh /path/to/service --workspace
# What happens if I change commons and rebuild service-a?
bash <skill_dir>/scripts/sbt_status.sh /path/to/service-a --plan-change /path/to/commons
# Where is this artifact being resolved from?
bash <skill_dir>/scripts/sbt_status.sh /path/to/service --verify platform-commonssbt_refresh.sh — Fix stale state
Clears caches, publishes upstream deps, and rebuilds.
bash <skill_dir>/scripts/sbt_refresh.sh <project-dir> [options]| Option | Description |
--publish-upstreams | Publish upstream workspace deps in dependency order first |
--artifact-version <ver> | Version for publishLocal |
--artifact <name> | Artifact name for targeted cache clearing |
--version <ver> | Version for targeted cache clearing |
--clean-target | Delete project target/ directory (also kills SBT server) |
--kill-server | Explicitly shut down the SBT server for this project |
--rebuild | Rebuild with compile after refresh |
--rebuild-arg <arg> | Explicit SBT arg for rebuild (overrides --rebuild) |
--workspace-dir <dir> | Override workspace directory |
--dry-run | Show what would be done without doing it |
Examples:
# Full upstream publish + cache clear + rebuild (most common for cross-repo changes)
bash <skill_dir>/scripts/sbt_refresh.sh /path/to/service --publish-upstreams --clean-target --rebuild
# Clear caches for a specific artifact and rebuild
bash <skill_dir>/scripts/sbt_refresh.sh /path/to/service --artifact my-lib --version 0.532.0 --clean-target --rebuild
# Dry run to see what would happen
bash <skill_dir>/scripts/sbt_refresh.sh /path/to/service --publish-upstreams --dry-runsbt_reset.sh — Wipe isolated cache and return to clean state
Removes all local publishes and cached artifacts so builds resolve from remote again.
bash <skill_dir>/scripts/sbt_reset.sh [options]| Option | Description |
--local-only | Only wipe local publishes, keep downloaded cache |
--dry-run | Show what would be deleted without deleting |
Examples:
# Full reset — everything from remote again
bash <skill_dir>/scripts/sbt_reset.sh
# Only wipe local publishes
bash <skill_dir>/scripts/sbt_reset.sh --local-only
# Preview what would be deleted
bash <skill_dir>/scripts/sbt_reset.sh --dry-runDecision Table
| Scenario | Command |
| Edit target service code, compile | sbt_build.sh <target> -- compile |
| Edit target service code, test | sbt_build.sh <target> -- test |
| Test a specific subproject | sbt_build.sh <target> -- "<subproject> / test" |
| Collect coverage for a specific subproject test | sbt_build.sh <target> --coverage -- "<subproject> / testOnly <suite>" |
| Check what this project depends on | sbt_status.sh <target> |
| Check full workspace state | sbt_status.sh <target> --workspace |
| Upstream library changed, rebuild downstream | sbt_refresh.sh <downstream> --publish-upstreams --clean-target --rebuild |
| Dependency declarations changed in build.sbt | sbt_status.sh <target> then sbt_build.sh <target> -- compile |
| Downstream still sees old artifact | sbt_refresh.sh <downstream> --artifact <name> --version <ver> --clean-target --rebuild |
| Plan a cross-repo change | sbt_status.sh <target> --plan-change <changed-repo> |
| Verify artifact resolution source | sbt_status.sh <target> --verify <artifact-name> |
| Compile with auto-fix for missing deps | sbt_build.sh <target> --auto-publish-deps -- compile |
| Compile several specific projects | sbt_build.sh <proj-a> <proj-b> -- compile |
| Compile all workspace projects | sbt_build.sh --all -- compile |
| Compile + test everything | sbt_build.sh --all --auto-publish-deps --continue-on-error -- test |
| Reset to clean state (resolve from remote) | sbt_reset.sh |
| Reset only local publishes | sbt_reset.sh --local-only |
| SBT returns stale test results after edits | sbt_build.sh <target> --fresh -- test |
| SBT server is stuck/corrupted | sbt_refresh.sh <target> --kill-server --clean-target --rebuild |
Exit Codes
| Code | Meaning |
0 | SUCCESS — build/test completed without errors |
1 | SBT error — compilation failure, test failure, or dependency resolution error |
2 | Infrastructure error — lock contention, missing Java, missing config, or no test reports |
Important rules
- Use
sbt_build.shfor all compile, test, and publishLocal flows. It preserves full logs, auto-checks deps, and auto-parses test reports. - All skill-driven SBT runs use the isolated cache at
~/.sbt-build-cache(Ivy, Coursier, SBT boot, SBT global) to avoid contaminating system caches. - Use
sbt_status.shbefore guessing dependency order. Do not guess publish order. - Show the dry-run plan before running
sbt_refresh.shwith--publish-upstreamsfor the first time in a session. - JUnit XML is the source of truth for test results. Console success only means SBT finished.
Parallel worktree builds
All SBT caches (Ivy, Coursier, SBT boot, SBT global) are isolated inside
SBT_BUILD_CACHE_ROOT (default: ~/.sbt-build-cache). For parallel builds
across git worktrees, set a different cache root per worktree:
# In worktree 1
export SBT_BUILD_CACHE_ROOT=~/.sbt-build-cache/wt-main
# In worktree 2
export SBT_BUILD_CACHE_ROOT=~/.sbt-build-cache/wt-feature-xEach worktree gets its own publishLocal artifacts, Coursier downloads, and SBT boot files. No lock contention or cache corruption between parallel builds.
Note: The first build in a new cache root is slower due to cold Coursier and SBT boot caches. Subsequent builds are fast.
Error handling
| Error | Cause | Fix |
Java <version> not found | Requested JDK is not installed | Update .sbt-workspace.conf or install the matching JDK |
python3 is required | Report parsing runtime missing | Install python3 |
Credentials file does not exist | Private resolver credentials missing | Create ~/.ivy2/.credentials |
cannot be mapped using the root paths | Local publishes conflict with root-path/remote-cache settings | Auto-detected by sbt_build.sh — falls back to non-dev mode automatically |
MISSING: <artifact> @ <version> | Workspace dep not in isolated cache | Use --auto-publish-deps on sbt_build.sh, or run sbt_refresh.sh --publish-upstreams |
STALE: <artifact> @ <version> | Upstream workspace repo on a feature branch with no local publish | Warning only. Republish upstream if you hit runtime errors |
NoSuchMethodError / NoSuchFieldError | Stale artifact on classpath | sbt_refresh.sh <project> --publish-upstreams --clean-target --rebuild |
not a valid command | Wrong scoped SBT command | Run sbt_status.sh <project> and use a listed subproject name |
No test-reports directory found | Tests did not generate XML reports | Run tests first via sbt_build.sh |
CRASH (no JUnit XML produced) | Test suite crashed before writing XML | Check SBT log for ClassCastException, OutOfMemoryError, or initialization errors |
Stale lock file detected | A previous build was killed leaving a lock | Auto-cleaned — no action needed |
WARNING: Log file is from a previous run | SBT did not execute (likely lock contention) | Check for concurrent builds or stale SBT server |
Troubleshooting
| Problem | Fix |
| Console output truncated | sbt_build.sh saves full logs — inspect the log file path in the summary |
| Downstream still sees old artifact | sbt_refresh.sh <project> --artifact <name> --clean-target --rebuild |
| Unsure if a change affects the target | sbt_status.sh <target> --plan-change <changed-repo> |
| Need the full workspace dependency order | sbt_status.sh <project> --workspace |
NoSuchMethodError at runtime | sbt_refresh.sh <project> --publish-upstreams --clean-target --rebuild |
| Upstream repo on a feature branch | sbt_status.sh <project> --workspace to see branch alignment |
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
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.

