⚠️ Early prototype — subject to rapid change.
Refrax is an AI-powered refactoring agent for Java code, implemented in Go.
We often need our source code to be polished by AI agents (like Claude Code), for example typos to be fixed, small refactorings applied, and JavaDoc blocks improved. But we struggle to formulate the prompt correctly. A simple "make my code better" may not work for two reasons: the agent quickly gets lost when it deals with hundreds of files, and the agent requires regular interaction with the user. Refrax solves both of these issues by breaking down a large demand to polish the code into a series of smaller requests to a number of agents with their specific roles: a critic, a reviewer, an editor, and so on. You just start Refrax and in a few minutes (or hours) it makes your code better, running fully autonomously.
Refrax integrates a number of LLMs communicating via the A2A protocol.
Download the latest stable version from the releases page. Pre-built binaries are available for macOS, Windows, and Linux.
If you have Go 1.24.1 or later installed, you can run:
go install github.com/cqfn/refrax@latest
To install a specific version, use:
go install github.com/cqfn/refrax@v0.0.1
Ensure that Go 1.24.1 or later is installed on your system.
-
Clone the repository:
git clone https://github.com/cqfn/refrax.git cd refrax
-
Build the binary:
go build -o refrax
-
(Optional) Install the binary to your
$GOPATH/bin
:go install
refrax refactor [path]
: Refactor Java code in the specified directory (defaults to current directory).refrax start [agent]
: Start the server for agents like fixer, critic, or facilitator.
You can try refactoring the testing project located in this repository. To do so, you will need to clone the repository:
git clone https://github.com/cqfn/refrax.git
Then, run the following command:
refrax refactor --output="./out" --ai=deepseek refrax/test/test_data/java/person
Or, if you are already in the refrax
folder, simply run:
refrax refactor --output="./out" --ai=deepseek test/test_data/java/person
refrax
does not inherently verify whether the applied changes are correct or cause any issues.
To address this, you can use the --check
option to validate the changes. Multiple --check
options can be provided, as shown below:
refrax refactor . --ai=deepseek --check="mvn clean test" --check="mvn qulice:check -Pqulice"
When at least one --check
option is specified, the reviewer
agent executes the provided checks and delivers feedback to the facilitator
agent.
--ai, -a
: Specify the AI provider (e.g., deepseek, openai).--token, -t
: Token for the AI provider.--debug, -d
: Enable debug logging.
Some operations in Refrax require AI authentication using an API token. You can provide the token using one of the following methods:
refrax refactor . --token your-token-here
Supported AI providers are:
deepseek
openai
✅ The DEEPSEEK_TOKEN
variable is the recommended option for deepseek
AI provider
✅ The OPENAI_TOKEN
variable is the recommended option for openai
AI provider
TOKEN
variable is still supported for any AI provider but deprecated.
Set the environment variable:
export DEEPSEEK_TOKEN=your-token-here
refrax start facilitator
If a .env
file is present in the working directory, Refrax will attempt to read the token from it:
# .env
DEEPSEEK_TOKEN=your-token-here
If multiple sources are provided, the following priority order is applied (highest priority first):
--token
command-line flagDEEPSEEK_TOKEN
environment variableTOKEN
environment variable (deprecated).env
file (DEEPSEEK_TOKEN
>TOKEN
)
To gather interaction statistics, you can use the following command:
refrax refactor . --ai=deepseek --stats --stats-format=csv --stats-output=stats.csv
This command generates a stats.csv
file containing the interaction statistics.
The --stats-output
and --stats-format
parameters are optional.
If you omit them, refrax
will output the statistics directly to the console.
The reviewer agent is responsible for verifying the results of refactoring.
It executes a set of predefined commands to ensure the repository's stability and the correctness of the refactoring changes.
Since the commands may vary between projects, you can configure them using the --check
option. For example:
refrax refactor . --ai=deepseek --check="mvn clean test" --check="mvn qulice:check -Pqulice"
Note that multiple --check
commands can be used.
Licensed under the MIT License.