Atlas helps Erlang developers refactor legacy modules in 2026 by providing a robust, terminal-native AI coding agent that integrates directly with the Erlang toolchain, including `rebar3 eunit` for testing and `erlfmt` for formatting. This ensures structural changes do not alter behavior or break existing callers, a critical concern for Erlang/OTP systems.
How Atlas maps Erlang module dependencies for safe refactoring
Atlas, in 2026, uses its `lsp` tool to map the public surface of Erlang modules, identifying all exported symbols and their callers. This process is crucial for understanding a module's impact before any changes, preventing silent breakage in complex Erlang/OTP systems.
Refactoring an Erlang module carries the inherent risk of introducing silent breakage at unknown callsites. Atlas mitigates this by leveraging its `lsp` tool, which performs a `documentSymbol` operation to identify all public functions and attributes within an Erlang module. Following this, Atlas executes `findReferences` on each exported symbol. This comprehensive enumeration of every callsite provides a complete map of the module's dependencies, ensuring that all affected areas are known before any structural modifications begin. For Erlang developers, this means Atlas can identify all invocations of a `gen_server` callback or a supervisor function, which is vital for maintaining the integrity of hot code loading and supervision trees. This proactive mapping is a cornerstone of safe refactoring in 2026, especially within `rebar3` managed projects.
Pinning Erlang module behavior with rebar3 eunit before refactoring
Before any structural changes, Atlas ensures behavioral integrity by running existing Erlang tests with `rebar3 eunit`. This establishes a green baseline, a critical step in 2026 for any refactoring effort, confirming the module's current functionality.
The first concrete step in any safe refactoring workflow with Atlas is to pin the existing behavior of the Erlang module. Atlas achieves this by using its `bash` tool to execute the project's test suite with the command `rebar3 eunit`. This command runs all EUnit tests defined within your Erlang application, typically found in the `test/` directory. By recording a 'green baseline' - a successful test run with no failures - Atlas establishes a verifiable benchmark for the module's current behavior. This baseline is paramount: it provides a clear, objective measure against which all subsequent changes can be validated. If the tests pass before refactoring, any failures after a change indicate a regression, allowing developers to immediately identify and correct behavioral deviations in their Erlang code.
Applying structural changes to Erlang code with Atlas's apply_patch
Atlas employs its `apply_patch` tool to restructure Erlang modules, ensuring changes are applied precisely. This tool, available in 2026, anchors on context lines and refuses to apply against a drifted file, preventing unintended modifications to your Erlang source.
for making structural changes to Erlang source files, Atlas utilizes its `apply_patch` tool for maximum precision and safety. Unlike simple find-and-replace operations, `apply_patch` works by seeking each hunk's context and `old_lines` within the target file. This means that the patch is not applied blindly; it verifies that the surrounding code matches the expected context before making any modifications. If the Erlang file has drifted - meaning the context or `old_lines` no longer match - `apply_patch` will fail with a 'Failed to find context' error. This robust mechanism prevents unintended or incorrect changes from being applied to your `.erl` files, providing a crucial safety net during complex refactoring tasks in 2026, especially within `rebar3` managed projects.
Verifying Erlang refactors incrementally with rebar3 eunit
After each structural change, Atlas re-runs the Erlang tests using `rebar3 eunit` via the `bash` tool. This incremental verification, a standard practice in 2026, immediately catches any regressions introduced by a specific hunk, maintaining code integrity.
A core principle of safe refactoring with Atlas is continuous, incremental verification. Instead of making all changes and then running tests once at the end, Atlas re-runs the Erlang test suite with `rebar3 eunit` after each individual hunk of changes lands. This is facilitated by the `bash` tool, which executes the `rebar3 eunit` command. This rapid feedback loop is invaluable for Erlang developers: if a test fails, it immediately points to the specific structural change that introduced the regression. This approach significantly reduces debugging time and complexity, ensuring that the module's behavior remains consistent throughout the refactoring process, especially when dealing with sensitive components like `gen_server` modules or `relx` release configurations.
Tracking remaining Erlang callsites with Atlas's todowrite
Atlas uses its `todowrite` tool to track remaining callsites during an Erlang module refactor, ensuring no partial migrations are mistaken for finished work. This systematic approach is essential for complex projects in 2026, providing clear visibility into outstanding tasks.
Refactoring often involves migrating multiple callsites across various modules. To prevent a partially migrated Erlang module from being mistaken for a finished one, Atlas employs its `todowrite` tool. After identifying all callsites with `lsp findReferences`, Atlas can use `todowrite` to maintain a clear, actionable list of remaining references that still need to be updated or migrated. This ensures that every identified callsite is addressed, providing a comprehensive and auditable record of the refactoring progress. For Erlang developers, this means a clear path to completion, preventing the deployment of incomplete changes that could lead to runtime errors or unexpected behavior in a live Erlang/OTP system.
Ensuring Erlang style and safety with Atlas's review process
Atlas integrates `erlfmt` and a robust review process to maintain Erlang code style and ensure safety during refactoring. Every Atlas tool call is permission-gated, and all file edits generate a unified diff for approval in 2026, providing full control.
Safety and style are paramount in Erlang development, and Atlas incorporates multiple layers to ensure both. Every Atlas tool call, including `lsp`, `apply_patch`, and `bash`, is permission-gated against allow, ask, and deny rules, giving developers granular control over agent actions. Atlas drafts its refactoring plan in a read-only plan agent, asking for approval before switching to a build agent to execute changes. Crucially, for every file edit, Atlas computes a unified diff and surfaces it for explicit approval before writing any changes to disk. This allows Erlang developers to review every line modified. Furthermore, Atlas can run `erlfmt` on touched modules, ensuring that all changes adhere to the project's established Erlang code style, making the diff clean and consistent with existing `rebar3` project standards.
Step by step
- 01Run `atlas` in your Erlang application directory, ensuring `rebar.config` and `src/*.app.src` are present for proper project context.
- 02Ask Atlas to map the module's public surface using the `lsp` tool's `documentSymbol` operation, then `findReferences` for each exported symbol to enumerate all callers.
- 03Pin the module's current behavior by instructing Atlas to run existing Erlang tests with `bash` using `rebar3 eunit`, recording the green baseline.
- 04Direct Atlas to restructure the module using `apply_patch`, which anchors on context lines and fails with 'Failed to find context' if the Erlang file has drifted.
- 05After each `apply_patch` hunk lands, have Atlas re-run the tests with `bash` using `rebar3 eunit` to immediately verify that no regressions were introduced.
- 06Use Atlas's `todowrite` tool to track any remaining callsites that need migration, ensuring a complete and verifiable refactor of the Erlang module.
- 07Approve the unified diffs presented by Atlas for each file edit, ensuring all changes align with your intent before they are written to your Erlang codebase.
- 08Let Atlas run `erlfmt` on the touched Erlang modules to maintain consistent code style, ensuring the final diff matches project formatting standards.
Frequently asked questions
- How does Atlas ensure my Erlang refactor doesn't break existing callers?
- Atlas uses its `lsp` tool to perform `findReferences` on every exported symbol of your Erlang module, enumerating all callsites before any changes are made. This comprehensive mapping prevents silent breakage by identifying all dependencies.
- Can Atlas work with my existing `rebar3` project structure?
- Yes, Atlas is designed to integrate direct with Erlang/OTP systems built with `rebar3`. It operates within applications containing `rebar.config` and `src/*.app.src` files, understanding your project's layout and dependencies.
- How does Atlas handle Erlang test execution during a refactor?
- Atlas uses its `bash` tool to run your existing Erlang tests with `rebar3 eunit`. It first establishes a green baseline and then re-runs these tests incrementally after each structural change to immediately detect regressions, ensuring behavioral integrity.
- What if my Erlang module's file changes while Atlas is working?
- Atlas's `apply_patch` tool is designed for safety. It anchors on context lines and `old_lines` for each hunk. If the Erlang source file has drifted, `apply_patch` will fail with 'Failed to find context', preventing incorrect modifications.
- Does Atlas help maintain Erlang code style during refactoring?
- Yes, Atlas integrates with `erlfmt`. After making changes, Atlas can run `erlfmt` on the touched Erlang modules, ensuring that the diff matches your project's established code style and formatting standards, maintaining consistency.
- How does Atlas ensure I review changes before they are applied to my Erlang codebase?
- Atlas operates with a permission-gated system for all tool calls. It drafts a plan in a read-only agent and, crucially, computes a unified diff for every file edit, which it surfaces for your approval before writing any changes to your Erlang files.
- Can Atlas help me track remaining work on a large Erlang refactor?
- Absolutely. Atlas uses its `todowrite` tool to track remaining callsites that need migration. This ensures that a partially migrated Erlang module is never mistaken for a finished one, providing a clear roadmap for completion and preventing incomplete deployments.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Refactor a Legacy Module with Atlas in 2026
How to refactor a legacy module with Atlas in 2026: findReferences maps every callsite, apply_patch refuses to apply against a drifted file, and bash proves behavior.
Atlas for Erlang in 2026
Atlas is a terminal-native AI coding agent for Erlang/OTP in 2026. Run it in an app with a rebar.config, map supervisors and gen_server modules, review every diff.
Upgrade a Dependency and Fix Breakage in Erlang with Atlas in 2026
In 2026, Erlang developers use Atlas to upgrade dependencies like `rebar3` packages, automatically fixing compile and test failures. Atlas leverages `rebar3 eunit` and `erlfmt` for a streamlined workflow.
Run Atlas Headless in CI in Erlang with Atlas in 2026
Automate Erlang development in CI/CD with Atlas. Run Atlas headless, integrate with rebar3 and erlfmt, and get machine-readable output for Erlang/OTP projects in 2026.
Self-review Your Working Diff Before Committing in Erlang with Atlas in 2026
Erlang developers in 2026 use Atlas to self-review uncommitted diffs, catching mistakes before CI. Leverage rebar3, erlfmt, and eunit with AI assistance.
Add a Regression Test for a Bug Fix in Erlang with Atlas in 2026
Lock in Erlang bug fixes with Atlas in 2026. Learn to write failing regression tests using rebar3 eunit, apply fixes, and confirm passes, all with Atlas's terminal-native AI agent.
Run the Erlang Test Suite and Triage Failures with Atlas in 2026
Erlang developers in 2026 use Atlas to efficiently triage rebar3 eunit test failures, transforming extensive red output into a prioritized list of distinct root causes for rapid resolution.
Onboard to an unfamiliar codebase in Erlang with Atlas in 2026
Erlang developers in 2026 can use Atlas to quickly build a mental model of unfamiliar rebar3 projects. Understand supervision trees, gen_server modules, and application structure without reading every file, leveraging