# How to set up JetBrains AI Assistant rules

Use [project rules](https://www.knowman.io/guides/knowledge-base-for-ai-agents): configure them under Settings | Tools | [AI Assistant](https://www.knowman.io/guides/give-your-ai-context) | Rules, write the guidelines as Markdown, and pick a Rule type for each file ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Rule files live in the `.aiassistant/rules` folder in the project root ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). By default, project rules are automatically added to each chat session, so AI Assistant adheres to the guidelines ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## What project rules do

Project-specific rules help AI Assistant better understand your code, preferred tools, and coding conventions ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Defining these rules improves the relevance of AI responses and keeps suggestions aligned with your project setup ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). This page of the documentation applies to AI Assistant 2026.2 ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). The file is created in the `.aiassistant/rules` folder in the project root ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Add your guidelines to the file as Markdown ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Then switch to the created file in the editor and select its Rule type ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## Choose a rule type

**Always** is applied automatically to all chat sessions, so the assistant always takes the guidelines into consideration ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). **Manually** is applied only when explicitly invoked in the chat, and manual rules can also be added via the Add attachment action ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

**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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). **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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). **Off** leaves the rule inactive and not applied ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## When rules are applied

By default, project rules are automatically added to each chat session, so AI Assistant adheres to the guidelines ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Once configured, AI Assistant uses the rules when providing responses ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Project rules concern chat mode; agent behavior is configured separately via the Agent instructions section ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## Model Context Protocol and KnowMan

The project rules documentation lists [Model Context Protocol](https://www.knowman.io/guides/what-is-an-mcp-server) (MCP) as a related topic ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). KnowMan provides a standalone stdio [MCP server](https://www.knowman.io/guides/mcp-server-knowledge-base), 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). KnowMan works as a saved library: it saves articles and links, reads and tags them, [answers questions](https://www.knowman.io/guides/ai-knowledge-base) with citations, and keeps memories such as claims, decisions, and playbooks ([personal knowledge](https://www.knowman.io/guides/personal-knowledge-base) base).

Through its MCP server, an agent gets tools for that library: `kb_search` searches [saved items](https://www.knowman.io/guides/how-to-save-articles) 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](https://www.knowman.io/guides/persistent-memory-for-ai-agents) and [a knowledge base for AI agents](https://www.knowman.io/guides/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](https://github.com/Essatt/knowman-mcp). It can run locally with `npx -y @knowman/mcp` for clients that use a local stdio MCP server.

## Questions

### 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). You create them from Settings | Tools | AI Assistant | Rules ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

### 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). Rules are added to each chat session by default ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

### 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). By model decision is an alternative, with an Instruction that can scope the rule, for example to Java files ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

### 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](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)). The project rules page points to that section for agent configuration ([JetBrains Help](https://www.jetbrains.com/help/ai-assistant/configure-project-rules.html)).

## Related guides

- [Persistent Memory for AI Agents](https://www.knowman.io/guides/persistent-memory-for-ai-agents)

- [Connect your knowledge base through KnowMan's MCP server](https://www.knowman.io/guides/mcp-server-knowledge-base)

- [How to Give Your AI Context from What You Read](https://www.knowman.io/guides/give-your-ai-context)

- [What Is a Knowledge Base for AI Agents?](https://www.knowman.io/guides/knowledge-base-for-ai-agents)

## More in this topic

- [How to give opencode context with AGENTS.md](https://www.knowman.io/guides/opencode-memory)
- [How to give OpenClaw better memory](https://www.knowman.io/guides/openclaw-memory)
- [Kilo Code memory: what persists and what to add](https://www.knowman.io/guides/kilo-code-memory)

## More for JetBrains AI Assistant

- [Connect KnowMan to JetBrains AI Assistant](https://www.knowman.io/integrations/jetbrains)
- [How to teach JetBrains AI Assistant your knowledge](https://www.knowman.io/guides/teach-jetbrains-your-knowledge)

## 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](/guides/persistent-memory-for-ai-agents)). Pro is free to try for 14 days, no credit card ([create your account](https://app.knowman.io/signup)).

[Start free](https://app.knowman.io/signup)

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

Source: https://www.knowman.io/guides/jetbrains-memory
