Context Cases
Context Cases let you link related cases together so that their knowledge is automatically loaded when you need it — especially after context compaction in Claude Code.
The Problem
When Claude Code compacts its context window, it loses the details of what you were working on — active tasks, project context, environment settings. While CLAUDE.md instructions survive compaction, case-specific knowledge doesn’t.
The Solution
Link one or more cases as “context” for your working case. After compaction, CaseMgr automatically reloads:
- Your current case’s active tasks and work state
- Context from all linked context cases (descriptions, notes)
This means your AI agent recovers seamlessly — no more “what were we working on?”
How It Works
You're working on "Feature X" case
↓
Link "Dev Standards" case as context
Link "Client Requirements" case as context
↓
Context compaction happens
↓
PostCompact hook fires automatically
↓
Claude calls preferences-get → finds current case
Claude calls cmmn-get_resume_context → gets:
• Active tasks from "Feature X"
• Notes from "Dev Standards" (env config, debugging rules)
• Notes from "Client Requirements" (specs, constraints)
↓
Claude resumes work with full context
Setting Up Context Cases
Via the UI
- Open a case in the CaseMgr app
- In the right panel, find the Context Cases section (below Worktrees)
- Click + Link
- Select a case from the dropdown
- Click Link
To remove a context link, click Unlink next to the case name.
Via MCP Tools
# Link a case as context
wa mcp graph-link from_id="#1:100" to_id="#1:200" link_type=context
# Or ask Claude directly:
"Link the Dev Standards case as context for this case"
# Verify context is loaded
wa mcp cmmn-get_resume_context case_id="#1:100"
# → includes context_cases array with linked case content
What Gets Loaded from Context Cases
| Data | Source |
|---|---|
| Case name and description | The context case itself |
| Top-level notes | Notes without a parent (first 10) |
You control what’s loaded by what you put in the context case. Keep it focused — a “Dev Standards” case might have notes for environment config, debugging rules, and test credentials.
Example Context Cases
Development Standards
A case containing notes about your development workflow:
- Which environment to use (QA vs Production)
- How to debug (Playwright, SSH, logs)
- Test credentials and URLs
- Code review checklist
Client Knowledge Base
A case containing client-specific information:
- Client requirements and constraints
- Contact information
- Billing preferences
- Historical decisions
System Knowledge
Infrastructure and architecture facts:
- Server configurations
- Database gotchas
- Deployment procedures
- Architecture decisions
Automatic Recovery After Compaction
CaseMgr uses two mechanisms to ensure recovery:
- PostCompact Hook — A Claude Code hook in
.claude/settings.jsonthat fires after every compaction, injecting instructions to reload context - CLAUDE.md Instructions — Post-compaction recovery steps that survive compaction (CLAUDE.md is re-read from disk)
Both trigger the same flow: preferences-get → cmmn-get_resume_context → full context restored.
Setup: Files You Need to Configure
Three files make the automatic recovery work. Here’s what each one does and what to put in it.
1. ~/.claude/CLAUDE.md (Global — all projects)
This file is loaded into every Claude Code session on your machine, and is re-read from disk after every compaction. Keep it minimal — just the recovery bootstrap.
# Global Claude Code Instructions
## Post-Compaction Recovery (MANDATORY)
After every context compaction, you MUST immediately:
1. Call `preferences-get` to find the current case ID
2. If a current case exists, call `cmmn-get_resume_context` with that case ID
3. This restores: active tasks, context cases, in-progress work, and case summary
4. Resume work from where you left off — do NOT ask the user "what were we doing?"
What NOT to put here: Project-specific instructions, architecture details, build commands. Those belong in the project CLAUDE.md or in a CaseMgr case.
2. .claude/settings.json (Project — per repository)
This file lives in your repository’s .claude/ directory. The PostCompact hook injects recovery instructions directly into the model’s context after compaction — a stronger signal than CLAUDE.md alone.
{
"hooks": {
"PostCompact": [
{
"hooks": [
{
"type": "command",
"command": "echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PostCompact\",\"additionalContext\":\"CONTEXT COMPACTED. You MUST immediately: 1) Call preferences-get to find current case ID. 2) If a current case exists, call cmmn-get_resume_context with that case ID to reload active tasks, in-progress work, and case summary. 3) Resume work seamlessly.\"}}'",
"timeout": 5
}
]
}
]
}
}
Why both CLAUDE.md and a hook? Belt and suspenders. CLAUDE.md is a persistent instruction that the model reads. The hook is a model-level context injection that fires as an event. Together they ensure the recovery instruction isn’t missed.
3. CLAUDE.md (Project root — per repository)
Your project’s CLAUDE.md should include a context discovery section. This is where you reference CaseMgr as the source of truth and list the MCP tools to use. Keep project-specific build/test commands here, but move operational knowledge (environments, credentials, architecture) into CaseMgr cases.
## Post-Compaction Recovery (MANDATORY)
After every context compaction, you MUST immediately:
1. Call `preferences-get` to find the current case ID
2. If a current case exists, call `cmmn-get_resume_context` with that case ID
3. This restores: active tasks, context cases, in-progress work, and case summary
4. Resume work from where you left off
## Context Discovery
Use these MCP tools to find context:
- `items-semantic_search` — natural language search
- `items-search` — exact text match
- `cases-list` — browse active cases
- `items-list_children` — explore a case's contents
What Goes Where: A Guide
| Information | Where It Belongs | Why |
|---|---|---|
| Post-compaction recovery instructions | ~/.claude/CLAUDE.md + PostCompact hook |
Must survive compaction, needed in every project |
| Build/test commands | Project CLAUDE.md |
Project-specific, rarely changes |
| Architecture overview | Project CLAUDE.md (brief) + CaseMgr case (detailed) |
Brief reference in CLAUDE.md, full details in a context case |
| Server configs, SSH access, env details | CaseMgr context case | Dynamic, shared across projects, loaded on demand |
| Debugging procedures | CaseMgr context case | Loaded only when relevant case is active |
| Client requirements | CaseMgr context case | Per-client, linked as context to billing/project cases |
| Test credentials | CaseMgr context case | Centralized, not hardcoded in CLAUDE.md |
| Decision history | CaseMgr case notes/journal entries | Searchable, timestamped, per-case |
The principle: CLAUDE.md is the bootstrap. CaseMgr is the knowledge base. Keep CLAUDE.md small and static. Put everything dynamic, detailed, or case-specific into CaseMgr cases and link them as context.
Tips
- Keep context cases focused — A few well-organized notes beats a case with 100 items
- Use one context case for multiple projects — A “System Knowledge” case can be linked as context from many working cases
- Context links are directional — Case A linking to Case B doesn’t make B link to A
- No token cap — You control the size by what’s in the context case