Key Concepts

Understanding how SourceBrain models knowledge will help you get the most out of it. This page covers the five core building blocks.

Lessons

A lesson is a single document in your knowledge base. It contains Markdown content: anything from a short note to a detailed explanation of a system component. Lessons are the atomic unit of knowledge in SourceBrain.

Think of a lesson like a wiki article: it covers one focused topic and links to related lessons with wikilinks, writing another lesson's path in double brackets ([[auth/jwt]]). Those links are two-way: each lesson shows its backlinks, and the whole knowledge base renders as a navigable graph in the web app.

Paths

Every lesson has a path: a slash-separated identifier that determines where it lives in the tree. Paths are freeform; SourceBrain doesn't enforce any schema. Design them to reflect your system's structure.

Common patterns:

auth/jwt               # feature / subtopic
auth/oauth/google
db/migrations          # layer / concern
db/indexes
api/rate-limiting
api/errors
infra/deployments
infra/secrets
πŸ’‘
Keep the top-level segments broad (feature areas, layers, or teams) and get specific as you go deeper. Three levels is usually enough.

Versions

Every time a lesson is created or updated, SourceBrain saves a new version. The current content is always the latest version. Older versions are retained indefinitely so you can see how your understanding evolved.

Each version records:

FieldDescription
contentFull Markdown text of the lesson at that point in time
messageOptional note explaining what changed (like a commit message)
authorEmail of the user who saved the version (cloud mode only)
created_atTimestamp when the version was saved

View the version history of any lesson with:

sourcebrain log auth/jwt

Workspaces

A workspace is a shared, named knowledge base in cloud mode. Each workspace has its own tree of lessons. A user can belong to multiple workspaces.

One person creates a workspace and becomes its owner. Owners and admins invite other users by email. Members can read and write lessons; admins additionally manage members and workspace settings. Only the owner can delete the workspace.

Workspace vs. local database

Local modeCloud workspace
Storage.sourcebrain/sourcebrain.db (SQLite)Server-side PostgreSQL, shared
AccessOnly on this machineAny browser or logged-in CLI
CollaborationNone (single user)Multi-user, invite by email
Auth requiredNoYes
OfflineYesNo

Switching workspaces

You can belong to many workspaces. The active workspace is stored in ~/.sourcebrain/config.json. Switch with:

sourcebrain workspace use other-team

Organizations (Pro)

With one workspace per repo, a company quickly has many workspaces and N member lists to keep in sync. An organization fixes that: it groups workspaces behind a single member list, so joining the org grants access to its org-visible workspaces automatically and leaving revokes it. A workspace can also stay private inside the org (grouped, but invite-only). Workspaces keep their own slugs and URLs; the org is a grouping, not a container you switch into.

The sharing model stays a set of concentric circles, each one ring wider: your personal lessons β†’ lessons shared with named people β†’ a workspace β†’ a team inside it β†’ the organization across workspaces. Cross-repo knowledge lives once, in a shared workspace, and is referenced by qualified links ([[ws:Platform/errors]], written with the workspace's name) instead of being copied around.


Plans & limits

Cloud workspaces are subject to per-plan limits. When you hit one, the server responds with a clear message (for example, "free plan allows 150 lessons; upgrade to Pro for unlimited") instead of silently failing. Upgrade from the Workspaces page in the web UI.

LimitFreeProEnterprise
Workspaces you own1UnlimitedUnlimited
Organizations you ownNone5Unlimited
Members per workspace325Unlimited
Lessons per workspace150UnlimitedUnlimited
SearchKeywordKeyword + semanticKeyword + semantic
Relevance scoresNoYesYes
AI lesson suggestions3 (trial)300 / monthUnlimited
Staleness checks (sourcebrain doctor)Stale references+ symbol-level drift+ symbol-level drift
Conflict detectionNoYesYes
πŸ’‘
Local mode has no limits. A .sourcebrain/ database can hold as many lessons as you like; plan limits apply only to cloud workspaces.

Sync: push and pull

When you have both a local .sourcebrain/ database and a cloud workspace, you can sync between them with push and pull.

How sync works

SourceBrain compares lessons by content hash (SHA-256 of the latest version content). If hashes match, the lesson is in sync and nothing happens. If they differ, SourceBrain classifies the state:

StateDescriptionAction
In syncSame hash on both sidesSkip
Local onlyExists locally, not on cloudPush: upload to cloud
Cloud onlyExists on cloud, not locallyPull: download locally
ConflictBoth sides changed independentlyPrompt you to resolve

Conflict resolution

When a conflict is detected, SourceBrain shows a unified diff of the two versions and asks you what to do:

Conflict: auth/jwt
--- local
+++ cloud
@@ -1,3 +1,3 @@
-JWTs expire after 30 days.
+JWTs expire after 7 days (tightened in v2.4).
 Secret is in env SOURCEBRAIN_JWT_SECRET.

[k] keep local  [c] cloud wins  [e] edit manually  [s] skip
ChoiceEffect
kUpload local content to cloud, overwriting the cloud version
cWrite cloud content to local, overwriting the local version
eOpen your editor with both versions for manual merge
sSkip this lesson; neither side is modified

Context export

The context command is SourceBrain's AI integration feature. It searches lessons by keyword and bundles the matching ones into a single Markdown document you can paste into an AI chat.

sourcebrain context "rate limiting"
sourcebrain context "database"
sourcebrain context "auth"     # > context.md

The output is a well-formatted document with each matching lesson under its own heading. No configuration needed; it just works.

πŸ’‘
Redirect output to a file for easy copy-paste: sourcebrain context "auth" > context.md
SourceBrain Docs Β· SourceBrain