Slash Commands
Slash commands are an efficient way to interact, allowing the agent to quickly execute common tasks within a chat. CodeArts Agent has been preconfigured with some common commands. You can also customize commands as needed.
Through custom commands, you can encapsulate frequently used operations or complex instructions into simple commands, thereby simplifying your workflow and enhancing collaboration efficiency with the AI. In CodeArts Agent, using custom slash commands offers the following advantages:
- Reusing common prompts: Boosting efficiency and reducing repetitive typing
Encapsulate frequently used prompts into shortcut commands to avoid typing the same instructions manually every time. For example, a custom command /code_explain can be used to explain the functionality, design mindset, and dependencies of the selected code.
- Standardizing output formats: Unifying team standards and decreasing collaborative friction
Enforce the AI to generate outputs that align with team standards through preset templates or rules, ensuring consistency. For example, a custom /api_doc_format can be used to convert API descriptions into a unified Markdown or Swagger format, making it easier for frontend integration or document platform synchronization.
- Automating common development workflows: Triggering multi-step tasks with one click
Package multiple operations or analysis steps into a single command to achieve "one-click trigger, end-to-end execution." For example, a custom command /code_review can be used to automatically scan the code of the current branch, identify potential bugs, performance bottlenecks, or style inconsistencies, and generate a comprehensive report.
Built-in Slash Commands
CodeArts Agent has been preconfigured with the commands listed in Table 1. You can directly invoke them without additional configuration.
| Mode | Command | Description |
|---|---|---|
| Intelligent Q&A | /optimize | Code optimization Allows CodeArts Agent to analyze code performance bottlenecks and provide optimizations, helping users improve the readability and maintainability of code. |
| /comment | Code commenting Allows the system to analyze the code's architecture and logic, then auto-generate clear, meaningful comments. It facilitates standardizing the comment style across your entire repository, so readability becomes second nature and code archaeology is a thing of the past. | |
| /explain | Code explanation Allows the system to walk you through complex code with function, purpose, application scenario, and main logic. This clear explanation helps you get up to speed faster, and make knowledge flows smoothly, keeping the whole team in sync. | |
| /tests | Unit test Powers up your coding with generated unit test cases that slot into various test frameworks, such as JUnit, JMockit, pytest, unittest, and GTest. From single method to comprehensive class-wide tests, the code quality is guaranteed and defect risks are reduced. | |
| /help | Help Displays shortcut operation tips. | |
| /clear | Clear screen Clears the Q&A window content and opens a new one. | |
| Agent Custom agent | /clear | Clear screen Clears the agent window content and opens a new one. |
| /init | Agent.md one-click initialization Automatically generates the specification configuration file Agent.md for stock projects. | |
| /review | Code review Initiates a review on code, automatically identifying and fixing issues. | |
| /sdd-new | Creation of requirement specifications Generates the requirement specification document spec.md based on requirement descriptions. | |
| /sdd-design | Creation of SDD technical design Generates design.md based on spec.md. | |
| /sdd-tasks | Creation of SDD coding tasks Generates the task list tasks.md based on spec.md and design.md. | |
| /sdd-apply | Execution of SDD coding tasks Executes coding tasks one by one based on tasks.md. | |
| Agent | /bugfix | Automatically invokes the repair expert agent to fix code issues based on the descriptions in the trouble tickets submitted by users. For details, see /bugfix. |
| Agent | /fix-review | Fixes a single piece of code based on the review comment from the code review agent. For details, see /fix-review. |
| Agent | /fix-review-batch | Fixes multiple pieces of code based on the review comments from the code review agent. For details, see /fix-review-batch. |
| Agent | /fix-codeartscheck-batch | Batch fixes alert issues generated by CodeArts Check. For details, see /fix-codeartscheck-batch. |
Custom Slash Commands
CodeArts Agent allows you to create a Markdown file in the commands/ directory under a specified path to customize slash commands. After the command is loaded successfully, you can run it in CodeArts Agent by using /. Custom slash commands can be used only in agent mode.
| Command Type | Command File Storage Path | Priority and Overriding Relationship | Description |
|---|---|---|---|
| Project | Root directory of the current project: ./codeartsdoer/commands/ | The priority of a command depends on its loading sequence. Commands loaded later have higher priority and will override previously loaded commands with the same name. | Valid only for the current project. |
| User | Local %USERPROFILE%/.codeartsdoer/commands/ | Valid for all projects of the current user. |
User-level configurations apply globally to all projects. Project-level configurations take effect only to the current project. Both can be used simultaneously, but care must be taken regarding potential naming conflicts.
- Log in to CodeArts Agent IDE as instructed in Quick Start.
- Create a dedicated directory named commands to store related command files.
In the explorer, right-click the .codeartsdoer directory of the corresponding project and choose New Folder. Enter commands in the displayed input box.
- Create a Markdown file to define commands.
- Right-click the created commands directory and choose New File from the shortcut menu to create a Markdown file.
To ensure clear mapping between commands and functions, name Markdown files according to the following rules:
- File name as the slash command
The file name of a Markdown file should be identical to its corresponding slash command. For example, if the file creation function is executed via the /create-file command, the Markdown file corresponding to this function should be named create-file.md.
- Single file for a single function
Each Markdown file should correspond to only one function. Avoid mixing descriptions of multiple functions within a single file to keep the content concise.
Figure 1 Creating create-file.md
- File name as the slash command
- Define the file content and save it.
In CodeArts Agent, you can use the $ARGUMENTS placeholder to capture all parameters passed to the command, or use positional parameters like $N to accurately access a specific parameter. For example, if you want to define a command that creates a file based on specific parameter content, the configuration example for create-file.md is as follows:
--- description: Create a new file with the specified content --- Create a file named $1 in the directory $2, with the following content: $3
In the preceding example, three location parameters are defined. $1 indicates the name of the file to be created, $2 indicates the file storage path, and $3 indicates the file content.
- Right-click the created commands directory and choose New File from the shortcut menu to create a Markdown file.
- After the file is saved, restart the IDE for the configuration to take effect.
Restart CodeArts Agent IDE. After login, open the chat panel. Switch to the agent mode and enter a / in the input box. The custom project-level command /create-file is displayed in the shortcut menu.
If the target command is not displayed, terminate the Bun processes in the task manager, and then re-login to CodeArts Agent IDE.
Figure 2 Displaying the custom project-level command /create-file
- Create a Markdown file to define commands. Windows 11 (x64) is used as an example.
- Create a commands folder in the local %USERPROFILE%/.codeartsdoer/ directory (C:\Users\Your username\.codeartsdoer).
- Go to the commands directory and create a Markdown file named delete-file.md.
- Define the file content and save it.
In CodeArts Agent, you can use the $ARGUMENTS placeholder to capture all parameters passed to the command, or use positional parameters like $N to accurately access a specific parameter. For example, if you want to define a command that deletes a file based on specific parameter content, the configuration example for delete-file.md is as follows:
--- description: Delete an existing file --- Delete the file named $1 located in the directory $2.
$1 indicates the name of the file to be deleted, and $2 indicates the path of the file.
- Restart CodeArts Agent IDE. After login, open the chat panel. Switch to the agent mode and enter a / in the input box. The custom user-level command /delete-file is displayed in the shortcut menu.
If the target command is not displayed, terminate the Bun processes in the task manager, and then re-login to CodeArts Agent IDE.
Using Custom Commands
- Log in to CodeArts Agent IDE as instructed in the quick start.
- At the bottom of the input box on the chat panel, choose Agent to switch to the agent mode.
- In the input box, enter a / and choose the custom command /create-file from the shortcut menu.
- Enter the command and click
. In the preceding example, create-file.md defines three location parameters: file name ($1), storage path ($2), and file content ($3). You need to pass specific values for these parameters when using the command.
Figure 3 Specifying parameter values
You only need to enter parameters here if they are defined in the Markdown file; separate multiple parameters with spaces. If the number of parameters entered exceeds the number defined in the file, the excess part will be merged into the content of the last parameter.
- After the command is executed, go to the specified directory (for example, D:\TestCode) and check whether the file and its content meet the expectation. Figure 4 File created
In the specified directory, you can view the generated file sample.txt, whose content is "Hello, world!"
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