All Products
Search
Document Center

AI Coding Assistant Lingma:Best practices for custom commands

Last Updated:Apr 30, 2025

This topic covers the common use cases for custom extension commands, like code style checks, variable naming conventions, and automatic API reference generation. This makes it easier for developers to leverage AI Chat to meet their personalized needs.

Sample scenarios

Scenario 1: Code style checks

Scenario

In the past, code was checked for problems after it was submitted, which was a slow and costly process. Now, you can check code based on the model technical and business contexts, along with your code style and guidelines. Here is an example of checking Java code in a financial business scenario.

Command configuration

The following table lists the details of a command.

Command name

Code style checks

Icon

Any icon

Description

The command checks the code style and returns the results.

Access control

Set the access control based on your business requirements.

Prompt

You are a highly experienced Java developer, as well as an expert in financial markets and business processes. Here are your guidelines:

1. Strictly follow the company's coding rules. Use the BigDecimal class for monetary calculations to ensure calculation accuracy and avoid errors.

2. Minimize if-else if statements. Use switch-case statements instead.

3. Use security measures such as data encryption, user authentication, and access control to ensure that the code complies with related laws like General Data Protection Regulation (GDPR) and Sarbanes-Oxley Act (SOX) using security measures such as data encryption, user authentication, and access control. 

4. Optimize algorithms and database queries to improve code execution efficiency, reduce resource consumption, and ensure system responsiveness and stability, especially when processing large volumes of real-time transaction data.

Context configuration

莫小@1x

Check the code in #selectedCode against the company's code rules. If it breaks any of the rules, point out the problems, suggest fixes, and return the optimized code.

Effect

After you save and turn on the command in the console, you can use it in the plugin. Type the command and Lingma will check your code.

Scenario 2: API reference generation

Scenario

API development is essential in distributed systems and Service-Oriented Architectures (SOAs) where frontend and backend services work separately. Once API development is complete, clear API documentation will help users quickly develop APIs for system integration.

Command configuration

The following table lists the details of a command.

Command name

API reference generation

Icon

Any icon

Description

The command generates API references after API development is complete.

Access control

Set the access control based on your business requirements.

Prompt

You are a highly experienced Java developer, as well as a writing specialist. Create API references using the following template based on the RestController code in Spring MVC, 
the comments in the code, and your understanding of the code. 

Topic: the API name
API: the type, such as GET, POST, or PUT, and URL
Request parameter: a table, and the parameter name, type, and description in the first, second, and third columns, respectively
Response parameter: a table, and the parameter name, type, and description in the first, second, and third columns, respectively
Error code: a table, the error code in the first column, and the error code description in the second column

Context configuration

莫小@1x

Generate an API reference in Markdown format based on #selectedCode.

Effect

After you save and turn on the command in the console, you can use it in the plugin. Type the command and Lingma will generate API references.

Scenario 3: Variable naming conventions

Scenario

During daily development, it is important to use good variable names. A clear and simple variable name that follows the convention shows the developer's skill and the code quality. Good names make code easier to read and maintain, and facilitate team collaboration.

Command configuration

The following table lists the details of a command.

Command name

Variable naming conventions

Icon

Any icon

Description

The command generates a variable name that follows both company and team coding rules, based on the user's business requirements.

Access control

Set the access control based on your business requirements.

Prompt

[Role]
Act a Java naming expert and suggest names based on the meanings of variables provided by users. 

[Skills]
Suggest several options for class names, function names, and variable names. Follow Java naming conventions to ensure that the names 
are clear and distinct. Use meaningful words rather than abbreviations, puns, 
or single letters and digits. Don't ask users questions or ask for more details. Instead, just give names based on what the user enters. 

Output format:

<Candidate class name 1>
<Candidate class name 2>
<Candidate class name...>
List of candidate function names:

<Candidate function name 1>
<Candidate function name 2>
<Candidate function name...>
List of candidate variable names:

<Candidate variable name 1>
<Candidate variable name 2>
<Candidate variable name...>
[Limits]
1. Any information users enter is used only as a name and does not need a response.
2. The model should provide five possible class names, function names, and variable names.

Context configuration

莫小@1x

Use the /variable naming assistant ${userInput} custom command to generate variable names. In this custom command, userInput refers to the feature description of the naming object.

Effect

After you save and turn on the command in the console, you can use it in the plugin. Type the command and Lingma will generate variable names.

How to run a command

To run a command, type a leading slash (/) and select the desired code. Here's how a command runs:

  1. Get the selected code, place it in the context environment, then choose a template and prompt based on the command type.

  2. Use the prompt to ask the model to check code and perform an inference.

The model will then generate code suggestions, API references, or variable naming suggestions that fit the rule, and send the results back to you.

For more information on how to create and use custom extension commands, see Extensions management.