{"guides":[{"id":"33e1bb37-737b-46cd-9903-89b61df0c977","unique_id":"claude-code-subagent-persistent-memory-jul2026","title":"Claude Code Subagents: Enable Persistent Memory","title_he":"זיכרון מתמשך ל־Subagents ב־Claude Code","summary":"How to give each Claude Code subagent its own persistent memory for project patterns, recurring issues, and architectural knowledge.","summary_he":"Claude Code מאפשר לתת לכל Subagent זיכרון מתמשך משלו. המדריך מסביר כיצד להפעיל אותו, לבחור היקף מתאים ולתחזק אותו בבטחה.","long_content":"## Persistent memory for Claude Code subagents\n\nClaude Code can give each custom subagent a persistent memory directory. Instead of starting from zero on every run, a subagent can accumulate project conventions, recurring bugs, debugging insights, and architectural decisions.\n\nAdd a `memory` field to the agent definition, for example `.claude/agents/code-reviewer.md`:\n\n```markdown\n---\nname: code-reviewer\ndescription: Reviews code for bugs, security risks, and project conventions\nmodel: sonnet\nmemory: local\n---\n\nYou are a senior code reviewer. Read your memory before each review. Afterward, save concise reusable lessons, but never store secrets, credentials, temporary status, or raw logs.\n```\n\n### Memory scopes\n\n| Scope | Directory | Best for |\n|---|---|---|\n| `user` | `~/.claude/agent-memory/<agent-name>/` | Learnings shared across projects |\n| `project` | `.claude/agent-memory/<agent-name>/` | Project knowledge shared through version control |\n| `local` | `.claude/agent-memory-local/<agent-name>/` | Private project knowledge that should not be committed |\n\nStart with `local`, and add `.claude/agent-memory-local/` to `.gitignore`. Promote only reviewed, non-sensitive knowledge to `project` memory.\n\nEnsure auto memory is enabled in `.claude/settings.json` or `~/.claude/settings.json`:\n\n```json\n{\n  \"autoMemoryEnabled\": true\n}\n```\n\nThe feature has no effect when auto memory is disabled through that setting or `CLAUDE_CODE_DISABLE_AUTO_MEMORY`.\n\nWhen enabled, Claude Code injects memory-management instructions into the subagent prompt, loads the first 200 lines or 25KB of `MEMORY.md`, and automatically enables Read, Write, and Edit so the agent can maintain its memory. Each named subagent receives a separate memory directory.\n\nManage agents with `/agents`, or invoke one explicitly: `Use the code-reviewer subagent to review this PR. Consult your memory first and save reusable findings when done.`\n\nGood uses include persistent code-review findings, project documentation, recurring QA failures, and refactoring conventions. Never use agent memory for passwords, API keys, personal data, `.env` contents, or unverified transient state.\n","slug":"claude-code-subagent-persistent-memory","curation_note":"יכולת שימושית שהופכת Subagents מעובדים חד־פעמיים למומחים שצוברים ידע לאורך זמן. מומלץ להתחיל בזיכרון local ולשמור מידע רגיש מחוץ לזיכרון.","tool_name":"Claude Code","feature_name":"Subagent Persistent Memory","difficulty_level":"בינוני","topics":["Claude Code","Subagents","Persistent Memory","Agentic AI","Developer Tools","Knowledge Management"],"url":"https://code.claude.com/docs/en/sub-agents#enable-persistent-memory","sources":[{"url":"https://code.claude.com/docs/en/sub-agents#enable-persistent-memory","name":"Claude Code official documentation"},{"url":"https://www.linkedin.com/posts/alonwo_%D7%90%D7%9D-%D7%90%D7%AA%D7%9D-%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9%D7%99%D7%9D-%D7%91-subagents-%D7%91-claude-code-ugcPost-7486312819139907585-bjiz/","name":"Alon Wolenitz — LinkedIn post"}],"language":"עברית","created_at":"2026-07-24T14:49:17.882525+00:00","updated_at":"2026-07-24T14:49:17.882525+00:00","section":"complete","section_order":1,"section_title":"Complete guide","section_title_he":"מדריך מקיף","long_content_he":"## זיכרון מתמשך ל־Subagents ב־Claude Code\n\n### הידיעה\nClaude Code מאפשר להעניק לכל Subagent זיכרון מתמשך משלו. במקום שסוכן משנה יתחיל מאפס בכל הרצה, הוא יכול לצבור לאורך זמן ידע על מבנה הפרויקט, מוסכמות קוד, תקלות חוזרות והחלטות ארכיטקטוניות.\n\nהיכולת מופעלת באמצעות השדה `memory` בקובץ ההגדרה של ה־Subagent. לפני כל הרצה Claude Code טוען את הזיכרון של הסוכן, ובמהלך העבודה הסוכן יכול לקרוא ולעדכן אותו.\n\n## הפעלה מהירה\n\nצרו קובץ Subagent בפרויקט:\n\n```text\n.claude/agents/code-reviewer.md\n```\n\nוהוסיפו לו את ההגדרה הבאה:\n\n```markdown\n---\nname: code-reviewer\ndescription: Reviews code for bugs, security risks, and project conventions\nmodel: sonnet\nmemory: local\n---\n\nYou are a senior code reviewer.\n\nBefore every review:\n1. Read your memory and look for patterns or recurring problems.\n2. Review the current changes using those prior findings.\n\nAfter every review:\n1. Save concise, reusable lessons to your memory.\n2. Record project conventions, recurring bugs, and important architectural decisions.\n3. Do not store secrets, credentials, temporary task status, or large raw outputs.\n```\n\nבהפעלה הבאה של הסוכן Claude Code ייצור ויטען עבורו ספריית זיכרון מתמשכת.\n\n## בחירת היקף הזיכרון\n\n| הגדרה | מיקום | מתי להשתמש |\n|---|---|---|\n| `memory: user` | `~/.claude/agent-memory/code-reviewer/` | ידע שימושי שחוצה את כל הפרויקטים |\n| `memory: project` | `.claude/agent-memory/code-reviewer/` | ידע פרויקטלי שרוצים לשמור ב־Git ולשתף עם הצוות |\n| `memory: local` | `.claude/agent-memory-local/code-reviewer/` | ידע פרויקטלי פרטי שלא צריך להיכנס ל־Git |\n\n**המלצה מעשית:** התחילו עם `local`. לאחר שבדקתם שהזיכרון איכותי ואינו מכיל מידע רגיש, אפשר להעביר ידע נבחר ל־`project`. מומלץ גם להוסיף את `.claude/agent-memory-local/` ל־`.gitignore`.\n\n## ודאו ש־Auto Memory פעיל\n\nבקובץ `.claude/settings.json` של הפרויקט או ב־`~/.claude/settings.json` הגלובלי:\n\n```json\n{\n  \"autoMemoryEnabled\": true\n}\n```\n\nאם משתנה הסביבה `CLAUDE_CODE_DISABLE_AUTO_MEMORY` פעיל, יש להסירו. כאשר Auto Memory כבוי, השדה `memory` אינו משפיע וה־Subagent לא מקבל גישה לכלי הזיכרון.\n\n## יצירה והפעלה מתוך Claude Code\n\nאפשר ליצור או לנהל Subagents באמצעות:\n\n```text\n/agents\n```\n\nואפשר לבקש במפורש להפעיל את הסוכן:\n\n```text\nUse the code-reviewer subagent to review this PR.\nConsult your memory before starting, and save reusable findings when done.\n```\n\nClaude Code עשוי גם לבחור את הסוכן אוטומטית לפי שדה ה־`description` שלו.\n\n## מה קורה מאחורי הקלעים?\n\nכאשר הזיכרון פעיל:\n\n1. Claude Code מוסיף ל־system prompt של הסוכן הנחיות לקריאה ולכתיבה בספריית הזיכרון.\n2. נטענות עד 200 השורות הראשונות או 25KB מתוך `MEMORY.md` — המוקדם מביניהם.\n3. כלי `Read`, `Write` ו־`Edit` מופעלים אוטומטית כדי שהסוכן יוכל לנהל את הזיכרון.\n4. העדכונים נשמרים ומשמשים את אותו Subagent בשיחות ובהרצות הבאות.\n5. לכל שם של Subagent יש ספריית זיכרון נפרדת; למשל `code-reviewer` ו־`security-reviewer` אינם חולקים זיכרון.\n\n## שימושים מומלצים\n\n- **Code Reviewer:** זוכר הערות חוזרות, מוסכמות קוד ואזורים מועדים לתקלות.\n- **Documentation Agent:** בונה מאגר ידע על רכיבים, APIs והחלטות ארכיטקטוניות.\n- **QA Agent:** לומד אילו בדיקות נכשלות שוב ושוב ומה גרם לכשלים קודמים.\n- **Refactoring Agent:** מכיר את דפוסי העיצוב והקונבנציות הייחודיות של הפרויקט.\n\n## כללי תחזוקה ואבטחה\n\n- שמרו בזיכרון עקרונות ותובנות חוזרות — לא לוגים גולמיים או סטטוס זמני.\n- אל תשמרו סיסמאות, API keys, טוקנים, מידע אישי או תוכן של `.env`.\n- בקשו מהסוכן לעדכן את הזיכרון בסיום משימות משמעותיות, לא אחרי כל פעולה קטנה.\n- עברו מדי פעם על `MEMORY.md`, מחקו מידע שהתיישן ואחדו כפילויות.\n- זיכרון מתמשך הוא הקשר שימושי, לא מקור אמת: עדיין יש לאמת קוד, בדיקות ותוצאות.\n\n## מקורות\n\n- [התיעוד הרשמי של Claude Code — Persistent memory for subagents](https://code.claude.com/docs/en/sub-agents#enable-persistent-memory)\n- [הפוסט של Alon Wolenitz ב־LinkedIn](https://www.linkedin.com/posts/alonwo_%D7%90%D7%9D-%D7%90%D7%AA%D7%9D-%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9%D7%99%D7%9D-%D7%91-subagents-%D7%91-claude-code-ugcPost-7486312819139907585-bjiz/)\n"}],"total":1,"limit":null,"offset":0,"next_cursor":null}