To run an Atlas session non-interactively in a Scala CI pipeline and retrieve machine-readable output, Scala developers in 2026 can leverage the `atlas run` command with the `--format json` flag. This approach integrates direct with existing `sbt` projects, allowing Atlas to refactor code, add `ScalaTest` cases, and interact with your codebase without human intervention, providing structured event streams for subsequent pipeline steps.
How to Invoke Atlas Headless in Scala CI Pipelines
In 2026, Scala developers can initiate an Atlas session non-interactively within a CI pipeline using the `atlas run` command. This command's default mode sends a single prompt, streams events to stdout, and exits when the session goes idle, making it ideal for automated `sbt` project tasks.
Atlas is designed for non-interactive execution in CI environments, particularly for Scala projects managed by `sbt`. The core command, `atlas run`, allows developers to provide a single prompt as an argument, initiating an agent session that operates without requiring human input. For instance, a Scala CI job might invoke `atlas run "Add a new ScalaTest case for the `UserService` trait in `src/test/scala/com/example/UserServiceSpec.scala`"`. This command streams all session events directly to stdout. Crucially, to enable subsequent pipeline steps to process Atlas's output programmatically, the `--format json` flag must be used. This ensures that instead of human-readable prose, a structured JSON event stream is emitted, which can then be parsed by other tools or scripts in the Scala CI workflow. This capability is vital for automating tasks like adding new `ScalaTest` cases or refactoring Scala code within a `build.sbt` project.
Configuring Atlas for Scala Tooling and Permissions in CI
For Atlas to operate effectively in a headless Scala CI environment in 2026, explicit configuration of the active model and pre-approval of necessary tools are paramount. Atlas connects to Model Context Protocol servers and exposes their tools, requiring permissions for actions like `bash`, `read`, `edit`, and `todowrite`.
A critical step for running Atlas headless in a Scala CI pipeline is to explicitly set the model using the `provider/model` format, as the GitHub path requires this specific structure. For example, `atlas run --model "ollama/codellama:7b" "Refactor the `OrderProcessor` implicit class to a typeclass in `src/main/scala/com/example/OrderProcessor.scala`"`. Furthermore, because a headless run has no human to answer `ask` prompts, all tools the job needs must be pre-approved through the permission configuration. Atlas's permission-gated tool calls ensure safety, but in CI, these gates must be set to `allow`. For Scala projects, Atlas frequently uses `bash` to execute commands like `sbt compile`, `sbt test` (for `ScalaTest`), or `scalafmt` for code formatting. It also uses `read` to understand Scala traits, implicits, and `sbt` modules, `edit` to modify Scala source files, and `todowrite` to manage tasks. Without these permissions explicitly granted, Atlas will halt, awaiting an approval that will never come in a non-interactive setting.
Managing Atlas Sessions and Code Changes in Scala Pipelines
In 2026, Scala CI pipelines can manage complex Atlas workflows by resuming or forking prior sessions, enabling multi-stage operations. Atlas snapshots file changes as git patches and computes a unified diff for every file edit, surfacing these for approval before writing to the `build.sbt` project.
Atlas provides robust mechanisms for managing agent sessions across multiple CI pipeline steps, which is particularly useful for iterative development on Scala projects. The `--continue` and `--session` flags allow a pipeline step to resume a prior Atlas run, building upon its context and progress. Alternatively, `--fork` can be used to create a new session based on an existing one, enabling parallel experimentation or branching workflows. For instance, one CI job might use Atlas to refactor a Scala trait to a typeclass, and a subsequent job could resume that session to add `ScalaTest` cases for the newly refactored code. Atlas ensures transparency and safety by computing a unified diff for every file edit it proposes, such as changes to `src/main/scala` files or `src/test/scala` `ScalaTest` definitions. These diffs are surfaced for approval before writing, and Atlas also snapshots file changes as git patches, allowing edits to be easily reviewed and rolled back if necessary. Atlas's ability to read git branches, status, and diffs, and even stage and create commits, provides comprehensive version control integration for Scala development.
Step by step
- 01Prepare your Scala project for Atlas indexing: Ensure your `sbt` project has a `build.sbt` file and Atlas can access your Scala source code, including traits, implicits, and `sbt` modules, for accurate indexing via AST declarations.
- 02Configure Atlas permissions for headless operation: Grant explicit `allow` permissions for the `bash`, `read`, `edit`, and `todowrite` tools in your Atlas configuration, as a headless CI run cannot respond to `ask` prompts.
- 03Invoke Atlas with a specific prompt and JSON output: Execute `atlas run "Add a new ScalaTest case for the `OrderService` in `src/test/scala/com/example/OrderServiceSpec.scala`" --format json` to initiate a non-interactive session and receive machine-readable event streams.
- 04Specify the Atlas model explicitly: Include the `--model "provider/model"` flag, for example, `--model "ollama/codellama:7b"`, to ensure the correct model is used for your Scala code generation and refactoring tasks.
- 05(Optional) Resume or fork a previous Atlas session: Use `atlas run --continue <session_id>` or `atlas run --fork <session_id>` in a subsequent CI step to build upon prior work, such as adding `scalafmt` rules after a refactoring.
- 06Parse the JSON event stream for pipeline integration: Process the `--format json` output in a downstream CI step to extract relevant information, such as proposed file changes or `ScalaTest` results, for automated checks or reporting.
- 07Review and apply generated code changes: Examine the unified diffs and git patches generated by Atlas for changes to Scala files or `ScalaTest` definitions, ensuring they meet your project's quality standards before merging.
Frequently asked questions
- How do I run `ScalaTest via sbt test` with Atlas in CI?
- Atlas can execute `sbt test` commands via its `bash` tool. To enable this in a headless CI run, ensure the `bash` tool has `allow` permissions configured. Atlas can then generate or modify `ScalaTest` cases and trigger the tests.
- Can Atlas refactor Scala code to typeclasses in a headless CI job?
- Yes, Atlas can refactor Scala code to typeclasses. By providing a prompt like "Refactor `X` to a typeclass," Atlas will draft a plan, use its `edit` tool to modify Scala source files, and present a diff, all within a non-interactive CI environment.
- What Scala-specific files does Atlas index for code understanding?
- Atlas indexes Scala code by AST declarations using tree-sitter, not blind line windows. This includes understanding `build.sbt` configurations, Scala traits, implicits, and `sbt` modules, providing a deep contextual awareness of your project.
- How does Atlas ensure safety when making changes to Scala code in CI?
- Atlas ensures safety through permission-gated tool calls and by computing a unified diff for every file edit. It also snapshots file changes as git patches, allowing for review and rollback, even in a headless CI environment where tools are pre-approved.
- How do I specify the model for Atlas when running headless in a Scala project?
- When running `atlas run` headless, you must explicitly specify the model using the `--model "provider/model"` flag, for example, `--model "ollama/codellama:7b"`, as the GitHub path requires this format.
- Can Atlas format Scala code using `scalafmt` in a CI pipeline?
- Yes, Atlas can invoke `scalafmt` through its `bash` tool. By configuring `allow` permissions for `bash`, Atlas can run `scalafmt` on your Scala codebase as part of a CI step, ensuring consistent code style.
- How can I debug an Atlas headless session that failed in my Scala CI?
- When `atlas run` is executed with `--format json`, it streams detailed events to stdout. By capturing and analyzing this JSON output, Scala developers can inspect the agent's actions, tool calls, and any errors encountered, aiding in debugging failed CI runs.
- Does Atlas support local Ollama embeddings for Scala projects in CI?
- Yes, Atlas can build its code index with local Ollama embeddings, keeping your Scala code off third-party servers. This capability is fully supported in CI environments, enhancing data privacy for your `sbt` projects.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Run Atlas Headless in CI with Atlas (2026 Workflow)
How to run Atlas headless in CI in 2026: atlas run sends one prompt and exits when the session goes idle, with --format json, --command, and --continue for pipeline steps.
Atlas for Scala in 2026
Atlas is a terminal-native AI coding agent for Scala in 2026. Run it in a project with a build.sbt, let it read your traits and implicits, and approve every diff.
Extract a shared helper from duplicated code in Scala with Atlas in 2026
Refactor Scala code efficiently in 2026 by extracting shared helpers from duplicated logic using Atlas. Leverage semantic search, `sbt test`, and `scalafmt` for safe, reviewable changes.
Automate GitHub issue and pull request triage in Scala with Atlas in 2026
Automate GitHub issue and pull request triage for Scala projects in 2026 using Atlas. Learn how Scala developers can integrate Atlas with sbt and scalafmt for safe, AI-driven workflow automation.
Write Unit Tests for Untested Code in Scala with Atlas (2026)
How to add ScalaTest coverage to an untested Scala module with Atlas in 2026: enumerate symbols with lsp documentSymbol, copy repo conventions, then run sbt test.
Locate where a behavior is implemented in Scala with Atlas (2026)
Find the Scala file and symbol behind a behavior in 2026 with Atlas: codebase_search for meaning, grep through ripgrep for exact text, and the lsp tool for symbols.
Plan a Multi-File Change Before Editing in Scala With Atlas (2026)
How to plan a multi-file Scala change before editing with Atlas in 2026: the plan agent denies edit for every path except .atlas/plans/*.md until you approve.
Review a Pull Request in Scala with Atlas in 2026
Streamline Scala pull request reviews in 2026 with Atlas. Leverage sbt, ScalaTest, and scalafmt for deep context, catching bugs a line-by-line diff misses.