Lingma supports setting project-specific rules (Project Rules). They are stored in the .lingma/rules directory and apply only to the current project. Setting Project Rules helps the model better understand and adapt to your coding preferences and project frameworks.
the Lingma rule library.
Prerequisites
To use this feature, update Lingma to one of the following versions or download Lingma IDE. For instructions, 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: Installed.
Rule limitations
A single rule file is limited up to 10,000 characters. Any content that exceeds this limit is automatically discarded.
Use natural language to describe rules. Images and links are not supported.
Rule synchronization
Rule files are stored in the project directory. They can be shared and synchronized within your team using version control tools such as Git.
Adding the .lingma/rules directory to project's .gitignore file restricts the application of rules to the local environment only.
Rule types
Rules are divided into the following 4 types based on their import and trigger methods.
Type | Trigger method | Applicable scenarios |
Manual | This rule takes effect only when it is manually imported with | Used in executing one-time or specific workflows, or apply custom prompts. |
Model Decision | When in Agent mode, or enabling tools in Ask mode, the model decides whether to apply the rule based on rule descriptions. | Used when the model decides what rules to be effective in what scenarios, such as effective in unit tests or comments generation. |
Always | Applies to all requests in AI chats and inline chat. | Used to set project-level standards, such as coding style, preferred format, or default response role. |
Specific Files | In AI chat and inline chat, this rule applies to all files that match the specified file pattern, such as | Used to create rules for specific languages or directories. For example, you can create a rule that applies to a specific language or a specific folder. |
Set and apply rules
The configuration interface and operations differ slightly among Integrated Development Environments (IDEs). The following sections describe how to set and use project-specific rules in VS Code, JetBrains, Visual Studio, and Lingma IDE.
If a rule conflicts with a memory, the rule takes precedence.
Set rules
Lingma IDE
In the upper-right corner of Lingma IDE, click the user icon
or use the keyboard shortcut (⌘⇧,for macOS orCtrlShift,for Windows), and then select Settings.In the navigation pane on the left, click Rules.
Click Add.
In the search bar at the top, enter a unique rule name and press Enter.
Select a rule type:
Manual: Takes effect only when manually imported with @rule.
Model Decision: Enter a description of the scenario where you want the rule to apply.
Specific Files: Enter file path wildcard characters, separated by commas. For example,
*.md,src/*.java.Always: Applies to all requests in AI chats and inline sessions.
Close the window to save the changes.
VS Code
In VS Code, use #rule to display the rule list.
In the IDE sidebar, click
to open AI Chat.On the AI Chat page, click your profile picture in the upper-right corner and select Personal Settings from the drop-down menu.
On the Personal Settings page, click Rules.

On the Rules page, you can add, edit, or delete rules.
Add a rule: Click the
+icon in the upper-right corner. In the dialog box that appears, enter the rule information and click Add Now.
Rule Name: Enter a rule name. The name serves as the unique identifier and the rule's file name.
Rule Type: Select the type of rule to configure. The following four types are supported:
Manual: Takes effect only when manually imported with
#rulein an AI chat or inline session.Model Decision: After selecting this type, enter a Description for the rule. The description should specify the scenario where the rule applies, such as for generating unit tests or comments. The model uses this description to determine whether to apply the rule.
Specific Files: After you select this type, enter file path wildcard characters. Separate multiple patterns with commas. Example:
*.md,src/*.java.Always: Applies to all requests in AI chat and inline chat.
Edit or delete a rule:

JetBrains IDE plugin
In JetBrains IDEs, use @rule to display the rule list.
The following figure shows how to open the environment settings in IntelliJ IDEA. In the Settings window, click Lingma and then locate the AI Rules for editing.
Best practices
Keep the following in mind when configuring rules:
Simple and clear: Keep rules concise, clear, and specific. Lingma might get confused at long or vague rules.
Use structured language: Format your rules with bullets, numbered lists, and Markdown. These formats are easier for Lingma to understand than long paragraphs.
Provide examples: Including "good code examples" (Do's) in your rules helps the model better understand your intent.
Iterate and optimize: After you create a rule, test its effectiveness with actual code generation and Q&A. Continuously iterate on and optimize your rule descriptions based on the model's feedback.
For more information about best practices for system prompts, see the Lingma rule library.
