This guide walks you from zero to a fully working StackMemory setup in under 5 minutes.
- Node.js 20+ (
node --versionto check) - Claude Code, Codex, or OpenCode installed
- macOS, Linux, or WSL
npm install -g @stackmemoryai/stackmemoryThis installs the stackmemory CLI and wrapper scripts (claude-sm, codex-sm, opencode-sm).
cd your-project
stackmemory initThis creates a .stackmemory/ directory with:
- SQLite database for context storage
- FTS5 full-text search index
- Default configuration
Add .stackmemory/ to your .gitignore — it's local state, not shared.
stackmemory setup-mcpThis configures Claude Code's MCP settings to connect to StackMemory. After running this, restart Claude Code.
stackmemory doctorYou should see all green checkmarks. If anything fails, the doctor output will tell you what to fix.
claude-sm # Claude Code with StackMemory context auto-loadedThe wrapper script:
- Loads your existing StackMemory context into the session
- Starts the Prompt Forge optimizer (watches CLAUDE.md for improvements)
- Runs Claude Code normally
In Claude Code, StackMemory tools are available immediately:
> Use get_context to see what I was working on last session
> Use add_decision to record: "Using PostgreSQL for the user service"
> Use start_frame to begin work on "Implement auth middleware"
- During your session, StackMemory records events, decisions, and anchors
- When you run
/clearor close the session, hooks automatically save context - Next session,
get_contextretrieves everything — decisions, constraints, progress - You never re-explain context to your AI coding tool again
| Command | What it does |
|---|---|
stackmemory init |
Initialize StackMemory in a project |
stackmemory setup-mcp |
Configure Claude Code MCP connection |
stackmemory doctor |
Verify installation health |
stackmemory capture |
Save current session state |
stackmemory restore |
Restore from a captured state |
stackmemory daemon start |
Start the memory monitor daemon |
stackmemory hooks install |
Install Claude Code hooks |
| Tool | What it does |
|---|---|
get_context |
Retrieve project context and active frame |
add_decision |
Record a decision or constraint |
start_frame |
Begin a new scoped unit of work |
close_frame |
Complete and summarize current work |
sm_search |
Search across all context |
cord_spawn |
Create a subtask with clean context |
# Set your Linear API key
echo "LINEAR_API_KEY=lin_api_..." >> .env
# Sync tasks
stackmemory linear:syncTasks flow bidirectionally between Linear and your coding sessions.
StackMemory can install Claude Code hooks that run automatically:
stackmemory hooks installHooks handle:
- Auto-saving context on
/clear - Task completion tracking
- Linear sync on task done
- PROMPT_PLAN progress updates
- Read the CLI Reference for all commands
- Explore the Architecture to understand the call stack model
- Check the MCP Tools Reference for all 56 tools