All Products
Search
Document Center

AI Coding Assistant Lingma:Rule settings

Last Updated:Nov 29, 2025

Lingma supports project-specific rules. These rules are stored in the .lingma/rules directory and apply only to the current project. By setting project-specific rules, you can help the model better understand and adapt to your coding preferences, such as the project's framework and code style.

Prerequisites

To use this feature, you must update Lingma to one of the following versions or download and install Lingma IDE. For more information, see Download and install.

  • JetBrains plugin: v2.1.5 or later.

  • VS Code plugin: v2.5.16 or later.

  • Visual Studio plugin: v0.4.4 or later.

  • Lingma IDE: Downloaded and installed.

Rule limits

  • Each rule file has a maximum size of 10,000 characters. Content that exceeds this limit is automatically truncated.

  • You must use natural language to describe rules. Images and links cannot be parsed.

Rule synchronization

  • Rule files are stored in the project folder. You can share and sync them with your team using versioning tools such as Git.

  • If you want rules to apply only to your local environment, you can add the .lingma/rules folder to your project's .gitignore file.

Rule types

Rules are divided into four types based on their import and trigger methods. This lets you adapt the rules to various business scenarios.

Type

Trigger method

Scenario

Manual

This rule is triggered only when it is manually imported with #rule in an AI chat or in-line session.

Use for one-time or specific workflows, custom prompts, and other on-demand tasks.

Model Decision

When you use the agent mode in an AI chat or enable tools in AI Q&A, the model decides whether to apply the rule based on its description.

Ideal for rules that should apply only in specific scenarios, such as generating unit tests or comments.

Always

This rule applies to all requests in AI chats and in-line sessions.

For setting project-level standards, such as coding style, preferred format, or a default response role.

Specific Files

In AI chats and in-line sessions, this rule applies to all files that match the specified file pattern, such as .js or src/**/.ts.

Use wildcard characters to precisely target files. This lets you create rules for specific languages or folders, such as a validation rule for a specific folder.

Set and use rules

The configuration interface and steps differ slightly among IDEs. The following sections describe how to set and use project-specific rules in VS Code, JetBrains, Visual Studio, and Lingma IDE.

Note

If a rule conflicts with a memory, the rule takes precedence.

Set a rule

Lingma IDE

  1. In the upper-right corner of Lingma IDE, click the user icon image or use the keyboard shortcut ( , for macOS or Ctrl Shift , for Windows) to open Personal Settings.

  2. In the navigation pane on the left, click Rules.

  3. Click Add.

  4. In the search bar at the top, enter a unique rule name and press Enter.

  5. Select a rule type:

    • Manual: The rule is triggered only when it is manually imported with @rule.

    • Model Decision: Enter a description of the scenario where you want the rule to apply.

    • Specific Files: Provide a comma-separated list of file path wildcard characters. For example, *.md, src/*.java.

    • Always: The rule applies to all requests in AI chats and in-line sessions.

  6. Close the window to save the changes.

VS Code

Note

In VS Code, use #rule to display the rule list.

  1. Click the image icon in the IDE sidebar to open the AI Chat.

  2. On the AI Chat page, click your profile picture in the upper-right corner and select Personal Settings from the drop-down menu.

  3. On the Personal settings page, click Rules to go to the Rules page.

    6-3-pts (46)

  4. On the Rules page, you can add, edit, or delete rules.

    • Add a rule: Click + in the upper-right corner. In the dialog box that appears, enter the rule information and click Add Now.

      6-3-pts (47)

      • Rule Name: Enter a name for the rule. The name must be unique and is used as the file name.

      • Rule Type: The type of the rule. The following four types are supported:

        • Manual: This rule is triggered only when it is manually imported with #rule in an AI chat or in-line session.

        • Model Decision: If you select this type, you must enter a Description for the rule. In the description, specify the scenario where the rule should apply, such as when generating unit tests or comments. The model uses this information to determine whether to apply the rule.

        • Specific Files: If you select this type, you must enter file path wildcard characters. Separate multiple wildcard characters with commas. Example: *.md, src/*.java.

        • Always: This rule applies to all requests in AI chats and in-line sessions.

    • Edit or delete a rule:

      6-3-pts (51)

JetBrains IDE plugin

Note

In JetBrains IDEs, use @rule to display the rule list.

  1. Click the image icon in the IDE sidebar to open the AI Chat.

  2. On the AI Chat page, click your profile picture in the upper-right corner, and then select image > Personal Settings.

  3. On the Personal settings page, click Rules to open the Rules page.

    image

  4. On the Rules page, you can add, edit, or delete rules.

    • Add a rule: Click + in the upper-right corner. In the dialog box that appears, enter the rule information and click Add Now.

      • Name: Enter a name for the rule. This name serves as the unique identifier and file name.

      • Type: Select one of the following four rule types:

        • Manual: The rule is applied only when manually imported using #rule in a smart session or an inline session.

        • Model Decision: If you select this option, you must enter a Description for the rule. In the description, specify the scenario where the rule should apply, such as when generating unit tests or comments. The model uses the description to decide whether to apply the rule.

        • Specific Files: If you select this type, you must enter file path wildcard characters. Separate multiple wildcard characters with commas. Example: *.md, src/*.java.

        • Always: This rule applies to all requests in AI chats and in-line sessions.

    • Edit or delete a rule:

      image

Use a rule

  • Manual

    In the dialog box, enter #rule to display the rule list, and then select the required rule.

    6-3-pts (52)

  • Model Decision

    When you use the Agent mode in AI Q&A, the model decides whether to apply a Model Decision rule based on its description. As shown in the following figure, the model can dynamically call the retrieval rule tool in different scenarios.

  • Always

    This rule applies to all requests in AI chats and in-line sessions. The following figure provides an example.

  • Specific Files

    This rule applies to all files that match the wildcard pattern you define, such as .js or src/**/.ts.

Best practices

To help Lingma effectively follow your rules, follow these practices when you write rule files:

  • Keep it simple and clear: Keep rules simple, clear, and specific. Rules that are too long or ambiguous may confuse Lingma.

  • Use a structured format: Use bullets, numbered lists, and Markdown format to format your rules. These formats are easier for Lingma to understand than long paragraphs.

  • Provide examples: Including "Do" examples of good code in your rules greatly helps the model understand your intent.

  • Iterate and optimize: After creating a rule, test its effectiveness through actual code generation and Q&A. Continuously iterate and optimize your rule descriptions based on the model's feedback.

Note

image For best practices on system prompts, see the Lingma Rule Library.