second-brain
Health Warn
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 8 GitHub stars
Code Pass
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Pass
- Permissions — No dangerous permissions requested
No AI report is available for this listing yet.
Local-first personal knowledge base CLI — hybrid FTS + pgvector search, a GraphRAG entity graph, and LLM enrichment over your notes, transcripts, Slack & Gmail. Runs fully local on Ollama (no cloud, no API keys); queryable by any AI agent through the built-in MCP server. Postgres-backed, publishes an Obsidian-style Quartz wiki.
Second Brain
Local, queryable knowledge base and note vault with hybrid search and an entity-graph layer — searchable by any AI coding agent or assistant from any conversation.
Stores career docs, interview prep, Krisp transcripts, Slack threads, Gmail, and authored Markdown notes in Postgres + pgvector. Any agent reaches all of it through the brain CLI or the bundled brain-mcp MCP server — no re-pasting context into every chat.

Token savings
Querying brain returns a ranked snippet instead of dumping whole threads and files into an agent's context, so a lookup costs a fraction of the tokens a direct MCP or file read would:
| Source | Direct read (MCP / Read tool) |
Via brain (search + optional show) |
Savings |
|---|---|---|---|
| Gmail thread | 15–50k (metadata + full threads with quoted replies / headers) | ~2–4k (snippets + one targeted brain show) |
~5–15× |
| Krisp transcript | 25–75k (search + full transcripts across candidates) | ~6–16k (search + one relevant transcript) | ~4–10× |
| Long PDF / DOCX (30+ pages) | 15–25k (read the whole file) | ~1–9k (one snippet + targeted show) |
~5–15× |
Brain stores pre-extracted, quote-stripped bodies and hybrid-ranks before fetching, so only the passage that matched enters context. See the full per-source breakdown.
See it in 60 seconds
Install the CLI, then run the offline demo — a throwaway Postgres seeded with a synthetic Larkspur compliance corpus. No Ollama, no personal data, no model downloads:
pipx install git+https://github.com/mshtawythug/[email protected]
# or, with uv:
uv tool install git+https://github.com/mshtawythug/[email protected]
brain demo # spins up a sandbox Postgres, seeds 22 docs, runs a hero query
Sample output:
Provisioning the demo Postgres on port 55433 …
Seeding the synthetic Larkspur corpus (22 docs, no Ollama) …
Seeded 22 new doc(s) (0 already present).
brain demo · 'compliance horror stories'
┌──────────┬─────────────────────────────────────────────┬────────┬───────┬───────────────────────────────…
│ ID │ Title │ Source │ Score │ Snippet
├──────────┼─────────────────────────────────────────────┼────────┼───────┼───────────────────────────────…
│ … │ Compliance Horror Stories — collected war … │ manual │ … │ A running list of the compliance horror stories I never want to repeat …
│ … │ … 4 more ranked hits (SOC 2 readiness sync, incident postmortem, #compliance war-stories thread, …)
└──────────┴─────────────────────────────────────────────┴────────┴───────┴───────────────────────────────…
Try these next:
brain demo query "SOC 2 evidence request"
brain demo query "PCI scope creep"
brain demo query "vendor risk" --source gmail
brain demo query "GDPR deletion request"
brain show <id> # read the top hit in full (in your own brain)
brain demo teardown # remove the sandbox when done
(IDs and scores are per-run; the seeded corpus and its ranking are deterministic — the top hit is always the "Compliance Horror Stories" note.)
brain demo needs only Docker; brain demo teardown destroys the sandbox.
Already ran the demo? You have brain installed — jump straight to brain setup --profile … below.
Quick start
Full install — the brain CLI plus the runtime (Postgres, and optionally Ollama / graph / wiki):
curl -fsSL https://raw.githubusercontent.com/mshtawythug/second-brain/v0.2.0/install.sh | bash
The installer pipx-installs brain from the v0.2.0 tag, then runs brain setup to provision $BRAIN_HOME, start the Postgres container, and (optionally) install the wiki + Claude Code skill. Choose how much to stand up with --profile:
| Profile | Search | Extra dependencies beyond the core |
|---|---|---|
minimal |
FTS-only (BRAIN_EMBEDDER=none) |
None — core only (no Ollama, no models). |
standard (default) |
Hybrid (FTS + vector) | + Ollama + one ~1 GB embedding model (snowflake-arctic-embed2). |
full |
Hybrid + GraphRAG + wiki | + Apache AGE image, concept-extraction LLM, Quartz/Caddy wiki, and (opt-in) launchd daemons via --daemons. |
brain setup --profile minimal # Docker-only, FTS search — fastest to stand up
brain setup --profile standard # default: local hybrid search
brain setup --profile full --daemons
Prerequisites (core): Git, Python 3.11+, and a running Docker (Desktop or Engine) — the Postgres + pgvector database runs in a container on port 55432.
Optional extras (only if you want more than FTS-only search):
- Ollama — local, free embeddings + LLM enrichment. To upgrade a
minimal(FTS-only) brain to hybrid search: install Ollama, thenollama pull snowflake-arctic-embed2, setBRAIN_EMBEDDER=arcticin.env, and runbrain init && brain reembed. - Node.js 18+ and Caddy — only for the rendered wiki.
gwsCLI — only for Gmail ingest and Google-backed directory linking.
Prefer to drive every step yourself, or hacking on the code? See Installing from source.
Core usage
brain ingest ~/Documents/resume.pdf --tag career # ingest a file (TXT / MD / PDF / DOCX)
brain ingest-dir ~/Documents/career # recursive, idempotent by content hash
brain search "what did I tell my manager about the migration" # hybrid FTS + vector search
brain show <id-prefix> # full document body (6+ hex prefix)
brain list --source gmail --limit 20 # browse by source
brain tag <id-prefix> +interview +career -old-tag # add (+name) / remove (-name) tags
Add --json to search / show / list for machine-readable output, and --fts-only to search to skip the embedding call. The full command surface — Gmail ingest, enrichment, tacit-knowledge elicitation, GraphRAG, the proactivity/synthesis commands, and vault authoring — lives in the CLI reference.
Claude integrations
brain and the bundled brain-mcp server are harness-agnostic — any agent that runs a shell command or speaks MCP can query the corpus.
Claude Code — register the MCP server (or symlink the skills):
claude mcp add brain -- brain-mcp
Claude Desktop — add to ~/Library/Application Support/Claude/claude_desktop_config.json (replace /Users/you with your home directory):
{
"mcpServers": {
"brain": {
"command": "/Users/you/workspace/second-brain/.venv/bin/brain-mcp",
"env": {
"DATABASE_URL": "postgresql://brain:brain@localhost:55432/second_brain",
"BRAIN_EMBEDDER": "arctic"
}
}
}
}
uvx second-brain also launches the MCP server. Full walkthrough (symlink, smoke-test, troubleshooting): docs/guides/claude-desktop-setup.md.
How it works
Hybrid search. Every document is chunked, embedded, and indexed for Postgres full-text search. A query runs both legs — lexical tsvector ranking and vector cosine similarity — and fuses them with Reciprocal Rank Fusion (k=60), then applies a recency boost and metadata filters. Lexical alone misses paraphrases ("what did I say about X"); vector alone misses exact names (a coworker, a former employer); RRF gets both in one ranked list without tuning weights. Set BRAIN_EMBEDDER=none for an FTS-only brain with no embedding dependency at all.
GraphRAG. Alongside search, brain builds an entity graph of the people and concepts that co-occur across the corpus (Apache AGE inside the same Postgres) and retrieves over that structure — answering "what themes come up in my conversations with X" or "which clusters of people and topics dominate my notes" by traversing relationships instead of matching text. It runs alongside plain search, not instead of it. See docs/graphrag.md.
Documentation
- docs/ — full documentation index
- CLI reference — every command beyond the core five
- GraphRAG — entity-graph retrieval (themes, patterns, connections)
- Vault and Wiki — the two-tier note vault + optional rendered wiki
- Configuration — tech stack, tuning knobs, integrations, embedder backends, uninstall
- CONTRIBUTING.md — dev setup, codebase layout, running the tests
- CHANGELOG.md — release history
- LICENSE — MIT
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found