Start free
Guide Memory

How to set up JetBrains AI Assistant rules

Updated 4 min read

The short answer

Use project rules: configure them under Settings | Tools | AI Assistant | Rules, write the guidelines as Markdown, and pick a Rule type for each file (JetBrains Help). Rule files live in the .aiassistant/rules folder in the project root (JetBrains Help). By default, project rules are automatically added to each chat session, so AI Assistant adheres to the guidelines (JetBrains Help).

On this page10 sections
  1. What project rules do
  2. Create a project rules file
  3. Choose a rule type
  4. When rules are applied
  5. Check that your rules were used
  6. What belongs in a rules file
  7. Model Context Protocol and KnowMan
  8. Where KnowMan fits
  9. Use the hosted KnowMan server
  10. Questions people ask

What project rules do

Project-specific rules help AI Assistant better understand your code, preferred tools, and coding conventions (JetBrains Help). Defining these rules improves the relevance of AI responses and keeps suggestions aligned with your project setup (JetBrains Help). This page of the documentation applies to AI Assistant 2026.2 (JetBrains Help).

Create a project rules file

Open **Settings | Tools | AI Assistant | Rules** and click New Project Rules File, then provide a name for the file (JetBrains Help). The file is created in the .aiassistant/rules folder in the project root (JetBrains Help). Add your guidelines to the file as Markdown (JetBrains Help). Then switch to the created file in the editor and select its Rule type (JetBrains Help).

Choose a rule type

**Always** is applied automatically to all chat sessions, so the assistant always takes the guidelines into consideration (JetBrains Help). **Manually** is applied only when explicitly invoked in the chat, and manual rules can also be added via the Add attachment action (JetBrains Help).

**By model decision** is applied when the model considers the rule relevant, and you must provide an Instruction, for example to apply the rule only when you work with Java files (JetBrains Help). **By file patterns** is applied when a file referenced in the chat matches a pattern such as *.kt or src/**, entered in the Patterns field (JetBrains Help). **Off** leaves the rule inactive and not applied (JetBrains Help).

When rules are applied

By default, project rules are automatically added to each chat session, so AI Assistant adheres to the guidelines (JetBrains Help). You can customize this behavior, for example apply rules only to specific files, invoke them manually, or let the model decide when to use them (JetBrains Help). Once configured, AI Assistant uses the rules when providing responses (JetBrains Help).

Check that your rules were used

To check whether rules were applied, expand the list of attachments at the beginning of the AI Assistant's response (JetBrains Help).

What belongs in a rules file

The example rule file in the documentation covers areas like naming, style, structure, and tooling, including following project-specific tooling or linters (JetBrains Help). Project rules concern chat mode; agent behavior is configured separately via the Agent instructions section (JetBrains Help).

Model Context Protocol and KnowMan

The project rules documentation lists Model Context Protocol (MCP) as a related topic (JetBrains Help). KnowMan provides a standalone stdio MCP server, package @knowman/mcp, started with npx -y @knowman/mcp on Node 22 or newer (MCP server knowledge base).

It talks to KnowMan's HTTP API with a Bearer key in the KNOWMAN_API_KEY environment variable, created in the web app at Settings > Connections > Connect an AI agent, or by running npx -p @knowman/mcp knowman login once (MCP server knowledge base). It runs locally with npx -y @knowman/mcp or as a hosted server at https://api.knowman.io/mcp with OAuth sign-in or an API key (MCP server knowledge base).

Where KnowMan fits

Project rules are written guidelines, added to chat sessions as Markdown (JetBrains Help). KnowMan works as a saved library: it saves articles and links, reads and tags them, answers questions with citations, and keeps memories such as claims, decisions, and playbooks (personal knowledge base).

Through its MCP server, an agent gets tools for that library: kb_search searches saved items by keyword or meaning, kb_ask answers with citations, and kb_memories returns saved claims, decisions, and playbooks (give your AI context). The server also offers kb_get_item, kb_save, and kb_recent (give your AI context). For more, see persistent memory for AI agents and a knowledge base for AI agents.

Use the hosted KnowMan server

In clients that support remote MCP servers, add https://api.knowman.io/mcp and sign in with OAuth on the KnowMan consent page, or send an API key as an Authorization: Bearer <key> header. Then ask the assistant to search or save KnowMan content.

The open-source local client is also available on GitHub. It can run locally with npx -y @knowman/mcp for clients that use a local stdio MCP server.

Questions people ask

Where are JetBrains AI Assistant rules stored?

Rule files live in the .aiassistant/rules folder in the project root, and you add the guidelines to the file as Markdown (JetBrains Help). You create them from Settings | Tools | AI Assistant | Rules (JetBrains Help).

How do I make a rule apply in every chat?

Set its Rule type to Always; it is then applied automatically to all chat sessions (JetBrains Help). Rules are added to each chat session by default (JetBrains Help).

Can a rule apply only to Kotlin files?

Yes. Use the By file patterns type and enter a pattern such as *.kt or src/** in the Patterns field (JetBrains Help). By model decision is an alternative, with an Instruction that can scope the rule, for example to Java files (JetBrains Help).

Do project rules also configure the agent?

No. Project rules concern chat mode, and agent behavior is configured separately via the Agent instructions section (JetBrains Help). The project rules page points to that section for agent configuration (JetBrains Help).

Rules for the project, memory for the rest

KnowMan saves articles and links, answers questions with citations, and keeps memories such as claims, decisions, and playbooks, available to your AI over MCP (persistent memory for AI agents). Pro is free to try for 14 days, no credit card (create your account).

Start free

Every new account starts with 14 days of Pro. No credit card.