worktree-manager-obsidian-bridge
Claude Code plugin for worktree-manager workspaces.
Provides context injection, conversation archiving, and Memory Wiki organization — all local, no external queue.
What it does
1. SessionStart: Inject requirement context
When entering a worktree, reads requirement-docs/{branch}/README.md and injects it into Claude's system prompt:
<worktree-requirement-doc>
<!-- Source: /path/to/requirement-docs/feature-27118/README.md -->
[content]
</worktree-requirement-doc>
Nothing else is injected — no memory wiki pages, no project context, no staging state. Just the current worktree's requirement doc.
2. SessionEnd / PreCompact: Archive to staging
At session end or compaction, reads the session JSONL, extracts the {role, content} conversation, and writes:
.memory-staging/session-{timestamp}-{sessionId}.json
Format is compatible with the organizer pipeline (see below).
3. /memory-sync — Manual archive trigger
Users can run /memory-sync anytime to immediately archive the current conversation to staging.
4. /memory-archive — Run finalize
Users can run /memory-archive to execute the finalize pipeline, which:
- Reads
.memory-staging/organized/*.md summaries
- Reads current
memory/ wiki state
- Calls LLM to generate file operations
- Applies them to
memory/ (updates requirements, projects, index, log)
- Cleans up staging on success
Prerequisite: Run --accumulate first (see below).
5. Built-in organizer (accumulate + finalize)
The plugin embeds scripts/organizer/ — a two-phase LLM pipeline:
| Phase | Command | Model | Input | Output |
|---|
| accumulate | bun run scripts/organizer/index.ts --accumulate | gpt-4o-mini | .memory-staging/*.json | .memory-staging/organized/*.md |
| finalize | /memory-archive or --finalize | gpt-5.4 | organized + memory/ state | Updated memory/ wiki |
# Step 1: accumulate (cheap, run manually or on CI)
export OPENAI_API_KEY="..."
bun run "${CLAUDE_PLUGIN_ROOT}/scripts/organizer/index.ts" \
--accumulate --staging .memory-staging --config .memory-organizer.config.json
# Step 2: finalize (via /memory-archive skill, or manually)
bun run "${CLAUDE_PLUGIN_ROOT}/scripts/organizer/index.ts" \
--finalize --staging .memory-staging --memory memory --config .memory-organizer.config.json
6. Vault restore/ingest (legacy skill)
skills/workspace-vault-maintainer/ provides Obsidian Vault restore and ingest workflows. This was the original purpose of this repo; the memory hook features have since become the primary use case.
Architecture
Claude Code Session
├── SessionStart → inject-context.ts → requirement-docs/{branch}/README.md
├── SessionEnd → archive-memory.ts → .memory-staging/session-XXX.json
├── PreCompact → archive-memory.ts → .memory-staging/session-XXX.json
├── /memory-sync → archive-memory.ts --trigger=manual
└── /memory-archive → organizer/index.ts --finalize
All data stays local:
- Staging:
.memory-staging/ in worktree root
- Wiki:
memory/ in Vault root
- Config:
.memory-organizer.config.json in worktree root
Installation
Marketplace
claude plugin marketplace add guoyongchang/worktree-manager-obsidian-bridge
claude plugin install worktree-manager-memory-hook@worktree-manager-obsidian-bridge
Or declare in .claude/settings.json:
{
"enabledPlugins": {
"worktree-manager-memory-hook@worktree-manager-obsidian-bridge": true
}
}
Local development
git clone https://github.com/guoyongchang/worktree-manager-obsidian-bridge.git
claude --plugin-dir /path/to/worktree-manager-obsidian-bridge
Configuration
.memory-organizer.config.json (worktree root)
{
"llm": {
"accumulate": {
"provider": "openai",
"model": "gpt-4o-mini",
"api_key_env": "OPENAI_API_KEY",
"base_url": "https://api.openai.com"
},
"finalize": {
"provider": "openai",
"model": "gpt-5.4",
"api_key_env": "OPENAI_API_KEY",
"base_url": "https://api.openai.com"
}
}
}
hooks/hooks.json (plugin-scoped)
Registered hooks:
| Hook | Script | When |
|---|
| Setup | setup.sh | Plugin install |
| SessionStart | inject-context.ts | Every directory change |
| PreCompact | archive-memory.ts --trigger=pre-compact | Context compaction |
| SessionEnd | archive-memory.ts --trigger=session-end | Session ends |
File layout