To extract a shared helper from duplicated code in a Quarkus project, Atlas leverages its semantic search capabilities to identify near-identical logic, then guides you through creating a new module, replacing duplicates with calls, and verifying changes with `JUnit 5 (@QuarkusTest)` and `Maven` before applying `Spotless` formatting.
How to find duplicated logic in Quarkus with Atlas?
Finding duplicated logic in a Quarkus codebase in 2026 is more effective with Atlas's `codebase_search` tool, which identifies semantic similarities that traditional `grep` commands often miss. This is crucial because copy-pasted code frequently differs in variable names or minor structural details, making exact text matching insufficient for identifying true duplication.
Atlas's `codebase_search` tool is specifically designed to overcome the limitations of keyword-based searches. It indexes your Quarkus project's code by AST declarations using tree-sitter, allowing it to understand the structure and meaning of your code, not just its literal text. When you ask Atlas to find a specific behavior or logic, it uses hybrid semantic and keyword retrieval fused by reciprocal rank fusion to surface near-duplicate implementations. This means Atlas can identify the same logic even if it's spread across different CDI beans, JAX-RS resources, or utility classes, and uses different variable names or minor structural variations. For instance, if you have a complex validation routine duplicated in two different JAX-RS endpoints, `codebase_search` can pinpoint both instances, enabling you to consolidate them into a single, reusable helper.
How to replace duplicated Quarkus code with a helper call?
Replacing duplicated code with calls to your new helper in Quarkus is managed by Atlas's `apply_patch` tool, which generates one reviewable patch per file. After each replacement, it is critical to run `bash ./mvnw test` to execute your `JUnit 5 (@QuarkusTest)` suite, ensuring that the refactoring in 2026 has not introduced any regressions.
The `apply_patch` tool is central to safely refactoring your Quarkus codebase. For each instance of duplicated code identified, Atlas will propose a patch to replace it with a call to your newly created shared helper. A key safety feature is that Atlas generates a separate, independently reviewable patch for each file modification. This granular approach allows you to approve or reject changes on a file-by-file basis, making the refactoring process transparent and manageable. After Atlas applies each patch, the documented workflow mandates running `bash ./mvnw test`. This command triggers your `Maven` build and executes all `JUnit 5 (@QuarkusTest)` cases, including those using `RestAssured` for JAX-RS endpoints. This immediate feedback loop is vital: if a test fails, you know exactly which `apply_patch` caused the issue, allowing for quick rollback and correction. This iterative testing ensures that your Quarkus application remains functional and robust throughout the refactoring process.
How does Atlas ensure safe refactoring and review in Quarkus?
Atlas ensures safe refactoring in Quarkus by implementing multiple layers of review and permission gating, from a read-only plan agent to unified diffs for every edit. In 2026, this includes integrating with your existing `Maven` and `Spotless` toolchain, providing confidence that changes are correct, formatted, and tested.
Safety and review are paramount when refactoring a live Quarkus application. Atlas employs a multi-stage process to ensure every change is intentional and correct. First, Atlas drafts a plan in a read-only plan agent, which you review and approve before any modifications are attempted. Every Atlas tool call, including `write` and `apply_patch`, is permission-gated against allow, ask, and deny rules, giving you explicit control. For every file edit, Atlas computes a unified diff and surfaces it for your approval before writing to disk. This means you see exactly what changes will be made to your Quarkus CDI beans, JAX-RS resources, or `pom.xml` files. Furthermore, Atlas snapshots file changes as `git` patches, allowing edits to be easily diffed and rolled back if necessary. After all functional changes are approved and tested with `JUnit 5 (@QuarkusTest)`, Atlas can apply `Spotless` formatting to ensure your code adheres to project style guidelines before staging and creating `git` commits on your behalf, completing a fully reviewed and compliant refactoring cycle.
Step by step
- 01Ask Atlas to `codebase_search` for the behavior of the duplicated logic across your Quarkus CDI beans or JAX-RS resources.
- 02Use Atlas's `read` tool to examine each search hit and confirm the copies are genuinely equivalent, noting variable name differences.
- 03Create the shared helper Java file using Atlas's `write` tool, reviewing the full diff and ensuring it aligns with Quarkus build-time augmentation requirements.
- 04For each duplicate, use Atlas's `apply_patch` tool to replace the copied logic with a call to the new helper, reviewing each file's diff independently.
- 05After every `apply_patch` operation, run `bash ./mvnw test` to execute your `JUnit 5 (@QuarkusTest)` suite and verify functionality, including `RestAssured` tests.
- 06Once all duplicates are replaced, run `bash grep -r "old_duplicated_logic_pattern" .` to confirm no surviving copies remain in your Quarkus project.
- 07Let Atlas apply `Spotless` formatting to all modified files and then stage and create a `git` commit for the refactoring.
Frequently asked questions
- How does Atlas handle Quarkus build-time augmentation during refactoring?
- Atlas is aware of Quarkus's build-time augmentation and native-image constraints. When creating new helpers with `write`, Atlas can suggest patterns that are compatible with build-time processing, helping you avoid runtime reflection and ensuring your code works correctly in a native executable.
- Can Atlas find duplicated logic across different Quarkus modules?
- Yes, Atlas's `codebase_search` tool indexes your entire project by AST declarations. This allows it to semantically identify duplicated logic across different Maven modules within your Quarkus project, even if they are in separate `pom.xml` contexts.
- How does Atlas integrate with Maven for Quarkus projects?
- Atlas integrates directly with `Maven` by operating within your project's `pom.xml` structure. It can suggest updates to `pom.xml` for new dependencies and, crucially, executes `bash ./mvnw test` to run your `JUnit 5 (@QuarkusTest)` suite, ensuring refactoring integrity.
- What testing framework does Atlas use for Quarkus refactoring?
- Atlas leverages your existing `JUnit 5 (@QuarkusTest)` suite for verification. After each code modification, Atlas prompts you to run `bash ./mvnw test`, which executes your Quarkus-specific tests, including those using `RestAssured` for JAX-RS endpoints, to confirm no regressions.
- Does Atlas support Spotless for Quarkus code formatting?
- Yes, Atlas supports `Spotless` integration. After completing functional refactoring and testing, Atlas can apply `Spotless` formatting to all modified files, ensuring your Quarkus codebase adheres to your project's defined style guidelines before committing.
- How does Atlas ensure code safety when extracting helpers in Quarkus?
- Atlas ensures safety through a multi-layered approach: a read-only plan agent, permission-gated tool calls, unified diffs for every edit, `git` patch snapshots for rollback, and mandatory `JUnit 5 (@QuarkusTest)` execution after each `apply_patch` operation in your Quarkus project.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Extract a Shared Helper from Duplicated Code with Atlas (2026 Workflow)
How to extract a shared helper from duplicated code with Atlas in 2026: codebase_search finds the copies by meaning, write creates the module, apply_patch swaps each call.
Atlas for Quarkus in 2026
Atlas is a terminal-native AI coding agent for Quarkus in 2026. It reads CDI beans and JAX-RS resources, then runs ./mvnw test behind a permission prompt.
Diagnose a hanging or long-running command in Quarkus with Atlas in 2026
In 2026, Quarkus developers use Atlas to diagnose hanging or slow Maven builds and scripts. Quickly identify if a command is blocked on input or genuinely slow, and get unstuck.
Run the test suite and triage the failures in Quarkus with Atlas in 2026
In 2026, Quarkus developers use Atlas to efficiently run JUnit 5 (@QuarkusTest) suites, parse extensive failure logs, and prioritize distinct root causes for rapid resolution.
Refactor a legacy module in Quarkus with Atlas in 2026
Streamline Quarkus module refactoring in 2026 with Atlas. Safely restructure old code, maintain behavior, and prevent breaking callers using Maven, JUnit 5, and Spotless.
Upgrade a Quarkus Dependency and Fix Breakage with Atlas in 2026
In 2026, Atlas helps Quarkus developers upgrade major dependencies, fixing compile and test failures. It drives Maven, reads compiler output, and repairs code with LSP, ensuring JUnit 5 and Spotless compliance.
Audit a Quarkus Repo with Parallel Subagents in Atlas in 2026
Sweep your Quarkus repository for problems without blowing your context window. Atlas uses parallel subagents, JUnit 5, Maven, and Spotless for efficient, safe audits.
Self-review your working diff before committing in Quarkus with Atlas in 2026
Catch your own mistakes in uncommitted Quarkus diffs using Atlas. Integrate with Maven, JUnit 5 (@QuarkusTest), and Spotless for a robust self-review workflow.