# Skill: Set up and maintain a persistent agent memory file > Apply this skill when an agent repeatedly forgets project conventions between sessions -- it teaches the agent to store habits as atomic instinct rules in a file and re-read them on every launch. Source: sodigi·learn -- vibecoding/pamyat-agenta · https://sodigi.io/learn/vibecoding/pamyat-agenta ## When to use - The user has to re-explain the same preferences every new session (spacing, language, naming conventions, etc.). - Starting a new project that will span multiple sessions. - The agent keeps reverting to defaults instead of following established project conventions. - Consolidating or cleaning up a memory file that has grown contradictory or bloated. ## Core rules - The model itself has no memory between sessions. All persistence lives in files on disk. If it is not in a file, it is gone after a restart. - Write memory as atomic instinct rules: "when I do X, do Y." One bullet = one fact. No walls of text. - Every instinct has an implicit confidence level. Habits that repeat without correction get applied automatically; new or uncertain ones get suggested first. - Separate project-local memory (React conventions, style rules for this repo) from global memory (always validate input, always read a file before editing it). - Update the memory file when corrected -- do not spawn duplicate entries. Delete stale or contradictory rules. - Never store secrets, passwords, API keys, or tokens in a memory file. A file will leak. - Read the memory file at the start of every new session before taking any action. ## Procedure 1. Create a MEMORY.md (or project-specified name) file in the project root if one does not exist. 2. Write existing known conventions as short "when X, do Y" bullets -- one fact per bullet. 3. At the start of each session, read the memory file before doing anything else. 4. When the user corrects behavior, find the relevant bullet and update it in place -- do not add a duplicate. 5. When a fact becomes outdated or conflicts with a new rule, delete the old entry. 6. If a habit appears reliably across multiple projects, promote it to the global memory scope. 7. Never write passwords, tokens, or credentials into the memory file. ## Ready-to-use prompt ``` Set up a MEMORY file in this project with my habits and maintain it yourself. Rules for keeping it: 1. Write short bullet points in the style of "when I do X, do Y." One bullet, one fact. 2. What we already know: [list your conventions here]. 3. If I correct you, update the relevant bullet -- do not create duplicates. 4. If a fact is outdated or conflicts with a new one, delete the old one -- do not keep both. 5. No passwords, keys, or secrets in this file. 6. At the start of every new session, read this file first, then start the task. ``` ## Pitfalls - Believing the AI will remember on its own without a file -- it starts every session from a blank slate. - Writing memory as long paragraphs -- the agent wastes context reading them and misses individual rules. Keep bullets short. - Hoarding stale or contradictory notes -- two bullets saying "do A" and "never do A" cause inconsistent behavior. - Storing secrets in the memory file -- the file is plain text and will eventually end up somewhere it should not. - Letting per-project habits leak into global scope -- React hooks do not belong in a Python project's memory. - Forgetting to instruct the agent to read the file at the start of each session -- without that instruction it will not.