Brain CLI
Go to file
ibotzhub 61b9c3ab8a style: remove emojis and non-ASCII punctuation from CLI and docs
Use plain ASCII for user-facing messages and documentation: no checkmarks
or symbols in terminal output, no em dashes in prose, and arrows or list
markers in docs use ASCII (-> and hyphen bullets).
2026-05-13 01:35:28 -07:00
cmd style: remove emojis and non-ASCII punctuation from CLI and docs 2026-05-13 01:35:28 -07:00
internal/brain chore: ignore build artifacts and remove committed binary 2026-05-13 01:18:12 -07:00
.gitignore chore: ignore build artifacts and remove committed binary 2026-05-13 01:18:12 -07:00
ARCHITECTURE.md style: remove emojis and non-ASCII punctuation from CLI and docs 2026-05-13 01:35:28 -07:00
CHANGELOG.md style: remove emojis and non-ASCII punctuation from CLI and docs 2026-05-13 01:35:28 -07:00
ci.yml Add files via upload 2026-01-28 22:42:32 -08:00
CONTRIBUTING.md Add files via upload 2026-01-28 22:44:41 -08:00
go.mod Refactor: restructure codebase and implement major updates 2026-05-13 01:03:19 -07:00
go.sum Refactor: restructure codebase and implement major updates 2026-05-13 01:03:19 -07:00
main.go Refactor: restructure codebase and implement major updates 2026-05-13 01:03:19 -07:00
PROJECT_SUMMARY.md Update PROJECT_SUMMARY.md 2026-01-29 03:22:00 -08:00
QUICKSTART.md style: remove emojis and non-ASCII punctuation from CLI and docs 2026-05-13 01:35:28 -07:00
README.md style: remove emojis and non-ASCII punctuation from CLI and docs 2026-05-13 01:35:28 -07:00
release.yml Add files via upload 2026-01-28 22:42:32 -08:00
TESTING.md Create TESTING.md 2026-01-29 03:24:56 -08:00
UPDATES_SUMMARY.md style: remove emojis and non-ASCII punctuation from CLI and docs 2026-05-13 01:35:28 -07:00

Brain CLI

A second brain for developers. Save your ideas, learnings, and insights, then surface them exactly when you need them using semantic search and context awareness.

Why Brain?

Ever had that "I know I learned this before..." moment? Brain remembers for you. It is not just a note-taking tool. It understands what you are working on and surfaces relevant knowledge automatically.

Features

  • Semantic Search: Find notes by meaning, not just keywords
  • Context Awareness: Get relevant notes based on your current project/directory
  • Smart Tagging: Organize with tags and projects
  • Lightning Fast: Built in Go, instant responses
  • Local First: Your data stays on your machine
  • AI-Powered: Uses embeddings for intelligent search (OpenAI or local fallback)

Installation

go install github.com/ibotzhub/second-brain-cli-something@latest

Or clone and build:

git clone https://github.com/ibotzhub/second-brain-cli-something
cd second-brain-cli-something
go build -o brain
sudo mv brain /usr/local/bin/

Quick Start

# Add a note
brain add "Redis caching reduced our API latency by 60%"

# Add with tags
brain add "Always use context.WithTimeout for API calls" --tags go,best-practices

# Add to a project
brain add "Team decided on tabs over spaces" --project myapp

# Search semantically
brain search "making APIs faster"

# Get notes relevant to your current directory/project
brain context

Commands

brain add

Save a note to your brain.

brain add "Your insight here"
brain add "Note content" --tags tag1,tag2
brain add "Note content" --project myproject
brain add "Note content" --tags go,performance --project api-service

brain list

List all your notes, sorted by most recent first.

brain list
brain list --limit 10
brain list --tags go,performance

Search your notes semantically.

brain search "performance optimization"
brain search "database" --limit 10
brain search "API design" --tags go

The search understands meaning. Searching for "making things faster" will find notes about "performance optimization" even if they do not contain those exact words.

brain context

Show notes relevant to what you're currently working on.

cd ~/projects/my-api
brain context
# Shows notes related to this project, recent commits, etc.

Brain analyzes:

  • Current directory name
  • Git repository (if present)
  • Recent commit messages
  • Project metadata

brain ask

Ask a natural language question and get answers based on your notes.

brain ask "What have I learned about database optimization?"
brain ask "How should I handle errors in Go?"

Configuration

For best results, set your OpenAI API key:

export OPENAI_API_KEY="sk-..."

Brain uses text-embedding-3-small which costs ~$0.02 per 1M tokens. For a typical note, that's less than $0.0001.

Local Embeddings (Fallback)

If no API key is set, Brain falls back to a simple local embedder. It works but won't be as accurate for semantic search.

How It Works

  1. You save a note: Brain generates an embedding (semantic vector) of your note
  2. You search: Brain generates an embedding of your query
  3. Magic happens: Brain finds notes with similar embeddings using cosine similarity
  4. You get results: Ranked by relevance, not just keyword matching

Data Storage

All data is stored locally in ~/.brain/:

  • notes.json: Your notes and metadata
  • vectors.db: Embeddings for fast search

Examples

Learning from a bug fix:

brain add "Goroutine leak fixed by using context cancellation in HTTP client" --tags go,debugging

Later, working on HTTP code:

brain search "http client issues"
# Finds your note about goroutine leaks

Team decision:

brain add "Decided to use PostgreSQL over MySQL for better JSON support" --project myapp

Months later in that project:

cd ~/projects/myapp
brain context
# Reminds you about the PostgreSQL decision

Roadmap

  • Interactive brain ask command with LLM synthesis
  • Auto-tagging with LLMs
  • Export to Markdown/Obsidian
  • Sync between machines
  • Browser extension for saving web insights
  • Integration with IDE (VS Code extension)
  • Link detection between related notes
  • Spaced repetition reminders

Contributing

Contributions welcome! This is a learning project and an experiment in building useful dev tools.

License

MIT

Inspiration

Inspired by the concept of a "second brain" and tools like Obsidian, but built specifically for developers who live in the terminal.


Built with Go because josh liked it and he has good taste.