second_brain_builder CLAUDE.md

A guide for Second Brain Builder, an Obsidian plugin that turns selected note text into explanations or improved passages using Claude Code, Gemini, Codex, or Ollama. Obsidian is a note-taking application, and Ollama runs language models locally.

In plain words
What is it for?
Use it when changing explanation modes, inline enhancements, command-line or local-model providers, the generation queue, settings, or the plugin build process.
Why use it?
It explains how the plugin connects notes to different text-generation tools and how its source is built into an Obsidian plugin file.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/algometrix/second_brain_builder/claude-md
Clone the repo
git clone --depth 1 https://github.com/algometrix/second_brain_builder
Per session 2,048 This file is loaded in full into every session.
When invoked 2,048 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02048 $0.02048
Opus 5 $0.01024 $0.01024
Sonnet 5 $0.00410 $0.00410
Haiku 4.5 $0.00205 $0.00205

Measured yesterday against content hash c5186e11fb47, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

second_brain_builder CLAUDE.md scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- **src/cli.ts** -- typed `child_process.spawn` boundary (`SpawnedCliProcess`, `spawnCli`)
CLAUDE.md · 96 lines

How it starts

The opening of the file, as written. The whole thing — 96 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

What This Is

An Obsidian plugin ("Second Brain Builder") that generates detailed explanation notes using Claude Code CLI, Gemini CLI, Codex CLI, or a local Ollama server. Users select text in a note, pick a teaching style (mode), and the plugin spawns the CLI to produce a new note or inline enhancement. Desktop only; supports Windows, macOS, and Linux.

Build Commands

npm install          # install dependencies
npm run build        # type-check (tsc -noEmit) + production bundle
npm run dev          # esbuild watch mode (rebuilds on save)

The build produces main.js (CJS bundle) from the single entry point main.ts via esbuild. Use the Hot-Reload plugin in Obsidian for live dev.

Project Structure

Source lives in src/, bundled to a single root main.js by esbuild (entry point src/main.ts).

  • src/main.ts -- ClaudeExplainerPlugin: commands, context menus, the generation queue, CLI/Ollama providers, note orchestration
  • src/types.ts -- shared interfaces: modes, inline actions, queue items, settings (+ defaults), provider labels
  • src/inline-actions.ts -- the INLINE_ACTIONS catalog (expand, simplify, add diagram, ...)
  • src/output-rules.ts -- formatting rules appended to every prompt (getOutputRules, inline/append variants)
  • src/cli.ts -- typed child_process.spawn boundary (SpawnedCliProcess, spawnCli)
  • src/logger.ts -- in-memory ring logger behind the "Enable logging" setting
  • src/utils.ts -- filename sanitizing, JSON array extraction, empty-note detection
  • src/ui.ts -- shared modal helpers (title, mode cards, searchable mode grid)
  • src/fixers.ts -- output post-processing fixers (code fences, mermaid, callouts, dataview, currency)
  • src/modals/ -- one file per modal family: generation.ts, folder.ts, analysis.ts, queue.ts, system-design.ts
  • src/settings-tab.ts -- the settings UI, including per-provider setup guides
  • modes.json -- note generation modes loaded as BUILTIN_MODES at build time. Gitignored; resolved before every build by scripts/sync-modes.js (from modes.config.json's modesFile if present, else an existing modes.json, else modes.sample.json)
  • modes.sample.json -- committed sample set of general-purpose modes (Explain, Deep Inquiry, Feynman, etc.); the default build input for fresh clones
  • modes.config.json -- optional, gitignored; { "modesFile": "<path>" } points the build at a personal modes file (conventionally modes.personal.json, also gitignored)
  • styles.css -- modal and queue UI styles
  • manifest.json -- Obsidian plugin manifest (id: second-brain-builder)
  • scripts/ -- build helpers and vault fix scripts:
    • sync-modes.js -- prepares modes.json before builds (see above); wired into npm run build and npm run dev
    • vault-root.js -- shared vault path resolution for the fix scripts (first non-flag CLI argument, OBSIDIAN_VAULT env var, or OBSIDIAN_VAULT= in a gitignored repo-root .env)
    • fix-all.js -- unified runner that executes all fix scripts below in order
    • fix-callout-fences.js -- fixes callout code fences missing the > prefix on closing ``` or content lines
    • fix-currency-dollars.js -- escapes unescaped $ currency signs that Obsidian misinterprets as LaTeX
    • fix-mermaid-end.js -- strips extra end keywords with no matching block opener (subgraph, or sequence-diagram par/alt/opt/loop/rect/critical/break/box) and inserts zero-width space into "end" inside larger words
    • fix-mermaid-missing-end.js -- re-inserts missing end keywords (indentation-based placement) and puts the closing ``` fence on its own line
    • fix-split-end.js -- rejoins lines corrupted by an old regex that split words like "Send" into "S\nend"
    • fix-mermaid-parens.js -- quotes unquoted mermaid node labels containing parentheses or slashes
    • fix-mermaid-quotes.js -- strips nested double quotes inside already-quoted mermaid labels (inner " to ')
    • fix-mermaid-list.js -- fixes "Unsupported markdown: list" errors by converting N./N) to N: in labels and joining - item lines with <br/>

Read the full file on GitHub · 96 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 96 lines · 2,048 tokens per session scan A c5186e11fb47

Subscribe to this mod's changes

second_brain_builder CLAUDE.md is an instructions file published in the GitHub repository algometrix/second_brain_builder (4 stars, last pushed 1mo ago), licensed MIT. It adds 2,048 tokens to every session, about $0.0102 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other instructions, from other repositories

claude-obsidian GEMINI.md

Gemini CLI instructions for AgriciDaniel/claude-obsidian: Read AGENTS.md as the canonical host-neutral contract. Skills live in skills/ /SKILL.md and the portable core lives in claudeobsidian/.

AgriciDaniel/claude-obsidian · 219 tokens

claude-obsidian copilot-instructions.md

Copilot instructions for AgriciDaniel/claude-obsidian: Read AGENTS.md before proposing changes. The repository is an Agent Skills package, Claude Code adapter, standard-library Python core, and deterministic vault template—not the default live user vault.

AgriciDaniel/claude-obsidian · 186 tokens

obsidian-claude-sidebar CLAUDE.md

Instructions for derek-larson14/obsidian-claude-sidebar, covering claude sidebar - agent guide, what this plugin does, two things you can help the user do, step 1: diagnose and step 2a: file a bug report.

derek-larson14/obsidian-claude-sidebar · 2,409 tokens

vault-operator AGENTS.md

Instructions for pssah4/vault-operator, covering vault operator, projekt-regeln, navigation, zuerst lesen, projekt, tech stack and build und deploy.

pssah4/vault-operator · 1,496 tokens

obsidian-claude-sidebar AGENTS.md

Instructions for derek-larson14/obsidian-claude-sidebar: This repo's contributor guide lives in CLAUDE.md. Read that for context on filing issues, opening PRs, and what fits the project's scope.

derek-larson14/obsidian-claude-sidebar · 32 tokens

obsidian-vault-mcp CLAUDE.md

Instructions for ebullient/obsidian-vault-mcp, covering obsidian vault mcp, code style and qa.

ebullient/obsidian-vault-mcp · 163 tokens