memory-init

memory-init is a skill for Claude Code from spudy-vibing/Claude-Code-Prompts. It costs 50 tokens per session (3,476 once invoked), scanned A, original, MIT.

Instructions for creating persistent memory for Claude in a code project. Persistent memory is information saved between sessions so the agent can load it again later.

In plain words
What is it for?
Setting up memory when starting a project or when the user asks to initialize, rebuild, or configure the memory system.
Why use it?
It helps Claude retain project context by creating memory files and automatic session-start hooks, which are scripts that run when a session begins.

Skill for Claude Code

Written for Claude Code: SessionStart hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md; positional $N argument.

Good fit Setting up memory when starting a project or when the user asks to initialize, rebuild, or configure the memory system.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/spudy-vibing/claude-code-prompts/memory-init
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add spudy-vibing/Claude-Code-Prompts --skill memory-init
Clone the repo
git clone --depth 1 https://github.com/spudy-vibing/Claude-Code-Prompts

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for memory-init

README.md
[![agentmods](https://agentmods.dev/badge/skills/spudy-vibing/claude-code-prompts/memory-init/github.svg)](https://agentmods.dev/skills/spudy-vibing/claude-code-prompts/memory-init)
Your own site
<a href="https://agentmods.dev/skills/spudy-vibing/claude-code-prompts/memory-init"><img src="https://agentmods.dev/badge/skills/spudy-vibing/claude-code-prompts/memory-init/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for memory-init

Your own site · 80×15
<a href="https://agentmods.dev/skills/spudy-vibing/claude-code-prompts/memory-init"><img src="https://agentmods.dev/badge/skills/spudy-vibing/claude-code-prompts/memory-init.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,476 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00050 $0.03476
Opus 5.5 $0.00020 $0.01390
Sonnet 5.5 $0.00010 $0.00695
Haiku 4.5 $0.00005 $0.00348

Measured 1mo ago against content hash 8b34c12544d1, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

memory-init scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

memory-init/SKILL.md · 411 lines

How it starts

The opening of the file, as written. The whole thing — 411 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Memory System Initialization

You are setting up a persistent memory system for this codebase. This memory exists solely for YOU to load and parse across sessions. No human will ever read these files directly.

Step 0: Check for Existing Memory

Before creating anything, check if .claude/mem/ already exists.

If it does:

  • Read the existing memory files
  • Ask the user: "This project already has Claude memory. Should I: (a) Keep existing memory and update the hooks only (b) Rebuild memory from scratch (existing memory will be backed up to .claude/mem.bak/) (c) Cancel"
  • If (a): Skip to Step 2 (hooks), preserve .claude/mem/
  • If (b): Copy .claude/mem/ to .claude/mem.bak/, then proceed normally
  • If (c): Stop

Step 1: Create Directory Structure

Create the following directories:

  • .claude/mem/
  • .claude/hooks/

Step 2: Create the Hooks

This system uses 4 hooks for full lifecycle coverage. Create all of them.

Configuration File

Create .claude/hooks/config.sh — a shared config sourced by all hooks. Users edit this one file to tune thresholds:

#!/bin/bash
# Memory system configuration
# Edit these values to tune hook behavior.
# All hooks fall back to defaults if this file is missing.

MEM_MAX_CHARS=8000           # Token budget (~2000 tokens). load-memory.sh warns above this.
CHECKPOINT_FRESHNESS=600     # Seconds. Stop hook skips if session saved within this window.
STOP_TURN_THRESHOLD=25       # Transcript lines. Stop hook only blocks after this many turns.
SAVE_TURN_THRESHOLD=4        # Transcript lines. SessionEnd hook skips trivial sessions below this.
TOOLS_CAP=20                 # Max tool entries logged in session metadata.

2A: SessionStart — Load Memory

Create .claude/hooks/load-memory.sh:

#!/bin/bash
set -euo pipefail

# Load config (optional — defaults used if missing)
HOOKS_DIR="$(cd "$(dirname "$0")" && pwd)"
[[ -f "$HOOKS_DIR/config.sh" ]] && source "$HOOKS_DIR/config.sh"

cd "$(dirname "$0")/../.." || exit 1

MEM_DIR=".claude/mem"
[[ -d "$MEM_DIR" ]] || exit 0

MAX_CHARS="${MEM_MAX_CHARS:-8000}"
TOTAL_CHARS=0

for f in "$MEM_DIR"/*; do
  [[ -f "$f" ]] || continue
  FILE_CHARS=$(wc -c < "$f" | tr -d ' ')
  TOTAL_CHARS=$((TOTAL_CHARS + FILE_CHARS))
done

if [[ "$TOTAL_CHARS" -gt "$MAX_CHARS" ]]; then
  echo "!!! MEMORY EXCEEDS TOKEN BUDGET (${TOTAL_CHARS} chars > ${MAX_CHARS}). Compact your .claude/mem/ files. !!!"
fi

for f in "$MEM_DIR"/*; do
  if [[ -f "$f" ]]; then
    echo "=== $(basename "$f") ==="
    cat "$f"
    echo ""
  fi
done

echo "=== git_state ==="
echo "hash:$(git log -1 --format=%h 2>/dev/null || echo 'not-a-repo')"
echo "branch:$(git branch --show-current 2>/dev/null || echo 'unknown')"

Read the full file on GitHub · 411 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 411 lines · 50 tokens per session scan A 8b34c12544d1

Subscribe to this mod's changes

memory-init is a skill published in the GitHub repository spudy-vibing/Claude-Code-Prompts (2 stars, last pushed 8mo ago), licensed MIT. It adds 50 tokens to every session and 3,476 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

knowledge-ingest

Ingest documents, articles, conversations, or supplied text into Knowledge with retained originals, sourced claims, entity updates, timelines, and cross-links; also learn durable lessons from a set of conversations, transcripts, or past sessions (/learn), including the Learn from conversations and Learn from Memory…

openclaw/openclaw · 79 tokens

forget

Remove a personal fact, preference, relationship detail, topic, or prior event from Muse's active memory and stop existing copies or automations from bringing it back. Use for explicit requests such as 'forget that', 'don't remember this about me', or 'remove that from your memory'. Do not use when 'forget it' merely…

asgeirtj/system_prompts_leaks · 74 tokens

mem0-oss-to-platform

Plan, then execute, a migration of a project from the mem0 open-source / self-hosted SDK (local Memory class) to the mem0 Platform / hosted SDK (MemoryClient). TRIGGER when: the developer wants to move, switch, or migrate mem0 off OSS/self-hosted to the hosted API, e.g. "migrate my mem0 setup to the platform", "switch…

mem0ai/mem0 · 217 tokens

Cortex

LifeOS memory, prior-session recall, and learning capture. USE WHEN capture this learning, document this learning, what did we learn recently, recent learnings, cortex, knowledge, knowledge base, search knowledge, what do we know about, archive, harvest, knowledge status, develop note, add to knowledge, add a people…

danielmiessler/LifeOS · 184 tokens

memory

Use when the user asks to remember, recall, forget, update, search, or inspect durable OpenSquilla memory, including profile facts in USER.md and long-term notes in MEMORY.md or memory//.md.

opensquilla/opensquilla · 44 tokens

ha-data-stores

Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…

shiwenwen/hope-agent · 115 tokens