memory-init
Memory Init
Initialize the Engram memory system for the current project.
When to Use
This skill is auto-triggered by the Engram hook when no .claude/memory-settings.json is found. Do NOT wait for the user to ask — when the hook says "Not initialized", immediately begin this workflow.
Workflow
1. Ask Preset Choice
Ask the user which preset they want:
- personal-assistant — Daily life, preferences, habits, personal interactions
- project-assistant — Codebase, architecture, tech decisions, team workflow
- character-companion — Persona, relationship, story progression, emotional bonds
- pair-programmer — AI self-learning, mistake tracking, user preference rules, collaboration patterns
Or offer custom configuration.
2. Ask File Name Customization
Show the default file names and ask if the user wants to change them:
memory_preferences.md (User/Project/Character preferences)
memory_conversations.md (Conversation history)
memory_longterm.md (Long-term memories)
3. Ask Language Preference
en— English instructions injected by hook (default)zh— Chinese instructions injected by hook
3.5 Ask Search Mode
strong— 每次回覆前都先搜尋記憶 / Search memories before EVERY response (no exceptions)weak— 僅在判斷需要時搜尋 / Only search when context suggests it's relevant (default)
4. Create Configuration
Create .claude/memory-settings.json with the chosen settings:
{
"enabled": true,
"preset": "<chosen-preset>",
"files": {
"preferences": "<preferences-filename>",
"conversations": "<conversations-filename>",
"longterm": "<longterm-filename>"
},
"reload_interval": 10,
"language": "<en|zh>",
"search_mode": "<strong|weak>",
"reminder_file": ".claude/memory-reminder.md"
}
5. Copy Preset Templates
Copy the template files from the plugin's templates/presets/<preset>/ directory to the project root. The plugin root is available via ${CLAUDE_PLUGIN_ROOT} or can be found by locating the engram plugin directory.
Read each template file and write it to the project root with the configured file names.
Replace {DATE} placeholders with the current date (YYYY-MM-DD format).
5b. Create Reminder File
Copy the reminder template from the plugin's templates/ directory to .claude/memory-reminder.md:
- If language is
zh: copy fromtemplates/memory-reminder-zh.md - If language is
en: copy fromtemplates/memory-reminder-en.md
The reminder file uses {{PREFS_FILE}}, {{CONVOS_FILE}}, {{LONGTERM_FILE}}, {{RELOAD_INTERVAL}}, and {{SEARCH_MODE_INSTRUCTION}} placeholders — these are automatically substituted at runtime by the hook script. Do NOT replace them during init.
Tell the user: "The reminder instructions are stored in .claude/memory-reminder.md. This is the legacy fallback — the main instructions are now in CLAUDE.md."
5c. Append Engram Section to CLAUDE.md
Read the CLAUDE.md section template from the plugin's templates/ directory:
- If language is
zh: read fromtemplates/claude-md-section-zh.md - If language is
en: read fromtemplates/claude-md-section-en.md
Replace the following placeholders with the actual configured values:
{PREFS_FILE}→ preferences file name{CONVOS_FILE}→ conversations file name{LONGTERM_FILE}→ longterm file name{RELOAD_INTERVAL}→ reload interval number{PRESET}→ chosen preset name{VERSION}→ plugin version from.claude-plugin/plugin.json{SEARCH_MODE_INSTRUCTION}→ resolved based on search_mode and language:- strong + en:
7. **MANDATORY pre-response search**: Before EVERY response, first analyze the user's intent and use the \memory-recall` skill to search memories. No exceptions — always search first, respond second.` - weak + en:
7. **Uncertainty about current topic**: If the conversation could possibly relate to past context, you MUST use the \memory-recall` skill to search memories before responding` - strong + zh:
7. **強制預搜尋**:每次回覆前,必須先分析使用者意圖,然後使用 \memory-recall` skill 搜尋記憶。沒有例外 — 永遠先搜尋再回覆。` - weak + zh:
7. **對當前話題不確定**:如果對話有可能涉及過去的上下文,必須先使用 \memory-recall` skill 搜尋記憶再回覆`
- strong + en:
Then apply to CLAUDE.md in the project root:
- If CLAUDE.md exists and contains
<!-- ENGRAM:START -->: Replace everything between<!-- ENGRAM:START -->and<!-- ENGRAM:END -->(inclusive) with the new resolved content - If CLAUDE.md exists but has no markers: Append the resolved content to the end of the file (with a blank line separator)
- If CLAUDE.md does not exist: Create a new CLAUDE.md with only the resolved content
Tell the user: "Memory instructions have been added to CLAUDE.md for high-priority instruction following. The hook will now only inject lightweight datetime/turn signals."
6. Initialize Counter
Create .claude/memory_counter.txt with content 0.
7. Optional Customization
Ask the user: "Would you like to add or modify any sections in the preferences template?"
If yes, guide through customization — adding new sections, renaming existing ones, or removing irrelevant ones.
8. Optional Initial Fill
Ask the user: "Would you like to fill in your initial preferences now?"
If yes, walk through each section and populate the preferences file with the user's answers.
8.5 Upgrade Path (Re-running Init)
If .claude/memory-settings.json already exists but search_mode is not set:
- Skip steps 1–3 (preset, file names, language are already configured)
- Ask: "search_mode is not configured yet — would you like to enable strong search mode?"
- Update
memory-settings.jsonwith the chosensearch_modevalue - Re-generate the reminder file (Step 5b) and CLAUDE.md section (Step 5c) with the new search mode instruction
- Do NOT reset other settings (preset, files, language, etc.)
9. Output Summary
Display a summary of what was created:
Engram Memory System Initialized!
Preset: <preset>
Language: <language>
Files created/updated:
- <preferences-file> (preferences)
- <conversations-file> (conversation history)
- <longterm-file> (long-term memories)
- .claude/memory-settings.json (configuration)
- .claude/memory-reminder.md (legacy hook instructions)
- .claude/memory_counter.txt (turn counter)
- CLAUDE.md (memory instructions — high priority)
The memory system is now active. I will automatically:
- Load your preferences on turn 1 and every N turns
- Save new preferences and decisions as I discover them
- Record conversation summaries
- Search past conversations when relevant