Updated on 2026-07-30 GMT+08:00

Commands

Open the CMD, PowerShell, or terminal and run codearts [command] to enter the CLI development mode of CodeArts Agent.

Table 1 CLI commands

Command

Description

Subcommand or Subparameter

codearts help

Views command help information.

None

codearts completion

Generates a shell autocomplete script.

None

codearts mcp

Manages the MCP server.

For details about subcommands, see MCP Commands.

codearts [project]

Starts the TUI development environment of a specified project. [project] is an optional parameter indicating the project name.

For example, you can run the following command to enter the TUI development mode and load the Test project:

codearts D:\Test

None

codearts run [message]

Runs CodeArts Agent CLI in non-interactive mode and directly inputs a prompt.

For example, run the following command to read files in the current directory:
codearts run read file

For details about the parameters supported by the codearts run command, see Table 2.

codearts agent

Manages agents.

  • create: creates an agent.
  • list: lists all available agents.

codearts models [provider]

Lists available models.

  • For example, you can run the following command to obtain available models of all vendors:
    codearts models
  • For example, you can run the following command to obtain available models of the huaweicloud-maas vendor:
    codearts models huaweicloud-maas

None

codearts stats

Queries token usage and cost statistics.

Run the following command to query all statistics:
codearts stats

For details about other subcommands, see Table 3.

codearts session

Manages sessions.

  • list: lists all sessions.
  • delete <sessionID>: sessionID is mandatory. You can obtain it by running the codearts session list command. After running the command, select the session to be deleted and press Enter.

codearts export [sessionID]

Prints the data of the session with a specified ID in JSON format. You can obtain the sessionID by running the codearts session list command.

  • For example, you can run the following command, select the session to be exported, and press Enter to print the session data.
    codearts export
  • For example, you can run the following command to print the data of the session with a specified ID:
    codearts export [sessionID]

None

codearts import <file>

Imports session data from a local JSON file. The <file> parameter is mandatory.

For example, you can run the following command to import data from a specified file. The imported data includes the sessionID.

codearts import session.json

Application scenario: You can continue the session based on the generated sessionID.

None

codearts upgrade

Upgrades CodeArts Agent CLI to the latest version.

None

codearts uninstall

Uninstalls CodeArts Agent CLI and deletes all related files.

None

codearts docs

Obtains the help documentation URL of CodeArts Agent CLI.

None

codearts privacy

Queries the privacy policy of CodeArts Agent CLI.

None

codearts debug

Debugs issues.

For details about subcommands, see Table 7.

codearts --version

Prints the version.

None

codearts --print-logs

Prints logs to stderr.

None

codearts --log-level <Log level>

Sets the log level, which can be DEBUG, INFO, WARN, or ERROR.

None

codearts codebase

Manages repository indexes.

For the parameters supported by this command, see Table 3.

codearts serve

Starts a server without a GUI.

Before running this command, run the following command in PowerShell, CMD, or the terminal to configure the username and password for the server. Otherwise, error message "Error: CODEARTS_SERVER_PASSWORD is not set; please configure the password to start the server." is displayed.

export CODEARTS_SERVER_USERNAME="Username for logging in to the server"
export CODEARTS_SERVER_PASSWORD="Password for logging in to the server"

You need to set the username and password by yourself.

For the parameters supported by this command, see Table 10.

codearts attach <url>

Binds a local command line to a remote CodeArts Agent CLI instance using a username and a password. You can pass the username and password using environment variables or command line--password.

For the parameters supported by this command, see Table 11.

Table 2 Parameters supported by codearts run

Flag

Description

codearts run --command

  • Runs a command using --command <Command>.
    For example, you can run the following command to perform initialization:
    codearts run --command init

    For example, you can run the following command to run the test command:

    codearts run --command test
  • Generates code using an SDD command in --command <SDD command> <Parameter> format.

    The SDD command can be sdd-new, sdd-design, sdd-tasks, or sdd-apply. Parameter is mandatory.

    • When the command is sdd-new, the parameter indicates the description of the task to be executed.
    • When the command is sdd-design, sdd-tasks, or sdd-apply, the parameter indicates the folder name of the product.

    When using SDD commands in the CLI, you do not need to add a slash (/) before them. Other functions are the same as those on the TUI. For details, see SDD.

  • Creates a scheduled task using the --command schedule "Prompt" command. For details, see Creating a Scheduled Task on the CLI.

codearts run --continue

Continues the previous session. It can be abbreviated as -c.

For example, you can run the following command to continue the previous session:

codearts run --continue

codearts run "Command to be executed" --sessionID <sessionID>

Continues a session with a specified ID. It can be abbreviated as -s.

For example, you can run the following command to continue the session with the specified ID:

codearts run "What day is it today?" --sessionid ses_07885a8e7ffe8ESvH4zV1BdFJw

In the preceding command, ses_07885a8e7ffe8ESvH4zV1BdFJw is the session ID. You can obtain it by running the codearts session list command.

codearts run --fork

Continues a fork session.

codearts run --model

Model to be used. It can be abbreviated as -m.

codearts run --agent

Agent to be used

codearts run --file

File to be attached to the message. It can be abbreviated as -f.

codearts run --format

Format, which can be default or json

codearts run --title

Session title

codearts run --thinking

Displays thinking blocks.

codearts run --attach

Connects to a running server.

For example, you can run the following command to connect to a running CodeArts server whose URL is http://localhost:4096 and perform Q&A:
codearts run --attach http://localhost:4096 --password 1***5 "hi"

codearts run --auto

Runs the Bash tool in automatic mode in the current session.

codearts run --sandbox

Runs the Bash tool in sandbox mode in the current session.

Table 3 Parameters supported by codearts stats

Command

Description

codearts stats --days

Displays statistics of the last N days.

  • For example, you can run the following command to display statistics of all days:
    codearts stats --days
  • Run the following command to display statistics of the last two days:
    codearts stats --days 2

codearts stats --tools

Displays statistics of tools.

codearts stats --models

Displays usage details of all models.

codearts stats --project

Displays statistics of a project.

Go to the root directory of the Git repository to be queried, right-click in the blank area, and select Open Windows Terminal here. Run the following command to query the statistics of the current project:

codearts stats --project
NOTE:

If the target repository has no Git commit records, the system displays project data of all non-Git repositories.

Table 4 Flags supported by codearts [project]

Flag

Abbreviation

Description

--continue

-c

Enters the TUI development mode and continues the previous session.

For example, you can run the following command to enter the D:\Test project and the TUI development mode to continue the session:

codearts D:\Test -c

--session

-s

ID of the session to be continued. You can obtain the sessionID by running the codearts session list command.

codearts D:\Test -s <sessionID>

--fork

-

Creates a fork session based on a specified session. The subcommands are as follows:

  • codearts --fork -c: enters the TUI development mode and continues the previous session.
  • codearts --fork -s sessionID: creates a fork session based on a specified session ID.

--model

-m

Model to be used

--agent

-

Agent to be used

Table 5 Parameters supported by codearts session list

Flag

Abbreviation

Description

--max-count

-n

Maximum number of recent sessions

--format

-

Output format, which can be table or json

Table 6 Flags of the codearts uninstall command

Flag

Abbreviation

Description

--keep-config

-c

Retains the configuration file.

--keep-data

-d

Retains session data.

--dry-run

-

Displays the content to be deleted.

--force

-f

Skips the confirmation prompt.

Table 7 codearts debug subcommands

Commands

Description

codearts debug config

Definition: displays the complete configuration after parsing.

Function: This command displays all configurations that have taken effect (including default values and environment variables) for troubleshooting configuration loading issues.

codearts debug rg

Definition: debugs the ripgrep code search tool. For details about subcommands, see Table 8.

Function: This command is used to debug ripgrep-related behavior, such as searching for rules, ignoring files, and matching paths.

codearts debug file

Definition: debugs file systems. For details about subcommands, see Table 9.

Function: This command is used to debug file-related issues, such as file reading/writing, path parsing, permissions, and symbolic links.

codearts debug scrap

Definition: lists all known projects.

Function: This command helps developers learn the projects identified by CodeArts Agent CLI.

codearts debug skill

Definition: lists all available skills.

Function: This command returns all the skills loaded in the current environment, including their names, descriptions, locations, and content.

codearts debug agent <name>

Definition: queries the configuration details of a specified agent. <name> is a mandatory parameter.

Function: This command returns all configurations of an agent, including permissions, tools, model parameters, and prompts. It is used to debug abnormal agent behavior.

codearts debug paths

Definition: displays global paths.

Function: This command returns core directories, including the data directory, configuration directory, cache directory, or status directory. It is used to troubleshoot issues such as missing files and permission issues.

codearts debug wait

Definition: waits indefinitely (for debugging). To exit, press the shortcut key (Windows: Ctrl+C; Mac: ⌘+C).

Function: This command keeps a process running so that a debugger can be attached to the process for debugging.

Table 8 codearts debug rg subcommands

Command

Description

codearts debug rg tree

Definition: displays the file directory tree using ripgrep.

With this command, you can:
  • View the file structure using ripgrep and check the directories or files that are included or excluded.
  • Check whether the .gitignore and .ignore rules take effect and why some files cannot be found.

Typical use case: You can use this command when you suspect that project files were accidentally ignored and want to confirm the scanning scope of ripgrep.

codearts debug rg files

Definition: lists all files using ripgrep.

With this command, you can:
  • List all files within the scanning scope of ripgrep (affected by ignore rules).
  • Quickly compare actual files with the files visible to ripgrep to locate the issue that files are not indexed.

Typical use case: You can use this command when you cannot find a file in CodeArts Agent CLI and want to check whether the file has been ignored by ripgrep.

codearts debug rg search <pattern>

Definition: searches for file content using ripgrep.

With this command, you can:
  • Directly call ripgrep to search for file content and verify the underlying behavior of the search function in CodeArts Agent CLI.
  • Compare the search results on CodeArts Agent CLI with those obtained using native ripgrep to determine whether an issue occurs in the frontend or backend.

Typical use case: When search results are missing or matching rules are abnormal, you can run this command if you want to use native ripgrep for comparison and verification.

Table 9 codearts debug file subcommands

Command

Description

codearts debug file read <path>

Definition: reads and outputs the content of a specified file in JSON format.

With this command, you can:

  • Directly view the content of files read by CodeArts Agent CLI, especially configuration files and status files.
  • Troubleshoot the following issues: A file exists but cannot be read; empty content is read; the format of the file read is incorrect.
  • Check whether the file encoding and JSON formats are correct.

codearts debug file status

Definition: displays the status of a file system.

With this command, you can:

  • Check the statuses and permissions of files in the current directory or workspace (such as symbolic links and read-only permissions).
  • Troubleshoot issues such as insufficient file permissions and unavailable paths.
  • Check whether a file is locked or occupied by the system.

codearts debug file list <path>

Definition: lists all files and subdirectories in a specified directory of the current project.

With this command, you can list files and subdirectories in a directory of a project.

codearts debug file search <query>

Definition: performs a fuzzy search for files in the current project by condition.

With this command, you can quickly search for files that meet specified conditions.

codearts debug file tree [dir]

Definition: displays the tree structure of non-empty directories in a specified directory.

This command displays the complete structure of a specified directory, allowing you to view levels of the directory.

Table 10 Parameters supported by codearts serve

Parameter

Description

--port

Server listening port. The default port is 4096.

For example, you can run the following command to specify listening port 4096:
codearts serve --port 4096

After the service is started, you can open a new window and run the codearts attach command to connect to the server. For details, see Table 1.

--hostname

Server listening address. The default value is 127.0.0.1.

For example, you can run the following command to specify the server listening address 127.0.0.1:
codearts serve --hostname 127.0.0.1

After the service is started, you can open a new window and run the codearts attach command to connect to the server. For details, see Table 1.

--mdns

Enables discovery of the mDNS services with zero configuration on the LAN. Devices on the same LAN as CodeArts Agent CLI can be automatically scanned and can access CodeArts Agent CLI. The IP address of the local host does not need to be manually specified.

For example, you can run the following command to start CodeArts Agent CLI on port 4096 of the local host and enable discovery of mDNS services on the LAN. Devices on the same LAN can automatically scan the current service and access the web management page and MCP interfaces using the .local domain name without the host IP address.
codearts serve --port 4096 --mdns

--mdns-domain

This parameter must be used together with --mdns. It specifies the custom host name prefix of the mDNS LAN. The default value is codearts.local. If you do not specify --mdns-domain, the system uses the codearts prefix and combines it with the fixed mDNS suffix .local to generate the LAN domain name codearts.local.

For example, the following command uses the default domain name codearts.local. The access address is http://codearts.local:4096.
codearts serve --port 4096 --mdns
The following command uses manually specified --mdns-domain to overwrite the default value. The domain name is dev-server.local, and the access address is http://dev-server.local:4096.
codearts serve --port 4096 --mdns --mdns-domain dev-server

--cors <origin>

Addresses of external web pages that have permissions to access the service. If * is passed, all web pages can access the service. This is used for local development and debugging. If this parameter is not set, only pages of the service can call APIs. External web pages will be blocked by the browser.

For example, you can run the following command to allow the local frontend page running on http://localhost:5173 to request APIs through port 4096:
codearts serve --port 4096 --cors http://localhost:5173
You can run the following command to allow access from multiple sources:
codearts serve --port 4096 \
--cors http://localhost:5173 \
--cors http://127.0.0.1:3000
You can run the following command to allow access from all sources. This command is used only for local debugging. It may pose security risks and is not recommended for the production environment.
codearts serve --port 4096 --cors *
Table 11 Parameters supported by codearts attach

Parameter

Description

<url>

You can run this command to connect to a running server.

You can perform the following steps to connect to a running server:

  1. Configure temporary environment variables to specify the username and password for connecting to the server.
    • Run the following commands in Windows:
      set CODEARTS_SERVER_USERNAME=Server username
      set CODEARTS_SERVER_PASSWORD=Server password
    • Run the following commands in macOS or Linux:
      export CODEARTS_SERVER_USERNAME="Server username"
      export CODEARTS_SERVER_PASSWORD="Server password"
  2. Run the following command to start the service on a terminal:
    codearts serve
    If the following information is displayed, the service is successfully started:
    This service runs in a local development environment and is not a standard cloud service. It does not provide enterprise-grade security hardening or SLA guarantees.
    Do not expose the service address to the public internet or share it with others. This may lead to unauthorized access, code leaks, and other security risks.
    By continuing to use this service, you acknowledge and voluntarily assume these risks.
    It is advised to set up a reverse proxy to secure access. Configuration guide:
    https://support.huaweicloud.com/intl/en-us/codeartsagent_faq/codeartsagent_faq_0054.html
    codearts server listening on http://127.0.0.1:4096
  3. Run the following command on another terminal to connect to a specified server:
    codearts attach ${CODEARTS_SERVER_URL} --password ${CODEARTS_SERVER_PASSWORD}

    In the command, ${CODEARTS_SERVER_URL} indicates the URL of the server to be connected, and ${CODEARTS_SERVER_PASSWORD} indicates the password of the server.

    For example, you can run the following command to connect to the remote development server through port 4096 of the local host and access the development environment through password authentication:
    codearts attach http://localhost:4096 -p yourpassword

-p,--password

Server password

-c,--continue

Continues the last session.

-s,--session

Session ID

--fork

Fork session, which is used together with --continue or --session.