Atlas renames a function, class, or constant across your entire Bun project by combining precise language server protocol (LSP) data with robust text search, ensuring every usage is updated, even in comments or documentation. It leverages Bun's integrated toolchain, including `bun test` for rapid verification and `bun fmt` for consistent formatting, to deliver a verified and clean refactor.
How Atlas renames symbols in Bun projects
Atlas renames symbols in Bun projects by orchestrating a multi-stage process that combines the precision of language servers with the breadth of text search. This ensures that by 2026, every instance of a symbol, from its declaration to its most obscure comment reference, is accurately updated, preventing common refactoring errors.
When you instruct Atlas to rename a symbol within your Bun codebase, it initiates a sophisticated workflow. First, Atlas uses the `lsp` tool to query the language server for the symbol's authoritative reference set. This step is crucial for Bun projects, as it accurately identifies all code locations where the function, class, or constant is used, respecting the type system and scope. This initial pass captures all programmatic usages, ensuring that your `Bun.serve` handlers, `Bun.file` operations, or custom utility functions are correctly identified. Following the LSP-driven identification, Atlas employs its `grep` tool to search for the old symbol name across the entire repository. This second pass is vital for catching occurrences that the language server might miss, such as references in `README.md` files, inline comments, or configuration files like `package.json` scripts that might invoke the symbol. This hybrid approach guarantees a comprehensive rename, addressing both structured code and unstructured text within your Bun project.
Using `lsp` and `grep` for accurate Bun symbol renaming
Achieving a truly accurate symbol rename in a Bun project requires more than simple find-and-replace; it demands a two-pronged approach. Atlas first uses the `lsp` tool to pinpoint 100% of code references, then `grep` to find all other mentions, ensuring no usage is missed or incorrectly matched by 2026.
For a Bun developer, the distinction between a code reference and a textual mention is critical. Atlas's `lsp` tool directly interacts with the language server to perform a `findReferences` operation on the target symbol. This provides a precise list of all locations where the symbol is programmatically used, such as imports in `index.ts`, calls within a `src/utils.ts` file, or declarations in `types/global.d.ts`. This is the 'authoritative callsite list' that respects Bun's module resolution and TypeScript's type checking. After securing these exact code references, Atlas then executes its `grep` tool. This `grep` command searches for the old symbol name as a plain string across all files. This catches instances in comments, JSDoc blocks, markdown documentation, or even within string literals that might dynamically construct the symbol's name. For example, if you're renaming a function `oldHandler` to `newHandler`, `lsp` finds `oldHandler()` calls, while `grep` finds `// TODO: Refactor oldHandler` or a string `'oldHandler is deprecated'`. This combination ensures a complete and context-aware rename across your entire Bun project.
Applying changes with Atlas `edit` in Bun projects
Once all references are identified, Atlas applies the mechanical renames using its `edit` tool, which offers robust safety features. For instance, `edit` refuses ambiguous single replacements, preventing unintended modifications in your Bun codebase and ensuring that only 1-to-1 matches are processed without explicit override.
The `edit` tool in Atlas is responsible for the actual modification of files within your Bun project. It takes the comprehensive list of references gathered by `lsp` and `grep` and systematically applies the new symbol name. A key safety mechanism of `edit` is its strict handling of replacements. When performing a `replaceAll` operation, Atlas ensures that the match is unambiguous within each file. If `edit` encounters a scenario where a single occurrence must change but multiple matches for the `oldString` exist in a file, it will throw an error like `Found multiple matches for oldString` rather than silently corrupting your code. This forces you to either provide more context to narrow the match or explicitly opt into a `replaceAll` for that specific file. This prevents accidental changes to unrelated code or documentation that might coincidentally contain the old symbol's name. For example, if you're renaming `fetchData` and `edit` finds `fetchData` in a comment and also in a string literal that shouldn't change, it will prompt for clarification, ensuring your Bun application's integrity.
Verifying Bun renames with `bun test` and `bun fmt`
After Atlas applies the symbol renames, it immediately moves to verification, leveraging Bun's integrated toolchain for rapid feedback. Atlas runs `bun test` to confirm functional correctness and `bun fmt` to ensure code style consistency, completing these checks in mere seconds for most Bun projects by 2026.
The final and most critical stage of any refactoring is verification. Atlas integrates directly with Bun's native tools to provide immediate feedback on the success of the rename. Once all file modifications are complete, Atlas executes the `bash` tool to run `bun test`. This command triggers Bun's incredibly fast test runner, quickly identifying any regressions or broken functionality introduced by the rename. If `bun test` reports failures, Atlas can iterate on the changes, allowing for rapid debugging and correction. Following successful tests, Atlas runs `bun fmt` over the modified files. This ensures that the newly renamed symbols and any surrounding code adhere to your project's formatting standards, maintaining a clean and consistent codebase. Finally, Atlas performs one last `grep` for the old symbol name across the entire repository. This serves as a definitive proof that zero remaining hits of the old name exist, confirming the completeness of the refactor before you approve the commit. This rigorous verification process, powered by Bun's speed, ensures that your refactored code is not only functionally correct but also aesthetically consistent.
Atlas safety and approval for Bun refactoring
Atlas prioritizes safety throughout the refactoring process, especially when renaming symbols in a Bun codebase. Every Atlas tool call is permission-gated, and all proposed changes are presented as a unified diff for your approval, ensuring you maintain full control over your project's evolution in 2026.
Atlas is designed with multiple layers of safety to prevent unintended modifications to your Bun project. Before any tool, such as `lsp`, `grep`, `edit`, or `bash`, is executed, Atlas checks against your defined `allow`, `ask`, and `deny` rules. This permission-gating ensures that Atlas only performs actions you explicitly permit. For instance, running `bun test` or `bun fmt` will trigger a permission prompt if not explicitly allowed. Furthermore, Atlas operates with a 'plan agent' that drafts a read-only plan of action before switching to a 'build agent' to execute changes. This allows you to review the strategy before any modifications occur. Crucially, for every file edit, Atlas computes a unified diff, which is then surfaced for your approval. This means you see exactly what changes Atlas proposes to make to your `index.ts`, `package.json`, or any other file, allowing you to accept, reject, or modify the changes before they are written to disk. Atlas also snapshots file changes as git patches, providing a robust rollback mechanism if needed. This comprehensive safety framework ensures that renaming symbols in your Bun project is a controlled and transparent process.
Step by step
- 01Start Atlas in your Bun project directory, ensuring `bun.lock` and `package.json` are present.
- 02Ask Atlas to rename your target function, class, or constant, for example: "Atlas, rename `oldFunction` to `newFunction` across the repo."
- 03Atlas will use the `lsp` tool's `findReferences` operation to get the authoritative callsite list from the language server for your Bun code.
- 04Atlas will then run `grep` for the old name to catch occurrences outside the type system, such as in comments or `README.md`.
- 05Atlas will apply the mechanical renames with the `edit` tool using `replaceAll` where the match is unambiguous per file.
- 06Review the unified diff presented by Atlas for all proposed changes to your Bun files.
- 07Approve the changes, and Atlas will then run `bash` to execute `bun test` to verify functional correctness.
- 08If tests pass, Atlas will run `bash` to execute `bun fmt` over the diff to ensure consistent formatting.
- 09Atlas will perform a final `grep` for the old name to prove zero remaining hits in your Bun project.
- 10Approve the final commit, which Atlas can stage and create on your behalf.
Frequently asked questions
- How does Atlas ensure a complete rename in a Bun project?
- Atlas ensures a complete rename by combining `lsp` for precise code references (like `Bun.serve` calls) with `grep` for all other textual occurrences, including comments and documentation, leaving no instance of the old symbol behind.
- Can Atlas rename symbols in `package.json` scripts or configuration files?
- Yes, Atlas's `grep` tool is designed to catch occurrences of the old symbol name in non-code contexts, such as `package.json` scripts, markdown files, or other configuration files within your Bun project.
- What if Atlas finds multiple matches for a symbol in one file during a rename?
- If Atlas's `edit` tool finds multiple matches for a single replacement, it will throw an error, requiring you to provide more context or explicitly opt into `replaceAll` for that file, preventing unintended changes in your Bun code.
- How does Atlas verify the refactoring in a Bun project?
- Atlas verifies refactoring by running `bun test` to confirm functional correctness and `bun fmt` to ensure code style consistency, followed by a final `grep` to confirm the old symbol is entirely removed from your Bun project.
- Is it safe to let Atlas modify my Bun codebase?
- Yes, Atlas is designed with multiple safety layers: permission-gated tool calls, a read-only plan agent, and a unified diff for every proposed change, requiring your explicit approval before writing to your Bun project.
- Can Atlas handle renaming symbols used in Bun-native APIs like `Bun.file`?
- Absolutely. Atlas's `lsp` tool understands Bun-native APIs like `Bun.file` and `Bun.serve`, accurately identifying references to your symbols within these contexts for a precise rename.
- What if `bun test` fails after Atlas renames a symbol?
- If `bun test` fails, Atlas will surface the test results, allowing you to review the failures. Atlas can then iterate on the changes, helping you debug and correct the refactoring until all tests pass in your Bun project.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Rename a Symbol Across the Repo with Atlas in 2026
How to rename a symbol across a repo with Atlas in 2026: findReferences gets the true reference set, grep catches strings and docs, and edit refuses ambiguous matches.
Atlas for Bun: Terminal-Native AI Coding in 2026
Atlas is a terminal-native AI coding agent for Bun. Swap Node compatibility shims for Bun.serve and bun:sqlite, iterate with bun test, and format with bun fmt in 2026.
Review a pull request in Bun with Atlas in 2026
Streamline your Bun pull request reviews in 2026 with Atlas, the terminal-native AI coding agent. Atlas leverages `bun test`, `bun fmt`, and `bun install` to ensure robust, context-aware code changes.
Migrate a deprecated API across every callsite in Bun with Atlas in 2026
Effortlessly migrate deprecated APIs across your Bun codebase in 2026 using Atlas. Ensure every callsite is updated with precision, leveraging `bun test` and `bun fmt` for verified changes.
Self-review your working diff before committing in Bun with Atlas in 2026
Catch your own mistakes in uncommitted Bun diffs before they reach review or CI. Atlas helps Bun developers in 2026 self-review code, run `bun test`, and `bun fmt`.
Write unit tests for untested code in Bun with Atlas in 2026
Learn how Atlas helps Bun developers in 2026 add real unit tests to untested modules, matching existing repo conventions using `bun test`, `bun install`, and `bun fmt`.
Debug a Single Failing Test in Bun with Atlas in 2026
Pinpoint and fix failing Bun tests with Atlas, the terminal-native AI coding agent. Leverage `bun test` and `bun fmt` for rapid iteration and precise code corrections in 2026.
Locate where a behavior is implemented in Bun with Atlas in 2026
Pinpoint the exact file and symbol responsible for any behavior in your Bun codebase using Atlas. Leverage semantic search, `grep`, and LSP tools for precise results and a streamlined workflow.