|
| 1 | +# Auto Memory |
| 2 | + |
| 3 | +Auto Memory is an experimental feature that mines your past Gemini CLI sessions |
| 4 | +in the background and turns recurring workflows into reusable |
| 5 | +[Agent Skills](./skills.md). You review, accept, or discard each extracted skill |
| 6 | +before it becomes available to future sessions. |
| 7 | + |
| 8 | +<!-- prettier-ignore --> |
| 9 | +> [!NOTE] |
| 10 | +> This is an experimental feature currently under active development. |
| 11 | +
|
| 12 | +## Overview |
| 13 | + |
| 14 | +Every session you run with Gemini CLI is recorded locally as a transcript. Auto |
| 15 | +Memory scans those transcripts for procedural patterns that recur across |
| 16 | +sessions, then drafts each pattern as a `SKILL.md` file in a project-local |
| 17 | +inbox. You inspect the draft, decide whether it captures real expertise, and |
| 18 | +promote it to your global or workspace skills directory if you want it. |
| 19 | + |
| 20 | +You'll use Auto Memory when you want to: |
| 21 | + |
| 22 | +- **Capture team workflows** that you find yourself walking the agent through |
| 23 | + more than once. |
| 24 | +- **Codify hard-won fixes** for project-specific landmines so future sessions |
| 25 | + avoid them. |
| 26 | +- **Bootstrap a skills library** without writing every `SKILL.md` by hand. |
| 27 | + |
| 28 | +Auto Memory complements—but does not replace—the |
| 29 | +[`save_memory` tool](../tools/memory.md), which captures single facts into |
| 30 | +`GEMINI.md`. Auto Memory captures multi-step procedures into skills. |
| 31 | + |
| 32 | +## Prerequisites |
| 33 | + |
| 34 | +- Gemini CLI installed and authenticated. |
| 35 | +- At least 10 user messages across recent, idle sessions in the project. Auto |
| 36 | + Memory ignores active or trivial sessions. |
| 37 | + |
| 38 | +## How to enable Auto Memory |
| 39 | + |
| 40 | +Auto Memory is off by default. Enable it in your settings file: |
| 41 | + |
| 42 | +1. Open your global settings file at `~/.gemini/settings.json`. If you only |
| 43 | + want Auto Memory in one project, edit `.gemini/settings.json` in that |
| 44 | + project instead. |
| 45 | + |
| 46 | +2. Add the experimental flag: |
| 47 | + |
| 48 | + ```json |
| 49 | + { |
| 50 | + "experimental": { |
| 51 | + "autoMemory": true |
| 52 | + } |
| 53 | + } |
| 54 | + ``` |
| 55 | + |
| 56 | +3. Restart Gemini CLI. The flag requires a restart because the extraction |
| 57 | + service starts during session boot. |
| 58 | + |
| 59 | +## How Auto Memory works |
| 60 | + |
| 61 | +Auto Memory runs as a background task on session startup. It does not block the |
| 62 | +UI, consume your interactive turns, or surface tool prompts. |
| 63 | + |
| 64 | +1. **Eligibility scan.** The service indexes recent sessions from |
| 65 | + `~/.gemini/tmp/<project>/chats/`. Sessions are eligible only if they have |
| 66 | + been idle for at least three hours and contain at least 10 user messages. |
| 67 | +2. **Lock acquisition.** A lock file in the project's memory directory |
| 68 | + coordinates across multiple CLI instances so extraction runs at most once at |
| 69 | + a time. |
| 70 | +3. **Sub-agent extraction.** A specialized sub-agent (named `confucius`) |
| 71 | + reviews the session index, reads any sessions that look like they contain |
| 72 | + repeated procedural workflows, and drafts new `SKILL.md` files. Its |
| 73 | + instructions tell it to default to creating zero skills unless the evidence |
| 74 | + is strong, so most runs produce no inbox items. |
| 75 | +4. **Patch validation.** If the sub-agent proposes edits to skills outside the |
| 76 | + inbox (for example, an existing global skill), it writes a unified diff |
| 77 | + `.patch` file. Auto Memory dry-runs each patch and discards any that do not |
| 78 | + apply cleanly. |
| 79 | +5. **Notification.** When a run produces new skills or patches, Gemini CLI |
| 80 | + surfaces an inline message telling you how many items are waiting. |
| 81 | + |
| 82 | +## How to review extracted skills |
| 83 | + |
| 84 | +Use the `/memory inbox` slash command to open the inbox dialog at any time: |
| 85 | + |
| 86 | +**Command:** `/memory inbox` |
| 87 | + |
| 88 | +The dialog lists each draft skill with its name, description, and source |
| 89 | +sessions. From there you can: |
| 90 | + |
| 91 | +- **Read** the full `SKILL.md` body before deciding. |
| 92 | +- **Promote** a skill to your user (`~/.gemini/skills/`) or workspace |
| 93 | + (`.gemini/skills/`) directory. |
| 94 | +- **Discard** a skill you do not want. |
| 95 | +- **Apply** or reject a `.patch` proposal against an existing skill. |
| 96 | + |
| 97 | +Promoted skills become discoverable in the next session and follow the standard |
| 98 | +[skill discovery precedence](./skills.md#skill-discovery-tiers). |
| 99 | + |
| 100 | +## How to disable Auto Memory |
| 101 | + |
| 102 | +To turn off background extraction, set the flag back to `false` in your settings |
| 103 | +file and restart Gemini CLI: |
| 104 | + |
| 105 | +```json |
| 106 | +{ |
| 107 | + "experimental": { |
| 108 | + "autoMemory": false |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +Disabling the flag stops the background service immediately on the next session |
| 114 | +start. Existing inbox items remain on disk; you can either drain them with |
| 115 | +`/memory inbox` first or remove the project memory directory manually. |
| 116 | + |
| 117 | +## Data and privacy |
| 118 | + |
| 119 | +- Auto Memory only reads session files that already exist locally on your |
| 120 | + machine. Nothing is uploaded to Gemini outside the normal API calls the |
| 121 | + extraction sub-agent makes during its run. |
| 122 | +- The sub-agent is instructed to redact secrets, tokens, and credentials it |
| 123 | + encounters and to never copy large tool outputs verbatim. |
| 124 | +- Drafted skills live in your project's memory directory until you promote or |
| 125 | + discard them. They are not automatically loaded into any session. |
| 126 | + |
| 127 | +## Limitations |
| 128 | + |
| 129 | +- The sub-agent runs on a preview Gemini Flash model. Extraction quality depends |
| 130 | + on the model's ability to recognize durable patterns versus one-off incidents. |
| 131 | +- Auto Memory does not extract skills from the current session. It only |
| 132 | + considers sessions that have been idle for three hours or more. |
| 133 | +- Inbox items are stored per project. Skills extracted in one workspace are not |
| 134 | + visible from another until you promote them to the user-scope skills |
| 135 | + directory. |
| 136 | + |
| 137 | +## Next steps |
| 138 | + |
| 139 | +- Learn how skills are discovered and activated in [Agent Skills](./skills.md). |
| 140 | +- Explore the [memory management tutorial](./tutorials/memory-management.md) for |
| 141 | + the complementary `save_memory` and `GEMINI.md` workflows. |
| 142 | +- Review the experimental settings catalog in |
| 143 | + [Settings](./settings.md#experimental). |
0 commit comments