Overview
Claude Code has the deepest CEMS integration with 6 hooks, 6 skills, 2 commands, and automatic context injection on every prompt.What Gets Installed
When you runcems setup --claude, the installer creates:
Hooks
cems_session_start.py
Trigger: Session start (new or resume) Purpose: Injects user profile and foundation guidelines into session context What it does:- Fetches user profile via
/api/memory/profile(preferences, past decisions) - Fetches foundation guidelines via
/api/memory/foundation(cached 15 min) - Checks for auto-updates (every 5 minutes, background)
- Ensures observer daemon is running
- Injects context as
<cems-profile>and<cems-foundation>XML blocks
CEMS_API_URL- Server URLCEMS_API_KEY- API keyCEMS_AUTO_UPDATE- Set to0to disable auto-updates
cems_user_prompts_submit.py
Trigger: Every user prompt Purpose: Searches CEMS for relevant memories and injects them before Claude sees your prompt What it does:- Strips XML tags from prompt (system reminders, previous hook output)
- Detects project from git remote (e.g.,
Chocksy/cems) - Searches CEMS via
/api/memory/searchwith project-scoped boosting - Populates gate rule cache for
cems_pre_tool_use.py - Injects memories as
<memory-recall>block - Handles
-uflag for ultrathink mode - Logs retrieval scores for offline analysis
- Skips confirmatory prompts (“yes”, “go ahead”) and instead searches what Claude just proposed
- Skips short prompts (< 15 chars) and slash commands
- Client-side score filtering (drops results < 0.4)
- Session deduplication (one result per session)
cems_pre_tool_use.py
Trigger: Before tool execution (bash, edit, etc.) Purpose: Enforces gate rules - blocks or warns on dangerous operations What it does:- Reads cached gate rules (populated by
cems_user_prompts_submit.py) - Matches tool calls against regex patterns
- Returns block/confirm/warn based on severity
bash: rm -rf / — Never delete root directory(severity: block)bash: git push --force — Force push can destroy history(severity: confirm)
cems_post_tool_use.py
Trigger: After tool execution Purpose: Extracts learnings from tool usage patterns What it does:- Analyzes tool results (especially errors)
- Sends to
/api/tool/learningfor pattern extraction - Stores common error solutions as memories
cems_stop.py
Trigger: Session end Purpose: Signals observer daemon to finalize session summary What it does:- Logs session data to
~/.cems/sessions/{session_id}/stop.json - Optionally saves transcript with
--chatflag - Writes stop signal to
~/.cems/observer/signals/{session_id}.json - Observer daemon picks up signal and calls
/api/session/summarize
cems_pre_compact.py
Trigger: Before context compaction Purpose: Preserves important context before Claude Code compacts the conversationSkills
Skills are invoked with/skill-name or as part of agent workflows.
/recall
File:~/.claude/skills/cems/recall.md
Purpose: Search memories
Usage:
- Parses
--limit,--scopeflags - Detects project from
git remote get-url origin - Calls
memory_searchMCP tool with project parameter - Fetches full documents for truncated results via
memory_get
/remember
File:~/.claude/skills/cems/remember.md
Purpose: Store personal memories
Usage:
- Detects project from git remote
- Determines category (preferences, conventions, architecture, decisions, workflow, errors, learnings, general)
- Calls
memory_addMCP tool withscope: "personal"andsource_ref: "project:org/repo"
/share
File:~/.claude/skills/cems/share.md
Purpose: Store team-wide memories
Usage:
scope: "shared"
/forget
File:~/.claude/skills/cems/forget.md
Purpose: Delete or archive memories
Usage:
/context
File:~/.claude/skills/cems/context.md
Purpose: Show memory system status
Displays:
- Session ID
- Project context
- Recent memories count
- Observer daemon status
memory-guide.md
File:~/.claude/skills/cems/memory-guide.md
Purpose: Instructions for proactive memory usage
Teaches Claude when to:
- Search before starting tasks
- Store discoveries during work
- Update stale memories
- Forget noise
Commands
Commands are shortcuts accessible via/recall and /remember directly in chat.
/recall command
File:~/.claude/commands/recall.md
Provides quick access to memory search without typing /skill cems/recall.
/remember command
File:~/.claude/commands/remember.md
Provides quick access to memory storage.
Setup Verification
After installation, verify everything works:1. Check files exist
2. Check credentials
3. Test connection
4. Test hook manually
hookSpecificOutput if memories found, or nothing if no matches.
5. Test in Claude Code
Start a new session and type:How It Works
On Session Start
cems_session_start.pyruns- Fetches your profile (preferences, past decisions) from
/api/memory/profile - Fetches foundation guidelines from
/api/memory/foundation - Injects both as XML blocks in session context
- Checks for updates (background, every 5 min)
- Ensures observer daemon is running
On Every Prompt
cems_user_prompts_submit.pyruns- Strips XML tags from prompt to get clean user text
- Detects project from git remote (e.g.,
[email protected]:Chocksy/cems.git→Chocksy/cems) - Searches CEMS with project-scoped boosting (same-project memories rank higher)
- Populates gate rule cache (used by
cems_pre_tool_use.py) - Injects memories as
<memory-recall>block - Logs retrieval scores to
~/.cems/sessions/{session_id}/hook_events.jsonl
On Tool Use
cems_pre_tool_use.pychecks gate rules before execution- Tool executes
cems_post_tool_use.pyextracts learnings from results
On Session End
cems_stop.pywrites stop signal- Observer daemon detects signal
- Observer reads transcript from
~/.claude/projects/{project}/transcripts/{session_id}.jsonl - Sends to
/api/session/summarizefor narrative extraction - Server extracts high-level observations (“User deploys via Coolify”, “Project uses PostgreSQL”)
- Observations stored as memories with
category: observation
Observer Daemon
The observer runs as a background process (cems-observer) and:
- Polls
~/.claude/projects/*/for new JSONL transcripts every 30 seconds - When 50KB of new content accumulates, sends to server
- Server extracts observations via Gemini 2.5 Flash
- Observations stored as memories automatically
Troubleshooting
Memories not appearing in prompts
- Check hook output:
- Check credentials:
cat ~/.cems/credentials - Test connection:
cems health - Check server logs if self-hosting
Skills not appearing
- Verify files exist:
ls ~/.claude/skills/cems/ - Restart Claude Code
- Type
/and look forrecall,remember,share,forget,context
Observer not running
- Check status:
cems-observer status - Check logs:
cat ~/.cems/observer/observer.log - Restart:
cems-observer restart
Hook errors
- Check hook logs:
cat ~/.cems/sessions/{session_id}/hook_events.jsonl - Test hook directly (see “Test hook manually” above)
- Check Python version:
python3 --version(needs 3.11+) - Check uv installed:
uv --version
Advanced Configuration
Disable auto-updates
Add to~/.cems/credentials:
Adjust profile token budget
Editcems_session_start.py and change:
Custom gate rules
Add gate rules via CLI:/remember:
MCP Tools Available
All Claude Code hooks and skills use these MCP tools:| Tool | Endpoint | Used By |
|---|---|---|
memory_search | /api/memory/search | cems_user_prompts_submit.py, /recall |
memory_add | /api/memory/add | /remember, /share |
memory_get | /api/memory/get | /recall (for truncated results) |
memory_forget | /api/memory/forget | /forget |
memory_update | /api/memory/update | Manual edits |
memory_maintenance | /api/memory/maintenance | Scheduled jobs |
Next Steps
- Cursor Integration - Lighter integration via MCP + hooks
- Codex Integration - Command-based interface
- Goose Integration - MCP-only extension