slowlp
← Blog
Method 2026.06.11 · 7 min read

How I Made My Second Brain Manage Itself

Building Claude Code automation for the second wiki — how ingest, scrub, digest, and hooks fit together

Method

How I Made My Second Brain Manage Itself

Building Claude Code automation for the second wiki — how ingest, scrub, digest, and hooks fit together

Part 1. The Wiki Skeleton — Two Folders Is All You Need

I started with just two folders: raw/ and wiki/. One rule: never touch raw. Conversations, notes, pastes — whatever comes in, raw stays untouched. wiki is the synthesized output that the LLM builds and maintains. Nailing down the “source of truth vs. digested result” separation from the start meant no confusion later.

I scaffolded the whole structure with a single /docs-init skill run. It reads the project, then generates index.md, log.md, and typed folders under docs/ — tailored to the actual content. If files already exist, it just updates them without overwriting, so there’s no risk of losing existing work.

Skill placement got decided here too. Global (~/.claude/skills/) holds things I’d use in any project — docs-init, digest, query, capture. Project (.claude/skills/) holds things specific to this wiki. Skip this distinction early and you end up with a tangled mess later.

Part 2. The Digest Pipeline — Four Steps, One Flow

ingest → scrub → digest → lint. That’s the full path from raw to wiki.

ingest-chats kicks it off. Claude Code sessions pile up automatically in ~/.claude/projects/**/*.jsonl, and a script pulls only the new ones using a manifest. No token cost, no duplicates, done in seconds. I originally tried handing this to an LLM, but this step is basically “copy files” — a deterministic script is faster and safer.

Next comes scrub. It replaces secrets — API keys, social security numbers, passwords — with [REDACTED:type]. I was puzzled at first about why this was necessary, until I discovered that obsidian-git doesn’t run native pre-commit hooks when auto-committing. It uses an isomorphic-git implementation. So you can’t rely on git hooks. The PreToolUse hook is your actual line of defense.

digest is the raw → wiki transform. Because an LLM loses context every new session, I hardcoded the digest criteria in CLAUDE.md, and the command follows those criteria exactly. Early on I put all of this directly in CLAUDE.md, which meant every session loaded digest-related rules even when they weren’t relevant. Splitting it into a separate command gave me the “load only when needed” structure I wanted.

lint is the final health check. It catches orphan pages, contradictions, and missing cross-references. You don’t need to run it often, but once the wiki grows, you’ll need it eventually.

Part 3. Hooks — The Automated Guard Rails

The config is simple.

{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Skill",
      "hooks": [{"type": "command", "command": "scripts/hook_digest_guard.sh"}]
    }]
  }
}

Right before a digest runs, it scans the diffs in raw/ and wiki/. If it finds high-confidence matches for sk-ant-, ghp_, AWS keys, or SSN patterns, it rejects with exit 2. A script does the blocking — not the model — so there are no judgment calls.

One more thing I set up in this configuration: Remote Control mode. Connecting via claude.ai/code on mobile attaches to the session on this PC. The conversations land in the local jsonl on the PC, so the existing ingest-chats picks them up as-is. No matter where a conversation happens, it flows into the wiki through the same path.


The core idea is simple. Turn repeated work into single-word commands. /ingest-chats, /digest, /scrub — clear names mean you never wonder what to call when. The three steps look complex at first, but by the third time you use them, you can’t imagine going without.


← Prev: Agent Context Cutoff and Wiki Integration · Next →: AI Wrote It, But It’s My Story — Using a Second Brain as a Blog Engine Method: Claude Code 4 Control Surfaces · Deep dive: The Moment a Skill Becomes Logic · Background: Second Brain Design Decisions

Related
All posts →
COMMENTS