notebrain-cli
AGENTS.md27 starsChanged 2 months agoMITView on GitHub
NoteBrain is a Go CLI tool that indexes an Obsidian vault into ChromaDB for semantic search, backlink traversal, graph connections, hidden connections, shared tags, and graph-boosted search.
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- notebrain-assistantSkill
The file
We split this AGENTS.md into the rules it gives an agent
12 rules. About 0 are common, 8 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 72
Test-Driven Development (TDD): Write tests FIRST, then implement the minimum code to pass them.
- Distinctive: line 73
Every public function and method MUST have corresponding test coverage.
- Distinctive: line 74
Use table-driven tests where appropriate.
- Very specific: line 75
Use testify for assertions only if already in go.mod.
- Very specific: line 78
Strict Non-Regression Guardrails: When refactoring or removing features, always add explicit assertion tests across internal/configfile/ …
- Very specific: line 83
Follow standard Go formatting (gofmt/goimports).
- Very specific: line 84
Use context.Context as the first parameter for any function that does I/O.
- Distinctive: line 86
No global mutable state. Pass dependencies explicitly (config, store, embedder).
- Distinctive: line 87
Use the options/functional-options pattern where it simplifies APIs.
- Distinctive: line 88
Keep packages focused: one responsibility per package.
- Distinctive: line 115
Only lint services/directories that have changes in the working directory.
- Distinctive: line 116
Do NOT run all linting tasks at once.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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
NoteBrain CLI — Agent Rules
Project Overview
NoteBrain is a Go CLI tool that indexes an Obsidian vault into ChromaDB for semantic search, backlink traversal, graph connections, hidden connections, shared tags, and graph-boosted search.
Technology Stack
- Language: Go 1.26.4
- CLI Framework: kong v1.15.x (with custom TOML configuration resolver)
- Vector Store: ChromaDB via chroma-go v0.4.x (
pkg/api/v2) - Build:
CGO_ENABLED=1(embedded persistent client via SQLite/HNSW bindings)
Module Path
github.com/nmdra/notebrain-cliProject Structure
notebrain-cli/
├── main.go
├── go.mod
├── Makefile
├── config/
│ └── config.go
├── internal/
│ ├── store/ ← ChromaDB wrapper (replaces DuckDB)
│ │ ├── store.go
│ │ ├── upsert.go
│ │ ├── query.go
│ │ └── *_test.go
│ ├── parser/ ← Markdown parsing, slugify, chunking
│ │ ├── parser.go
│ │ └── *_test.go
│ ├── ingest/ ← File ingestion pipeline
│ │ ├── ingest.go
│ │ └── *_test.go
│ ├── embedder/ ← Embedding backends (MiniLM, Ollama)
│ │ ├── embedder.go
│ │ └── *_test.go
│ ├── llmparse/ ← LLM-based PDF to Markdown conversion (OpenRouter, DeepSeek)
│ │ ├── llmparse.go
│ │ ├── openai_compat.go
│ │ ├── prompt.go
│ │ └── *_test.go
│ ├── pdfextract/ ← WASM PDFium extraction
│ │ ├── backend.go
│ │ ├── pdfextract.go
│ │ └── *_test.go
│ └── obsidian/ ← Obsidian CLI client
│ ├── client.go
│ └── *_test.go
└── cmd/
├── cli.go
├── ingest.go
├── search.go
├── backlinks.go
├── refs.go
├── connections.go
├── hidden.go
├── tags.go
├── boosted.go
├── stats.go
└── reset.goDevelopment Methodology
- Test-Driven Development (TDD): Write tests FIRST, then implement the minimum code to pass them.
- Every public function and method MUST have corresponding test coverage.
- Use table-driven tests where appropriate.
- Use
testifyfor assertions only if already in go.mod; otherwise use stdlibtesting. - Name test files
*_test.goalongside the source file. - Go Vendoring: This repository uses Go vendoring (
vendor/). Whenever dependencies ingo.modorgo.sumare added, removed, or updated, you MUST rungo mod vendorbefore running tests or builds. - Strict Non-Regression Guardrails: When refactoring or removing features, always add explicit assertion tests across
internal/configfile/andinternal/store/to verify that existing core functions, default settings, TOML key resolution, and database initialization do not regress or depend on removed parameters. - CLI Testing & Flag Standards: When executing CLI commands or writing automated tests/scripts for NoteBrain, strictly use the exact flag names
--vault-pathand--chroma-path(never--vaultor--db). For graph and note commands (backlinks,connections,hidden,tags,get,refs), pass exactly one positional argument: the note slug (<note>). Forrefs, use--only-images/--only-pdf/--only-other/--only-external-linksto limit by kind (no flags = all kinds) and--include-missingto surface broken attachment links. Forboostedsearch, always provide the required--seed=<slug>flag. When testinghiddenconnection discovery where already-linked notes should be included, pass--include-linked. Use--candidate-chunks(not the removed--top-k) to control deep hidden-analysis depth. Note thatbacklinksandconnectionscanonicalize link targets by stripping#headinganchors and matching exact vault subfolders. Use--show-tagsto show tags in CLI output. When testingresetin automated scripts, pipe confirmation via stdin (echo yes | ./notebrain reset). To avoid contextual empty-result hints in automated scripts, always request machine formats (--format=json,tsv, or--jsonpath). When testing LLM-based PDF ingestion, use--with-pdfand--llm-model, and provide the required API key via environment variables (DEEPSEEK_API_KEY, orOPENROUTER_API_KEY). Use--exclude-notesto exclude notes from search.
Coding Conventions
- Follow standard Go formatting (
gofmt/goimports). - Use
context.Contextas the first parameter for any function that does I/O. - Errors must be wrapped with
fmt.Errorf("context: %w", err)for traceability. - No global mutable state. Pass dependencies explicitly (config, store, embedder).
- Use the options/functional-options pattern where it simplifies APIs.
- Keep packages focused: one responsibility per package.
ChromaDB Collections
| Collection | Purpose | Has Embeddings |
nb_chunks | Note text chunks with vectors + metadata | Yes |
nb_links | Wikilink graph edges (metadata-only) | No (dummy 16-dim random L2 vectors) |
Testing Strategy
- Unit tests — Pure logic (parser, config, metadata encoding)
- Integration tests — Store operations against a temporary ChromaDB (use
t.TempDir()) - No mocks for ChromaDB — Use real persistent client in tests with temp directories
Commit Messages
Use Conventional Commits:
feat(store): add UpsertChunks method
test(parser): add table-driven tests for Slugify
fix(ingest): handle empty frontmatter gracefullyLinting
- Only lint services/directories that have changes in the working directory.
- Do NOT run all linting tasks at once.
Key Design Decisions
- Tags encoded as
tag_0,tag_1, … (not array metadata) for Go client compatibility. - Graph traversal (BFS) done in Go, not SQL — ChromaDB has no SQL.
nb_linksuses dummy 16-dimensional random float vectors in L2 space because Chroma requires non-empty vectors with uniform dimensions per collection, and flat zero-vectors or 1-dim vectors trigger HNSW index degeneracy/crashes.DeleteNoteChunksBEFOREUpsertChunks(not after) to handle interrupted re-ingests.- Persistent client is single-writer — fine for CLI usage.
- TOML-Only Configuration: Configuration hierarchy is strictly 2-tier: CLI flags > TOML configuration file (
~/.notebrain/config/config.tomlor--config). No.envfiles or application environment variable fallbacks are permitted except for secret API keys (DEEPSEEK_API_KEY,OPENROUTER_API_KEY) which must be provided exclusively via environment variables. TOML keys support normalized matching (snake_caseandkebab-casematch interchangeably). - Embedded Persistent Storage Only: NoteBrain strictly embeds ChromaDB in persistent mode (
CGO_ENABLED=1). Standalone HTTP server connections (CGO_ENABLED=0) are intentionally unsupported to keep the CLI lightweight, self-contained, and zero-setup. - OS-Level Scheduled Ingestion: In line with Unix philosophy, periodic re-indexing is handled by standard OS schedulers (cron, systemd timers) rather than a custom persistent background watch daemon or file-watching loop. Recommended ingestion interval is every 3 hours.
- Decoupled Automated Ingestion Logging: Because
notebrain ingestis frequently executed as an automated background task (cron, systemd timers, agentic workflows), it strictly uses structured logging (log/slog) for progress reporting to guarantee clean, machine-readable operational logs. - Goldmark AST & Structural Continuity: Note text chunking (
internal/parser) strictly preserves syntax for Markdown lists (1.,-), task checkboxes ([ ]), blockquotes/callout headers (> [!NOTE]), and GFM tables with alignment separator rows (| --- | --- |). Distinct structural blocks (paragraph,list,table,blockquote,code) are separated by\n\nacross chunks, while reconstructed notes (notebrain get) automatically prepend dynamic section headers (### Section Heading\n\n<text>).
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.

