|
| 1 | +--- |
| 2 | +title: Memory |
| 3 | +description: Give your AI agents long-term memory to prevent repeating mistakes and enforce coding standards. |
| 4 | +slug: memory |
| 5 | +order: 6 |
| 6 | +--- |
| 7 | + |
| 8 | +Imagine if your AI assistant never made the same mistake twice. |
| 9 | + |
| 10 | +The **Memory** service allows you to store actionable insights, coding patterns, and project guidelines. Once stored, this knowledge is available to your AI agents (via MCP) and to you directly via the CLI, ensuring consistency across your development workflow. |
| 11 | + |
| 12 | +## How It Works |
| 13 | + |
| 14 | +You can interact with Memory in two ways: |
| 15 | + |
| 16 | +1. **Through your AI Assistant (Recommended):** Connect via MCP so your AI can automatically search for relevant context and save new rules as you work. When you chat with your AI assistant, it will automatically fallback to the CLI to search for relevant context and save new rules if MCP is not available. |
| 17 | +2. **Through the CLI:** Manually store or retrieve knowledge directly from your terminal—perfect for quick lookups or scripting. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 1. Using with AI Agents (MCP) |
| 22 | + |
| 23 | +This is the most powerful way to use Memory. Your AI (Cursor, Claude, etc.) gains "tools" to save and retrieve information naturally. |
| 24 | + |
| 25 | +### Setup |
| 26 | + |
| 27 | +Add the server to your MCP configuration file: |
| 28 | + |
| 29 | +```json |
| 30 | +{ |
| 31 | + "mcpServers": { |
| 32 | + "memory": { |
| 33 | + "command": "npx", |
| 34 | + "args": ["@ai-devkit/memory"] |
| 35 | + } |
| 36 | + } |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +### Usage Examples |
| 41 | + |
| 42 | +Once connected, you can talk to your AI naturally: |
| 43 | + |
| 44 | +**Storing Knowledge:** |
| 45 | +> "We just decided that all API responses must handle BigInt serialization. Please save this rule to memory with the tag #backend." |
| 46 | +
|
| 47 | +**Retrieving Knowledge:** |
| 48 | +> "I'm building a new endpoint. Check memory for any API standards I need to follow." |
| 49 | +
|
| 50 | +The AI will intelligently rank results based on your current task and available tags. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## 2. Using the CLI |
| 55 | + |
| 56 | +You don't need an AI agent to use Memory. The `ai-devkit` CLI has built-in commands to manage your knowledge base. |
| 57 | + |
| 58 | +### Storing Knowledge |
| 59 | + |
| 60 | +Found a solution to a tricky bug? Save it immediately: |
| 61 | + |
| 62 | +```bash |
| 63 | +ai-devkit memory store \ |
| 64 | + --title "Fix: Docker connection refused on M1 Mac" \ |
| 65 | + --content "Enable 'Use Rosetta for x86/amd64 emulation' in Docker Desktop settings." \ |
| 66 | + --tags "docker,mac,infra" |
| 67 | +``` |
| 68 | + |
| 69 | +### Searching Knowledge |
| 70 | + |
| 71 | +Need to recall a specific command or pattern? Search for it: |
| 72 | + |
| 73 | +```bash |
| 74 | +ai-devkit memory search --query "docker m1" |
| 75 | +``` |
| 76 | + |
| 77 | +**Output:** |
| 78 | +```json |
| 79 | +[ |
| 80 | + { |
| 81 | + "title": "Fix: Docker connection refused on M1 Mac", |
| 82 | + "content": "Enable 'Use Rosetta for x86/amd64 emulation'...", |
| 83 | + "score": 5.2 |
| 84 | + } |
| 85 | +] |
| 86 | +``` |
| 87 | + |
| 88 | +### CLI Reference |
| 89 | + |
| 90 | +| Command | Description | Key Flags | |
| 91 | +| :--- | :--- | :--- | |
| 92 | +| `memory store` | Save a new item | `--title`, `--content`, `--tags`, `--scope` | |
| 93 | +| `memory search` | Find items | `--query`, `--tags`, `--limit` | |
| 94 | + |
| 95 | +## Organizing Your Knowledge |
| 96 | + |
| 97 | +To keep your memory effective, use **Tags** and **Scopes**. |
| 98 | + |
| 99 | +### Tags |
| 100 | +Categorize your entries so they trigger in the right context. |
| 101 | +- `["typescript", "react"]` -> For frontend rules. |
| 102 | +- `["deployment", "ci"]` -> For DevOps procedures. |
| 103 | + |
| 104 | +### Scopes |
| 105 | +Control where your knowledge applies. |
| 106 | +- **Global** (Default): Applies to all your projects. |
| 107 | +- **Project**: `project:my-app` — Specific to a project. |
| 108 | +- **Repo**: `repo:org/repo` — Specific to a git repository. |
| 109 | + |
| 110 | +*Note: AI agents will prioritize knowledge that matches the scope of the project you are currently working on.* |
| 111 | + |
| 112 | +## Privacy & Storage |
| 113 | + |
| 114 | +Your memory is **100% local**. |
| 115 | + |
| 116 | +All data is stored in a high-performance SQLite database located at `~/.ai-devkit/memory.db`. No data is sent to the cloud, ensuring your proprietary coding patterns remain private. |
| 117 | + |
| 118 | +This is portable so you can just copy the database file to another machine to use it across different machines. |
0 commit comments