Migrating a deprecated API across every callsite in a Lua codebase is a critical task that Atlas streamlines by integrating directly with your existing `busted`, `luarocks`, and `stylua` toolchain. Atlas ensures no caller is missed by front-loading enumeration with `lsp` and `grep`, then safely applies changes with `apply_patch` while verifying each step with your `busted` tests, all within your terminal.
How Atlas finds all deprecated Lua API calls
Identifying every callsite of a deprecated Lua API is the crucial first step in any migration, preventing missed references that could lead to runtime errors in 2026. Atlas achieves this comprehensive enumeration by combining the `lsp` tool's `findReferences` operation with a `grep` cross-check.
Atlas begins by leveraging its `lsp` tool to query the language server for all references to the deprecated symbol. For instance, if you're deprecating `old_module.legacy_function()`, Atlas will use `lsp findReferences old_module.legacy_function` to get a complete list of static calls. This is particularly effective for Lua codebases where modules are well-defined and `luarocks` manages dependencies. However, Lua's dynamic nature means some calls might be string-based or constructed at runtime. To catch these, Atlas performs a secondary `grep` search across your `.lua` modules and `rockspec` files, ensuring no dynamic usages like `local func = require("old_module")["legacy_function"]` are overlooked. This dual approach guarantees a robust and complete enumeration, forming the foundation for a safe migration.
How Atlas migrates Lua callsites with context-aware patches
Migrating each deprecated Lua API callsite requires precision to avoid introducing new bugs, a task Atlas handles with its `apply_patch` tool. This tool ensures changes are applied safely by seeking the exact context and old lines, failing explicitly rather than misapplying to a drifted file in 2026.
Once all callsites are identified, Atlas creates a `todowrite` entry for each, making partial progress visible and preventing any silent skips. For each entry, Atlas's build agent drafts a specific change, such as replacing `old_module.legacy_function(arg1)` with `new_module.modern_function(arg1)`. The `apply_patch` tool then attempts to apply this change. Crucially, `apply_patch` is context-anchored; it requires the exact `old_lines` and surrounding context to match before applying the `new_lines`. If the file has drifted since the initial enumeration (e.g., another developer committed changes), `apply_patch` will throw a "Failed to find expected lines" error. This prevents incorrect modifications and ensures that every change to your `.lua` files is precise and intentional, maintaining the integrity of your codebase.
Verifying Lua API migrations with busted and stylua
Ensuring the correctness and style of migrated Lua code is paramount, which Atlas achieves by integrating directly with your `busted` test runner and `stylua` formatter. After each file modification, Atlas runs affected tests via `bash`, marking a `todowrite` entry complete only if all 100% of tests pass.
Atlas's workflow prioritizes safety and correctness. After `apply_patch` modifies a `.lua` file, Atlas immediately runs the relevant tests using the `bash` tool. For a typical Lua project, this means executing `busted spec/path/to/affected_module_spec.lua` or a broader `busted` command. Atlas presents a permission prompt before running `busted`, giving you control. Only if these tests pass successfully is the corresponding `todowrite` entry marked as completed. This iterative testing approach catches regressions early, preventing a cascade of errors. Furthermore, before committing any changes, Atlas can run `stylua` over the touched modules, ensuring that the new code adheres to your project's formatting standards, such as those defined in a `.stylua.toml` file, maintaining code consistency across your `luarocks`-managed project.
Safe review and rollback for Lua API changes
Atlas provides robust mechanisms for reviewing and rolling back changes to your Lua codebase, ensuring every migration is transparent and reversible. Before writing any file, Atlas computes a unified diff, presenting it for your approval, and snapshots changes as git patches for easy rollback, even in 2026.
Transparency is a core principle of Atlas. For every proposed edit to a `.lua` file, Atlas computes a unified diff, which it surfaces in its terminal-native TUI for your explicit approval. This allows you to review the exact changes, line by line, before they are written to disk. Atlas also integrates deeply with Git. It reads your current branch, status, and diffs, and can stage and create commits on your behalf, always behind a permission prompt. Crucially, Atlas snapshots file changes as Git patches. This means that even if you approve a change and later discover an issue, you can easily diff the edits or roll them back using standard Git commands, providing a safety net for complex API migrations in your `luarocks`-based projects.
Step by step
- 01Initialize Atlas in your Lua project root: `atlas init` where your `.lua` modules and `rockspec` files reside.
- 02Enumerate all calls to the deprecated Lua API, e.g., `old_module.legacy_function`, using `atlas lsp findReferences old_module.legacy_function` and cross-check with `atlas grep "legacy_function"` for dynamic usages.
- 03Create a `todowrite` entry for each identified callsite: `atlas todowrite "Migrate call to old_module.legacy_function in file.lua"`.
- 04For each `todowrite` entry, instruct Atlas to draft and apply the migration, e.g., `atlas apply_patch --file path/to/file.lua --old-lines "old_module.legacy_function(arg)" --new-lines "new_module.modern_function(arg)"`.
- 05After each `apply_patch`, run the affected `busted` tests via `atlas bash "busted spec/path/to/file_spec.lua"` and confirm they pass before marking the `todowrite` entry complete.
- 06Once all callsites are migrated, run `atlas stylua --check path/to/file.lua` over the modified files to ensure formatting compliance, then `atlas stylua path/to/file.lua` to apply fixes.
- 07Perform a final `atlas grep "legacy_function"` across your codebase to confirm zero remaining hits of the deprecated symbol.
- 08Delete the old Lua implementation file, e.g., `rm lua/old_module.lua`, and update any `rockspec` files if necessary.
Frequently asked questions
- How does Atlas handle dynamic Lua API calls during migration?
- Atlas addresses dynamic Lua API calls by combining `lsp`'s static analysis with a `grep` cross-check. While `lsp findReferences` catches most calls, `grep` scans `.lua` files and `rockspec`s for string-based or runtime-constructed usages, ensuring comprehensive enumeration.
- Can Atlas integrate with my existing busted test suite for Lua?
- Yes, Atlas integrates directly with your `busted` test suite. After each file modification, Atlas uses its `bash` tool to run `busted` tests, prompting for permission. A `todowrite` entry is marked complete only if all tests pass, ensuring no regressions.
- What if my Lua file changes while Atlas is migrating an API?
- If a Lua file changes (drifts) during migration, Atlas's `apply_patch` tool will detect it. `apply_patch` is context-anchored and requires exact `old_lines` to match. If they don't, it throws a "Failed to find expected lines" error, preventing misapplication and preserving file integrity.
- Does Atlas support Lua package managers like luarocks?
- Yes, Atlas is designed to work direct with `luarocks`. It reads your `rockspec` files and resolves dependencies managed by `luarocks`, ensuring its code index and `lsp` operations accurately reflect your project's structure and available modules.
- How does Atlas ensure my Lua code remains formatted correctly after migration?
- Atlas integrates with `stylua`, the standard Lua formatter. After modifying `.lua` modules, Atlas can run `stylua` over the touched files, either to check for compliance or to automatically apply formatting fixes, ensuring your codebase maintains consistent style.
- Can I review changes before Atlas writes them to my Lua files?
- Absolutely. Atlas computes a unified diff for every proposed file edit and surfaces it in its terminal-native TUI for your explicit approval. This allows you to review all changes to your `.lua` files line by line before they are written, ensuring full transparency.
- How can I roll back a Lua API migration if something goes wrong?
- Atlas snapshots all file changes as Git patches. This deep integration with Git means that every edit is easily reversible. You can use standard Git commands to diff the changes or roll back specific edits, providing a robust safety net for your Lua codebase.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Migrate a Deprecated API Across Every Callsite with Atlas (2026 Workflow)
How to migrate a deprecated API across every callsite with Atlas in 2026: the lsp tool's findReferences enumerates callers, todowrite tracks them, apply_patch migrates each one.
Document a module with a README in Lua with Atlas in 2026
Generate accurate README documentation for your Lua modules in 2026 using Atlas. Leverage `luarocks`, `busted`, and `stylua` to describe what your code actually does today, not what it was supposed to do a year ago.
Extract a Shared Helper from Duplicated Lua Code in 2026 with Atlas
In 2026, Lua developers use Atlas to find and refactor duplicated logic into shared, tested helpers. Leverage `busted`, `luarocks`, and `stylua` for robust code quality and consistency.
Run the test suite and triage the failures in Lua with Atlas in 2026
Streamline Lua test triage in 2026. Use Atlas to run `busted` suites, group failures by root cause, and prioritize fixes, transforming a wall of red output into actionable tasks for Lua developers.
Debug a single failing test in Lua with Atlas in 2026
In 2026, Lua developers use Atlas to efficiently debug single failing `busted` tests. Learn how Atlas leverages `luarocks` and `stylua` to pinpoint and fix code issues in your Lua projects.
Research a Third-Party API Before Integrating It in Lua with Atlas in 2026
For Lua developers in 2026, Atlas streamlines third-party API research and integration. Leverage `websearch` and `webfetch` for current docs, then integrate with `luarocks`, `busted`, and `stylua`.
Review a Pull Request in Lua with Atlas in 2026
In 2026, Atlas empowers Lua developers to thoroughly review pull requests by analyzing full file context, checking for breaking changes with LSP, and running `busted` tests.
Diagnose a Hanging or Long-Running Lua Command with Atlas in 2026
In 2026, Lua developers use Atlas to quickly diagnose whether a `luarocks` build or `busted` test run is genuinely slow or silently blocked on interactive input, getting unstuck faster.