A local Claude Code plugin that turns an Obsidian vault into an autonomous Knowledge OS. This repository is the control layer: session capture, guardrails, structured note drafts, and promotion workflows.
second-brain captures Claude Code session activity and uses it to generate structured Obsidian notes automatically.
It manages:
- Claude Code hooks for session lifecycle events
- local plugin commands and agents for workflow control
- guard scripts that protect your vault from unsafe edits
- staged drafting and promotion into
Ideas/,Meta/Promotions/, andReferences/
The Obsidian vault is the long-term memory store, while this repo orchestrates how notes are captured, reviewed, and promoted.
- Enables friction-free knowledge capture from Claude Code sessions
- Keeps AI-generated output aligned to structured vault conventions
- Prevents accidental destructive shell or file operations
- Automates daily, weekly, monthly, and session summaries
- Makes review explicit by staging draft content before final promotion
- Hook wiring for
SessionStart,UserPromptSubmit,PreToolUse,PostToolUse,Stop, andSessionEnd - Prompt and tool capture via
scripts/session-memory.sh - Harvest queue, worker, and flush pipeline in
scripts/harvest.py - Draft distillation with
scripts/distill.pyandscripts/distill-draft.py - Promotion workflow with
scripts/promote.py - Observable vault guardrail scripts under
scripts/ - Plugin manifest, agent prompts, commands, and skills for Claude Code
- macOS or Linux
- Claude Code with local plugin support
jqinstalledpython3available onPATH- An Obsidian vault with a compatible note structure
git clone https://github.com/masuda-so/second-brain.git
cd second-brainRun the init helper with your vault location:
./scripts/init.sh "/path/to/your/Obsidian Vault"This setup step:
- validates
jqandpython3 - writes
SECOND_BRAIN_VAULT_PATHto.claude/settings.local.json - patches
CLAUDE.mdfor the vault path - installs the git pre-commit hook
- registers plugin hooks into local settings
- validates hook wiring and vault structure
- syncs starter templates into
Templates/
Open this repo as a Claude Code project. The plugin manifest, hooks, commands, and skills will be discovered automatically.
In Claude Code, use commands such as:
/status— view plugin status and session health/logs— inspect recent hook and script output/promote— move approved drafts fromMeta/Promotions/
| Path | Purpose |
|---|---|
CLAUDE.md |
Operating rules, vault conventions, AI behaviour |
hooks/hooks.json |
Session hook wiring |
hooks/pre-commit |
Git guard hook for vault safety |
scripts/ |
Core shell and Python utilities |
agents/ |
Claude agent prompts |
commands/ |
Operator command documentation |
skills/ |
Obsidian workflow helper skills |
.claude-plugin/plugin.json |
Claude Code plugin manifest |
settings.json.example |
Example environment settings |
Session lifecycle hooks capture prompts, tools, and edits, then surface structured drafts for review:
SessionStartinitializes session context, daily/weekly notes, and starts captureUserPromptSubmitlogs prompts and queues harvested contentPreToolUseblocks unsafe file or shell operationsPostToolUsevalidates edits and captures tool outputsStopruns the harvest workerSessionEndflushes queued content and distills session notes
Ideas/— low-score auto-sketchesMeta/Promotions/— staged drafts awaiting human reviewReferences/— high-confidence promoted contentProjects/— manual-only project notes
Local configuration belongs in .claude/settings.local.json. Key environment variables:
SECOND_BRAIN_VAULT_PATH— required absolute vault pathSECOND_BRAIN_DAILY_DIR— defaultDailySECOND_BRAIN_SESSION_DIR— defaultMeta/AI SessionsSECOND_BRAIN_CAPTURE_STRICT—1makes hook failures fatal instead of fail-open
CLAUDE.md— main operating guide and vault rulescommands/status.md— status command referencecommands/logs.md— log troubleshooting referenceREADME.ja.md— Japanese README
If you need help, open an issue with your setup details and the output from ./scripts/init.sh.
Maintained by masudaso.
Contributions are welcome via issues and pull requests. Prefer changes that are:
- small and reversible
- safe for user vaults
- aligned with
CLAUDE.mdrules - documented when they affect setup or operator workflow
Released under the MIT License. See LICENSE for details.