# Kilo Code memory: what persists and what to add

[Kilo Code](https://www.knowman.io/guides/teach-kilo-code-your-knowledge) applies [custom instructions](https://www.knowman.io/guides/give-your-ai-context) across sessions: per-agent prompts injected into the agent's system prompt, instruction files such as AGENTS.md that apply to every session, and extra rule sources in `kilo.jsonc` ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). They personalize how Kilo Code behaves, shaping responses, coding style and decision-making, and you can scope them per agent, per project or globally at `~/.config/kilo/AGENTS.md` ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). For [saved reading](https://www.knowman.io/guides/ai-article-saver), decisions and playbooks that grow over time, KnowMan provides a local MCP server an agent can query, with tools such as `kb_search`, `kb_ask` and `kb_memories` ([KnowMan](https://www.knowman.io/guides/mcp-server-knowledge-base)).

## What Kilo Code remembers between sessions

Custom instructions personalize how Kilo Code behaves, shaping responses, coding style and decision-making ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). Per-agent prompts apply across all sessions using that agent, and project-level instructions apply to every session, so the guidance you set is there next time ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

Both the VSCode extension and the CLI support custom instructions, though the mechanisms differ ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). The extension layers them: per-agent prompts in the Settings UI, instruction files auto-discovered in your project, and global config ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

## Set a per-agent prompt

Each agent can have its own custom prompt, configured in the settings UI. The prompt is injected into the agent's system prompt and applies across all sessions that use that agent ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

This suits stable preferences, such as coding conventions or how you want answers formatted. For a wider look at steering agents with written context, see [give your AI context](https://www.knowman.io/guides/give-your-ai-context).

## Use AGENTS.md at the project root

Kilo Code automatically discovers instruction files at your project root and in parent directories ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). AGENTS.md is the primary instruction file, CLAUDE.md is supported for compatibility, and CONTEXT.md provides additional project context. Any of these files at the project root gives project-wide instructions ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

Project-level instructions load before global instructions and apply to every session ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). AGENTS.md files also work in subdirectories: one loads dynamically when the agent's Read tool accesses a file in that directory, and its contents are injected into the conversation. A subdirectory file supplements root instructions for tasks in that directory, so it does not need to repeat them ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

## Global instructions for all projects

For instructions that apply across all projects, place an AGENTS.md file in the global config directory. In Kilo Code this is `~/.config/kilo/AGENTS.md` ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

There is also a [Claude-compatible global fallback](https://www.knowman.io/guides/claude-code-memory) at `~/.claude/CLAUDE.md`, used until Claude Code Migration has been attempted. Attempting migration ends that fallback, while project-level CLAUDE.md files keep working ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

## Add rule sources in kilo.jsonc

The `instructions` key in `kilo.jsonc` accepts an array of paths, globs or URLs pointing to extra instruction files. You manage these in Settings → Agent Behaviour → Rules ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

URL-based sources are fetched at session start with a 5-second timeout. If a URL is unreachable, the source is silently skipped ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). Legacy `.kilocoderules` files from the VSCode extension are still loaded via auto-migration, and AGENTS.md is recommended for new projects ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

## The limits to plan around

These features inject text into prompts. Per-agent prompts go into the system prompt, and instruction files load per session or on directory access ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). The documented edges are concrete: URL rules have a 5-second timeout and are silently skipped when unreachable ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)), the `~/.claude/CLAUDE.md` global fallback ends once Claude Code Migration is attempted ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)), and subdirectory files load only when the Read tool touches that directory ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

For material that accumulates, such as saved reading, decisions and playbooks, a separate library the agent can query is one way to handle it. KnowMan saves articles and links, reads and tags them, and keeps memories such as claims, decisions and playbooks ([KnowMan](https://www.knowman.io/guides/personal-knowledge-base)). The broader pattern is covered in [persistent memory for AI agents](https://www.knowman.io/guides/persistent-memory-for-ai-agents).

## Where KnowMan fits

KnowMan 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 ([KnowMan](https://www.knowman.io/guides/personal-knowledge-base)). Its MCP server is a local [stdio server](https://www.knowman.io/guides/what-is-an-mcp-server), package `@knowman/mcp`, started with `npx -y @knowman/mcp` on Node 22 or newer ([KnowMan](https://www.knowman.io/guides/mcp-server-knowledge-base)).

Through the server an agent gets tools including `kb_search` to search [saved items](https://www.knowman.io/guides/how-to-save-articles) by keyword or meaning, `kb_ask` to answer questions with citations, and `kb_memories` to read saved claims, decisions and playbooks ([KnowMan](https://www.knowman.io/guides/mcp-server-knowledge-base)). A practical split is to keep AGENTS.md for rules and preferences, and let KnowMan hold the growing library. KnowMan runs locally with `npx -y @knowman/mcp` and also as a hosted server at https://api.knowman.io/mcp, where you sign in with OAuth or send an API key ([KnowMan](https://www.knowman.io/guides/mcp-server-knowledge-base)). The general pattern is covered in [an MCP server knowledge base](https://www.knowman.io/guides/mcp-server-knowledge-base), and the same idea applies to [Claude Code](https://www.knowman.io/guides/claude-code-knowledge-base).

## Use the hosted KnowMan server in Kilo Code

KnowMan runs as a hosted server at https://api.knowman.io/mcp in addition to the local stdio server. In clients that support remote MCP servers you add the server URL and sign in with OAuth: the client opens the KnowMan consent page, you approve the requested scopes, and access tokens refresh automatically.

The alternative is an API key, created in your KnowMan settings, sent with each request as an `Authorization: Bearer <key>` header. Both paths expose the same six tools, from `kb_search` and `kb_ask` to `kb_save`, so the split between AGENTS.md rules and the KnowMan library stays the same.

The general remote-server pattern is described in [an MCP server knowledge base](https://www.knowman.io/guides/mcp-server-knowledge-base). For the local server instead, run `npx -y @knowman/mcp`; the open-source client lives at [knowman-mcp on GitHub](https://github.com/Essatt/knowman-mcp).

## Questions

### Does Kilo Code have memory across sessions?

Yes, through custom instructions. Per-agent prompts are injected into the agent's system prompt and apply across all sessions using that agent, and project-level instructions apply to every session ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). A global `~/.config/kilo/AGENTS.md` extends instructions to all projects ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

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

AGENTS.md is the primary instruction file for Kilo Code, auto-discovered at your project root and in parent directories ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). CLAUDE.md is supported for compatibility and CONTEXT.md adds project context ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

### Can Kilo Code load rules from a URL?

Yes. The `instructions` key in `kilo.jsonc` accepts paths, globs and URLs pointing to extra instruction files ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)). URL sources are fetched at session start with a 5-second timeout, and unreachable URLs are silently skipped ([Kilo Code docs](https://kilo.ai/docs/customize/custom-instructions)).

### How do I give Kilo Code access to my saved reading?

KnowMan runs locally as a stdio server started with `npx -y @knowman/mcp`, and it exposes tools such as `kb_search`, `kb_ask` and `kb_memories` ([KnowMan](https://www.knowman.io/guides/mcp-server-knowledge-base)). It also runs as a hosted server at https://api.knowman.io/mcp, where you sign in with OAuth or send an API key ([KnowMan](https://www.knowman.io/guides/mcp-server-knowledge-base)). General setup is described in [an MCP server knowledge base](https://www.knowman.io/guides/mcp-server-knowledge-base); this page does not include steps specific to Kilo Code.

## 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)

- [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 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)
- [How to give Qwen Code better memory](https://www.knowman.io/guides/qwen-code-memory)

## More for Kilo Code

- [KnowMan MCP server for Kilo Code](https://www.knowman.io/integrations/kilo-code)
- [How to teach Kilo Code your knowledge](https://www.knowman.io/guides/teach-kilo-code-your-knowledge)

## Rules for behavior, a library for the rest

Try KnowMan Pro free for 14 days, no credit card needed. Save what you read, keep decisions and playbooks, and use KnowMan to ask questions with citations across your library. [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/kilo-code-memory
