Transforming code on the command line with Amazon Q Developer
You can transform your applications from the command line with the Amazon Q Developer command line transformation tool. To transform your code, you provide the path to your source code and any necessary configuration files, and Amazon Q generates new code in a series of steps. Throughout the transformation, Amazon Q builds code on your local environment to verify changes. For more information, see Building code in your local environment. Amazon Q creates a new branch in your repository where it commits the code changes. When the transformation is complete, you can merge the branch into your original branch to incorporate the changes into your codebase.
To get started, install the command line tool and authenticate, and then see the commands to configure and start a transformation.
Topics
Building code in your local environment
During a transformation, Amazon Q performs verification builds in your local environment. Amazon Q transforms your code on the server side in multiple steps. After each step, Amazon Q sends the code to your local environment to build and test the changes it made. The code is then sent back to the server side to continue the transformation.
The build in your local environment helps verify the transformed code by allowing Amazon Q to run tests that require access to private resources. To minimize security risks associated with building AI-generated code in your local environment, Amazon Q reviews and updates the code it generates to address security concerns.
Note
Amazon Q performs transformations based on your project's requests, descriptions, and content. To maintain security, avoid including external, unvetted artifacts in your project repository and always validate transformed code for both functionality and security.
Commands
For step-by-step instructions for running these commands, see Running a transformation on the command line with Amazon Q Developer.
To configure a transformation and authenticate to Amazon Q Developer Pro, run:
qct configure
To start a transformation for a Java upgrade, run the following command. For
<your-source-java-version>
, you can enter
JAVA_1.8
, JAVA_8
, JAVA_11
, JAVA_17
, or
JAVA_21
. For <your-target-java-version>
, you can
enter either JAVA_17
or JAVA_21
. Both
--source_version
and --target_version
are optional. The --trust
flag enables a transformation to run while vetting code to maintain security.
qct transform --source_folder
<path-to-folder>
--source_version<your-source-java-version>
--target_version<your-target-java-version>
--trust
To start a transformation for a SQL conversion, run:
qct transform --source_folder
<path-to-folder>
--sql_conversion_config_file<path-to-sql-config-file>
To see what version of the command line tool for transformation you are using, run:
qct -v
To get help with transformations, run:
qct -h
Pausing or canceling a transformation
You can choose to pause or cancel your current transformation job. You can pause a transformation job for up to 12 hours before you can resume again.
To pause or cancel a code transformation job
-
In your CLI terminal, press Ctrl+C on your keyboard.
-
Select whether you want to pause or cancel your tranformation.
-
Enter
1
if you want to puase the code transformation job. You can resume the job within 12 hours to continue the code transformation using the following QCT command:`qct transform --source_folder=≤/Path/Given/Originally/To/QCT>`
. -
Enter
2
if you want to cancel the code tranformation job.
-