What is Kimi Code memory?
Kimi Code keeps project rules in instruction files and keeps long chats going with compaction. You write AGENTS.md files, and Kimi Code puts them into the prompt. When a chat grows past the context window, it summarizes the older part. The Kimi Code docs we read on 2 December 2026 describe no store of notes that carries over between sessions, so for that you add a plugin or a memory server.
Two names exist. Kimi Code is the product this page covers, with its own docs at moonshotai.github.io/kimi-code. The older Kimi CLI has separate docs at moonshotai.github.io/kimi-cli. The file locations below come from the Kimi Code docs.
Where Kimi Code reads its instructions
The agents docs (moonshotai.github.io/kimi-code/en/customization/agents, read 2 December 2026) list these files:
| File | Applies to | Notes |
|---|---|---|
$KIMI_CODE_HOME/AGENTS.md (default ~/.kimi-code/AGENTS.md) | You, in every project | Kimi-specific global rules; moves with KIMI_CODE_HOME |
~/.agents/AGENTS.md | You, in every tool that reads it | Generic rules shared with other agents |
AGENTS.md at the project root | Everyone who works in the repo | Loaded with the project |
.kimi-code/AGENTS.md in the project | Everyone who works in the repo | Kimi-specific project rules |
The file contents go into the prompt as reference data. A project file does not replace the system prompt.
Agent override files are different: a project file named agent.md with override: true replaces the whole
default system prompt. Review .kimi-code/agents/ and .agents/agents/ in a repo you did not write before you
run Kimi Code in it.
The config docs say the watchers reload AGENTS.md, skills and MCP settings when they change, so a running
session can pick up an edit. The watcher is on by default; you can turn it off in the config.
How compaction works
Compaction replaces the older part of a chat with a summary. The sessions guide (moonshotai.github.io/kimi-code/en/guides/sessions, read 2 December 2026) describes two ways:
- Automatic: Kimi Code compacts when the context gets close to the limit. The setting
reserved_context_sizesets how much room stays free for the reply. A failed compaction is retried up tocompaction_max_attempts, which defaults to 5. - Manual:
/compact, optionally with instructions, for example/compact Keep the discussion about database migrations.
The docs say the summary keeps key information and drops the rest. If the exact details of a chat matter, compact by hand with clear instructions, or start a new session and paste the facts in.
The docs describe compaction inside a session. They do not say it carries facts into the next session.
The hook events PreCompact and PostCompact fire before and after a compaction (hooks guide, read 2 December 2026).
Hooks you can use
Kimi Code hooks run commands at set points. The ones that matter for memory:
SessionStartcan returnadditionalContext, which the docs say goes to the model but not to the chat screen.PreCompactandPostCompactrun around each compaction. Their return values are ignored.
Adding Hindsight to Kimi Code
The Hindsight Coding Agents package lists Kimi Code among its 22 supported CLI agents. Its docs (hindsight.vectorize.io/sdks/integrations/coding-agents, read 2 December 2026) give this install:
- Run
npx @vectorize-io/hindsight-coding-agents install kimi-code. - The installer adds native hooks to
~/.kimi-code/config.tomland MCP settings to~/.kimi-code/mcp.json, plus a companion skill. IfKIMI_CODE_HOMEis set, these go there instead. - Work as usual. Capture is automatic, with no setup command.
By default each repo gets one bank, coding-agent::{gitProject}, shared with the other coding agents you install.
Coding Agents 0.9.0 (30 November 2026) says Kimi Code reports its compactions, so memory comes back after one:
the first prompt after a compaction gets the recalled memory again. sessionContext pins pages and mental models at
the start of a session. Source: hindsight.ai/oss/blog/2026/11/30/coding-agents-090.
The Hindsight docs say Kimi’s SessionStart hook cannot reach the model, so the session briefing is silent there,
and recalled memory arrives on the first prompt instead. The Kimi Code hooks docs say the opposite: a SessionStart
hook that returns additionalContext injects text into the model. We could not settle which is right, so check it
on your install before you rely on the session briefing.
Limits:
- Memory lives in Hindsight Cloud (needs an API key), a server you run, or a local daemon. Pick one before you install.
- The plugin writes to your home folder config (
~/.kimi-code/), so check those two files after install. - We found no independent benchmark of this plugin with Kimi Code in the sources we checked, so this page makes no performance claim.
Where this fits
Use AGENTS.md for rules that rarely change: build commands, code style, folders to leave alone. Use a memory bank for facts from the work: past decisions, the cause of a bug, a setup step that took an hour. Kimi Code’s built-in files do the first job; a memory bank does the second.
For the same question on other tools, see AI coding agent memory, OpenCode memory and Claude Code memory.
Sources
- Kimi Code agents and instruction files: https://moonshotai.github.io/kimi-code/en/customization/agents (read 2 December 2026)
- Kimi Code sessions and compaction: https://moonshotai.github.io/kimi-code/en/guides/sessions (read 2 December 2026)
- Kimi Code config reference: https://moonshotai.github.io/kimi-code/en/configuration/config-files (read 2 December 2026)
- Kimi Code hooks: https://moonshotai.github.io/kimi-code/en/customization/hooks (read 2 December 2026)
- Hindsight Coding Agents, Kimi Code entry: https://hindsight.vectorize.io/sdks/integrations/coding-agents (read 2 December 2026)
- Hindsight Coding Agents 0.9.0: https://hindsight.ai/oss/blog/2026/11/30/coding-agents-090 (30 November 2026)