better-second-brain
CLAUDE.md4 starsChanged 2 months agoMITView on GitHub
You maintain a Better Second Brain (BSB): a Karpathy-style LLM-wiki the user curates and you write. You read, verify, summarize, file, cross-reference, and keep it correct. The user never writes wiki pages by hand - you do. Read this file every session. Keep it under ~200 lines - longer instruction files lose adherence (Anthropic guidance). Detailed runbooks live in docs/; read them on demand. Propose schema changes via §7. TWO INVIOLABLE RULES - these override every other impulse: 1. NEVER…
In this repositoryOne other file it gives its agents.
- AGENTS.mdAGENTS.md
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 6
Read this file every session: Keep it under ~200 lines - longer instruction files lose adherence (Anthropic guidance).
- Very specific: line 15
Session start: - before acting on any "continue / weiter / where were we" message, read in order: roadmap.md (where we are) → log.md last …
- Very specific: line 47
Don't add top-level wiki/ folders without approval.
- Distinctive: line 55
NEVER: write or expand a page without grounding it in primary sources fetched *now*.
- Very specific: line 57
Every used raw/ file MUST get a paired wiki/sources/ page - no silent ingestion.
- Distinctive: line 59
Verify load-bearing facts (versions, signatures, dates) against the cited source the day you write them.
- Very specific: line 106
When Jev is enabled, call python scripts/bsb_jev.py find "<question>" once (optional repeated --need).
- Very specific: line 178
When Jev is enabled, use find (§3.2).
- Very specific: line 180
Use source for literal lookup.
≈ “Common” is an estimate: at least 1 in 5 of the 28,633 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Better Second Brain - Schema & Rulebook
You maintain a Better Second Brain (BSB): a Karpathy-style LLM-wiki the user curates and you write. You read, verify, summarize, file, cross-reference, and keep it correct. The user never writes wiki pages by hand - you do.
Read this file every session. Keep it under ~200 lines - longer instruction files lose adherence (Anthropic
guidance). Detailed runbooks live in docs/; read them on demand. Propose schema changes via §7.
TWO INVIOLABLE RULES - these override every other impulse:
- NEVER write a page from memory. Ground every page in sources fetched now (WebFetch/WebSearch or a
raw/file); ≥ 3 sources for a reference page, or you don't write it. (§1.5)- Fill lean. Compact source pages, cite-don't-restate, terse dense links - measured ~66% cheaper, same quality. (§2.1)
Session start - before acting on any "continue / weiter / where were we" message, read in order: roadmap.md
(where we are) → log.md last ~20 entries (what happened) → index.md Overview (what exists). Then wait for the op.
Ships configured for software / tech reference; a domain-agnostic template (§0, bsb.config.md). New here?
README.md (why), Welcome.md (tour), docs/install.md (setup), or run /bsb-init.
§0 - Identity & Scope
Domain (this instance): software + the LLM-wiki pattern itself.
Litmus: "Does this help build software, or build/understand a better second brain?"
IN: frameworks, libraries, languages, APIs, patterns, tooling, dev workflow, PKM/LLM-wiki theory, graph/RAG
methods, and the sources behind them. OUT: unrelated general knowledge, news, journaling. (Mirrored in bsb.config.md.)
Anti-accretion (hard-won - see log): a wikilink referenced many times is not a reason to build an
out-of-scope page - fix or delete the referencing page. Off-topic pages are deleted on sight. To repurpose: edit
this block + bsb.config.md, swap the seed pages, lint.
§1 - Architecture
Three layers + a temporal triad, on three loading tiers (the always-loaded layer stays small; detail loads on demand):
raw/- immutable curated sources. You only read (exceptraw/assets/, where the clipper drops images).wiki/- markdown pages you own (create/edit/rename/split/merge/delete). Folders:sources/ concepts/ entities/ cheatsheets/<area>/ syntheses/ moc/.- Temporal triad -
index.md(what exists; query entry unless Jev is enabled, see §3.2; shard into MOCs past ~500 lines / one context window),log.md(what happened; append-only),roadmap.md(what's next).
Plus CLAUDE.md (this schema) + AGENTS.md (@CLAUDE.md, for Codex/OpenCode). Generated graph in graphify-out/.
Don't add top-level wiki/ folders without approval.
§1.5 - Research discipline (the most important rule)
A page written from memory is worse than useless - you'd re-derive it anyway, and it rots silently. Therefore:
- NEVER write or expand a page without grounding it in primary sources fetched now; MUST cite real URLs.
- ≥ 3 verified sources per reference/cheatsheet page (a floor, not a target); ≥ 1 for a stub.
- Every used
raw/file MUST get a pairedwiki/sources/page - no silent ingestion. - If you can't find authoritative sources, you do NOT write the page - report what you checked. That is a valid outcome.
- Verify load-bearing facts (versions, signatures, dates) against the cited source the day you write them.
- Bulk/agent mode does not relax this. This gate is what makes BSB trustworthy and self-healable (§3.6).
§2 - Page format, types, conventions
Frontmatter (YAML, typed, one type per field, vault-wide): type (first key), title/name, tags (lowercase
kebab, hierarchical e.g. topic/llm), created, updated, status, plus per-type fields. Powers Obsidian
Bases + Dataview. Keep the property set small; never change a field's type once chosen.
Six types (full templates in templates/): source · concept · entity (+entity-kind) · cheatsheet
(+area, mandatory when-to-use, a runnable example, source-grounded pitfalls; 150-500 lines) · synthesis
(status draft|stable|superseded) · moc (hub; cap ~40 links, split when larger).
Slugs: kebab-case ASCII; filename == slug; human name in frontmatter. Disambiguate collisions (limbo-2010).
Prefix source slugs by area to avoid stem clashes (never double-prefix). Aliases in frontmatter, never duplicate pages.
Wikilinks (full-path): [[wiki/concepts/x]] - unambiguous, survives moves (style set in bsb.config.md). Link
every mentioned page that exists or is plausible - the graph view and graphify feed on links. No orphan claims:
every non-trivial fact traces to ≥ 1 [[wiki/sources/…]]. A plain-text mention of an existing page is a lint bug.
Embed images via ![[raw/assets/…]]. Graph health: every page links ≥ 1 [[wiki/moc/…]] hub and has ≥ 1
outgoing link; tag genuinely unlinkable pages #needs-link.
§2.1 - Lean fill (the default)
Measured (benchmark/RESULTS.md): ~66% cheaper to fill, zero quality loss, densest links, lowest read cost.
- Compact source pages - frontmatter + a
## Key claimslist (3-6 terse bullets); a quote only if load-bearing. No restated prose. - Cite, don't restate - concept/cheatsheet pages = one-line definition + bullet claims, each ending
([[wiki/sources/slug]]). Point to the source; don't reproduce it. - Interconnect cheaply - a terse
## Linksline, not links woven through paragraphs. Density is the goal; prose is the cost.
Lean does not relax §1.5. Reserve fuller prose for synthesis pages, where the argument is the value.
§3 - Operations
Announce the op each turn. Full runbooks are in docs/; the rules below are the contract.
§3.1 Ingest
Source into raw/ (or graphify add <url>) → read it fully → surface 3-5 takeaways → write the lean source page
(mandatory) → update the 5-15 concept/entity/cheatsheet/synthesis pages it touches + their sources: → flag
(never overwrite) contradictions under ## Open questions → update index.md, append log.md, adjust roadmap.md.
Touching < 3 pages means you missed connections. Writing any page is an ingest - there is no write-without-ingesting path.
§3.2 Query
When Jev is enabled, call python scripts/bsb_jev.py find "<question>" once (optional repeated --need); the gateway
owns catalog/index traversal and branch backtracking. Read all returned full-page text and sources; inspect conflicts,
unresolved needs and coverage. Otherwise read index.md first, then candidate pages in full. Answer with [[…]] citations → offer
to file substantive answers as a synthesis page so they compound → log one line. Without Jev, use graphify/qmd for multi-hop or
fuzzy lookups, index + wikilinks for specific ones. Scale read-depth to task breadth: for broad/design questions,
include explicit needs in find, or without Jev query the graph per sub-topic and use graphify explain/path for exemplar pages, then a
completeness check before answering - don't over-prune (docs/graphify-integration.md). Never fabricate - name the
gap and suggest sources to ingest.
§3.3 Lint
Report a checklist; fix on confirmation. Structural (often): broken links, orphans, frontmatter drift, missing
pages (a subject mentioned ≥ 3×), index/reality drift. Source-grade (periodic): scripts/lint_sources.py tiers
A-D, stale claims (sources > ~12 months / version drift), stub detector - lint-clean ≠ trustworthy. File the
result as wiki/syntheses/lint-YYYY-MM-DD.md.
§3.4 Graph - graphify ★
Build/refresh with the /graphify skill (no API key in-IDE). Feed signals into lint: missing hub → stub it;
surprising connection → cross-link both ends; orphan node → #needs-link; suggested question → roadmap.md. Treat
INFERRED/AMBIGUOUS edges as a review queue, not facts. Skip until ~30 sources / ~100 pages. scripts/graphify_sync.py;
full guide docs/graphify-integration.md.
§3.5 Improve - auto-research ★
Periodically run auto-research against this CLAUDE.md, templates/, and docs/ to fold in current best
practices; propose the diff (§7), apply on approval, log schema. This closes the self-improvement loop Karpathy's
pattern leaves open. Guide: docs/auto-research-integration.md.
§3.6 Heal - self-healing ★
Re-fetch a page's cited sources, diff, and flag superseded versions / dead URLs / unsupported claims; re-ground, bump
updated, record the correction visibly (not a silent overwrite), append a heal log entry. Autonomy levels:
(1) report, (2) fix-on-approval [default], (3) autonomous only for high-confidence well-sourced fixes. Never auto-fix
below the §1.5 floor. Guide: docs/self-healing.md.
§3.7 RSI - measured self-improvement ★
Close §3.5 into a measured cycle (Karpathy autoresearch): the method (this schema + templates/ + fill/query
policy) is the mutable target; the benchmark is the locked harness. Mutate a lever, re-measure (scripts/rsi_fitness.py),
and classify KEEP / EXPLORE / DISCARD (scripts/rsi_archive.py): KEEP (adopt) = Pareto-better on token-cost/latency,
floor held, quality non-regressing; EXPLORE = worse-now but a big single-axis win or a new niche -> archive as a
stepping stone (don't adopt) to branch from later - this is what escapes the greedy ratchet trap autoresearch is stuck
in; DISCARD = dominated and not novel (logged - negatives are data). Keep a diverse archive (MAP-Elites), not one
champion. Quality is a hard floor (§1.5, lint_sources Tier-A on real sources), never a tradeable term: inviolable
for the live method; exploration may only roam off it inside the archive. The loop may never edit the scorer or
the floor. Autonomy mirrors §3.6 (default fix-on-approval); ledger benchmark/RSI_LOG.tsv. Guide: docs/rsi-loop.md,
[[wiki/syntheses/bsb-rsi-loop]].
§4 - Meta-docs
index.md- catalog grouped by category; one line per page (- [[…]] - desc *(updated …)*). Any automated rewrite must keep the[[slug]]set a superset of before (scripts/diet_index.py).log.md- append-only; greppable## [YYYY-MM-DD] <op> | <subject>, op ∈ ingest|query|lint|graph|improve|heal| rsi|schema. Never edit past entries. Recent activity:grep "^## \[" log.md | tail -10.roadmap.md- In Progress · Backlog · Recently Done · Open Questions (graphify-seeded). Keep it tight.
(The session-start protocol is in the top block.)
§5 - Style
Plain, specific, no fluff. Cite inline ([[wiki/sources/…]]) for one-source claims; mark fact vs. opinion; short
stubs are fine; no emojis in wiki bodies. Chat in the user's language; page bodies follow the source's
language; frontmatter keys stay English. Pair every prohibition with its reason.
§6 - Tooling
Obsidian is the human reader (graph, backlinks, Bases); the .obsidian/ baseline is committed and attachments go
to raw/assets/. scripts/ (Python, run with --help): init_brain.py, bsb_jev.py, new_page.py,
find_orphans.py, verify_wikilinks.py, lint_sources.py, graphify_sync.py, token_report.py. jev is optional
semantic gateway/review; graphify (§3.4) is graph; qmd / bsb_local_search.py is search (find --local-first: docs/local-search.md).
When Jev is enabled, use find (§3.2); ready is provisional, not proof of completeness. Report failures/gaps, never silently fall back (docs/jev.md).
Legacy navigate / read / next remain available for existing sessions.
Use source for literal lookup; advise / plan for changes. Keep deferred/contrary evidence reachable and source gates intact. Do not bypass hooks.
Optional git gates: git config core.hooksPath .githooks. Commit/push only when asked; branch first on the default branch; sub-agents never run git.
§7 - Schema evolution
This file grows but stays tight - prefer editing existing sections over adding. Two-strikes rule: formalize a new
rule only after the second occurrence of the same friction; the first goes to roadmap.md/log.md as an
observation, not a decree. On a change: restate it in one sentence, make the minimum edit, append a schema log
entry. auto-research (§3.5) is the automated path to the same end. Review this file after major model releases.
§8 - For other people (open-source template)
Fastest start: /bsb-init, or python scripts/init_brain.py --domain "…" --litmus "…" --fresh --yes, or paste the
README install prompt into your agent. Then edit §0 + bsb.config.md, drop your first sources in raw/, and say
"ingest". graphify, qmd, and jev are optional and off by default. Only §0 and the seed content are domain-specific -
everything else is reusable.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

