IntelliJ IDEA
CodeArts Agent provides intelligent coding assistance for developers in various scenarios, including code generation, R&D knowledge Q&A, and agent-based collaborative development.
This section uses IntelliJ IDEA as an example to guide you through the installation and login of the CodeArts Agent extension. It also describes how you can perform a unit test.
Procedure
| Step | Description |
|---|---|
NOTE: CodeArts Agent provides two editions: Basic and Professional. Select a proper edition based on your service requirements. For details about how to purchase a package, see Subscriptions. This section uses the basic edition as an example. | |
| Install the CodeArts Agent extension and log in with your HUAWEI ID. | |
| Use the agent capabilities to generate a clean, modular, and testable Snake game for unit testing. | |
| Automate unit tests of core modules with the agent to improve code quality and verification efficiency. |
Preparations
Before using CodeArts Agent for coding, complete the preparations by referring to Table 1.
| Item | Description |
|---|---|
| IntelliJ IDEA | You have downloaded and installed IntelliJ IDEA (versions 2022.3 to 2026.1). Switch IntelliJ IDEA's interface language for improved usability. Windows OS: Windows 11 (x64) is recommended. If you are using Windows 10 (x64), the version must be 2019 or later, and upgrading to the latest stable version is recommended. |
| Account | You have a HUAWEI ID. If you do not have one, perform the following steps to create a HUAWEI ID:
|
Step 1: Install and Log In to CodeArts Agent
- Double-click the IntelliJ IDEA icon to start the program.
- Install CodeArts Agent.
- In the navigation pane on the left of IntelliJ IDEA, click Plugins to access the Plugins page.
- Click Marketplace on the top of the page and enter CodeArts Agent in the search box to search for the CodeArts Agent extension. Figure 1 Searching for CodeArts Agent
- Click Install. IntelliJ IDEA will then download and install the extension.
- After the installation is complete, click Restart IDE or manually restart the IDE to activate the extension.
- Create a project for storing files.
- On the Welcome to IntelliJ IDEA page, click New Project. The New Project dialog box is displayed.
- Enter the project name, select a path for storing the project, and click Create.
Unit tests depend on the data read from pom.xml. To ensure unit tests can run properly, set Build system to Maven when creating a project. After the project is created, a pom.xml file is generated in the corresponding folder of the explorer.
Figure 2 Creating a project
- Log in to CodeArts Agent.
- On the sidebar of IntelliJ IDEA, click the CodeArts Agent extension icon
. - Click Switch to International Site.
- Click Log In with HUAWEI ID. The Huawei Cloud login page is displayed.
- Enter your HUAWEI ID and password and click Log In.
If this is the first time you use CodeArts Agent, the activation page will be displayed. Agree to the service statement and click Activate Now. Wait until the package is activated.
After the package is activated, complete the login authorization. After the system displays a message indicating that the login is successful, return to IntelliJ IDEA to start your intelligent coding journey.
- On the sidebar of IntelliJ IDEA, click the CodeArts Agent extension icon
Step 2: Create a Snake Game
This section uses the agent capabilities to generate a Snake game in Java for unit testing.
- Click the CodeArts Agent icon
on the IDE sidebar to open the chat panel. - At the bottom of the input box on the chat panel, choose Built-in > Agent to switch to the agent mode.
- Select the agent running mode and authorize automatic operations.
- Click the settings icon
in the upper right corner of the chat panel to access the settings page. - Choose , select the running policy for the agent to execute terminal commands. This section uses the default running policy (Running in Sandbox).
A sandbox provides an isolated and restricted execution space for instructions generated by agents. Strict permission controls ensure commands run in a secure, isolated environment. This effectively blocks access to unauthorized resources, like files and networks, and prevents risky commands, such as those that change permissions. For intercepted commands, the agent will issue a risk prompt within a chat. These commands need your second approval before running outside the sandbox.
- Choose Dialog Flow > Auto-approve and click
to enable the required items. After authorization, tasks for generating complex project-level code are executed automatically. Without authorization, some operations will need your manual confirmation when you code with CodeArts Agent.
Table 2 Parameters for automatic approval Parameter
Description
Example
Edit
Allows the agent to call tools like edit, write, and deleteFile to edit files on your computer.
Enabled
Open Browser
Allows the agent to access websites in the browser.
Enabled
Web Crawler
Allows the agent to access and capture specified web page content.
Enabled
- Exit the current page to complete the authorization.
- Click the settings icon
- In the chat box, enter the following content. CodeArts Agent will guide you to create a game step by step.
Develop a snake game in Java.
Step 3: Perform a Unit Test with the Agent
Automate unit tests of core modules with the agent to improve code quality and verification efficiency.
- In the code generated in Step 2: Create a Snake Game, right-click and choose . Figure 3 Choosing Unit Test (Agent)
- Check whether the GamePanelTest.java unit test file is generated. If yes, the running is successful and the test is passed.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot