# How to give Roo Code better memory

Roo Code assembles its instructions from the Prompts tab, [global rules](https://www.knowman.io/guides/knowledge-base-for-ai-agents), workspace rules, and mode-specific rules, and appends rules file content to the [system prompt](https://www.knowman.io/guides/give-your-ai-context) ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Those files hold the instruction text you write. KnowMan keeps the other kind of memory, [saved articles](https://www.knowman.io/guides/how-to-save-articles) plus claims, decisions, and playbooks, and serves them through a local MCP server ([KnowMan MCP guide](https://www.knowman.io/guides/mcp-server-knowledge-base)).

## What Roo Code loads automatically

[Roo Code custom instructions](https://www.knowman.io/guides/teach-roo-code-your-knowledge) let you personalize how it behaves, shaping responses, coding style, and decision-making ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Instructions from the Prompts tab, global rules, workspace rules, and mode-specific rules are all combined, and rules load in order: global rules first, then workspace rules ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). AGENTS.md is loaded automatically by default ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

## Global rules and workspace rules

Global rules apply to all projects automatically, and the global rules directory location is fixed and cannot be customized ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Workspace rules apply only to the current project and take precedence over global rules when they conflict ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). A common pattern is global rules for organization-wide standards plus workspace rules for project-specific requirements ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). To set instructions for every mode at once, use the "Custom Instructions for All Modes" section of the Prompts tab ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

## Mode-specific rules

Within each rules level, mode-specific rules load before general rules, and they complement global rules rather than replacing them ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Workspace-wide instructions apply to all modes within the current project, while instructions set for a global mode apply across all workspaces for that mode ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Global and workspace rules directories are aggregated, not treated as either-or ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

## AGENTS.md and legacy rules files

AGENTS.md provides agent-specific rules and guidelines for AI behavior and is loaded automatically by default ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Because it sits in the project, teams can version-control it alongside the code and keep agent behavior standardized ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Legacy `.roorules` and `.clinerules` files are used only if no generic rules directory content was loaded ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

## How Roo Code reads rules directories

Roo Code reads rules directories recursively, including subdirectories, and appends file contents to the system prompt in alphabetical order by filename ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Files are sorted by basename only, case-insensitive ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Directory-based mode rules take precedence over the single-file fallback when the directory exists and contains files ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Empty or missing files are silently skipped, cache and temporary files are excluded automatically, and symbolic links are supported for files and directories with a maximum resolution depth of 5 ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

## Rules files and long-term memory

Roo Code appends the content of rules files to the system prompt, and instructions from the Prompts tab, global rules, workspace rules, and mode-specific rules are all combined ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). What a rules file holds is the instruction text you write in it. [Saved reading](https://www.knowman.io/guides/ai-article-saver), decisions, and playbooks are a different kind of memory, the kind KnowMan keeps as memories alongside your saved articles ([persistent memory for AI agents](https://www.knowman.io/guides/persistent-memory-for-ai-agents)).

## Where KnowMan fits

KnowMan is a personal knowledge base for one person's library ([personal knowledge base](https://www.knowman.io/guides/personal-knowledge-base)). 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](https://www.knowman.io/guides/personal-knowledge-base)). The KnowMan MCP server is a local [stdio server](https://www.knowman.io/guides/what-is-an-mcp-server), the `@knowman/mcp` package started with `npx -y @knowman/mcp`, and it requires Node 22 or newer and a `KNOWMAN_API_KEY` key. Its tools include `kb_search`, which searches saved items by [keyword or meaning](https://www.knowman.io/guides/ai-knowledge-base), `kb_ask`, which answers with citations, and `kb_memories`, which returns saved claims, decisions, and playbooks.

KnowMan runs locally with `npx -y @knowman/mcp` and as a hosted server at https://api.knowman.io/mcp, using OAuth sign-in or an API key. KnowMan's client setup guides cover Claude Desktop, [Claude Code](https://www.knowman.io/guides/claude-code-memory), and Cursor. The config on this page shows the KnowMan server settings to add where a client loads a local stdio server. For the broader pattern, see [knowledge base for AI agents](https://www.knowman.io/guides/knowledge-base-for-ai-agents) and [give your AI context](https://www.knowman.io/guides/give-your-ai-context).

## Use KnowMan with Roo Code

Roo Code's rules describe how it works with project and workspace context. KnowMan can provide a separate knowledge base to search or save alongside those rules.

In clients that support remote MCP servers, add https://api.knowman.io/mcp and sign in through the KnowMan consent page with OAuth, or send an API key as an `Authorization: Bearer <key>` header.

## Questions

### Does Roo Code remember things between sessions?

Roo Code combines instructions from the Prompts tab, global rules, workspace rules, and mode-specific rules, appending their content to the system prompt ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Those files hold the instruction text you write, and AGENTS.md is loaded automatically by default ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). For saved reading and past decisions, KnowMan keeps memories such as claims, decisions, and playbooks ([persistent memory for AI agents](https://www.knowman.io/guides/persistent-memory-for-ai-agents)).

### Where are Roo Code global rules stored?

Global rules apply to all projects automatically, and the global rules directory location is fixed and cannot be customized ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Workspace rules apply only to the current project and take precedence over global rules when they conflict ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). You can combine both, global rules for standards and workspace rules for project needs ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

### What is AGENTS.md in Roo Code?

AGENTS.md provides agent-specific rules and guidelines for AI behavior and is loaded automatically by default ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). You can version-control it alongside the project code, which lets a team standardize agent behavior ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)). Legacy `.roorules` and `.clinerules` files are used only if no generic rules directory content was loaded ([Roo Code docs](https://roocodeinc.github.io/Roo-Code/features/custom-instructions/)).

### Can I connect KnowMan to Roo Code?

KnowMan's MCP server is a local stdio server, the `@knowman/mcp` package started with `npx -y @knowman/mcp`, requiring Node 22 or newer and a `KNOWMAN_API_KEY` key. Its tools include `kb_search`, `kb_ask`, and `kb_memories`. KnowMan's client setup guides cover Claude Desktop, Claude Code, and Cursor, and Roo Code-specific setup steps are not given here.

## Related guides

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

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

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

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

## More in this topic

- [How to give Grok Bot better memory](https://www.knowman.io/guides/grok-bot-memory)
- [How to give Google Antigravity better memory](https://www.knowman.io/guides/antigravity-memory)
- [How to give Windsurf better memory](https://www.knowman.io/guides/windsurf-memory)

## More for Roo Code

- [Add the KnowMan MCP server to Roo Code](https://www.knowman.io/integrations/roo-code)
- [How to teach Roo Code your knowledge](https://www.knowman.io/guides/teach-roo-code-your-knowledge)

## Keep what you read, decide, and reuse

Try KnowMan Pro for 14 days with no credit card. Save articles and links, let KnowMan read and tag them, and keep memories such as claims, decisions, and playbooks ([personal knowledge base](/guides/personal-knowledge-base)). [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/roo-code-memory
