Skip to content

Lean Brain Extension

Arnel Robles edited this page Oct 20, 2026 · 1 revision

Lean Brain Extension

A VS Code extension in vscode/ that shows the Brain database and the Test Queue. It reads the database and never writes it. Its only changes go through bin/brain: closing and reopening an item, answering a question, and routing or moving a queued job.

No telemetry and no network calls.

Install

The extension is not on the Marketplace. package.json sets private: true with the publisher baryo-dev, so you build the .vsix yourself:

cd vscode
npm ci
npm run package
code --install-extension lean-brain-<version>.vsix

npm run package runs the type check, a production bundle, then vsce package. It needs VS Code 1.90 or newer. The extension starts when the editor finishes starting up.

What it shows

  • Status bar. Open real failures and flaky items for the current workspace project, as counts with icons (red when a real failure is open). The tooltip reads Brain: N real, M flaky. The project is the folder name or the git main repository name, case-insensitive. With no match it counts every project. While a test job runs it adds the suite name and elapsed time, updated every 5 seconds. A click opens the dashboard.
  • Open items view. Items grouped by project, then kind. Click one for all its fields. Right click to close as fixed, close as not a bug, reopen, or copy the ref.
  • Queue view. Queued and running jobs with elapsed time and host, and the last 10 finished.
  • Dashboard. Seven tabs, each with a count badge where it has one:
    • Overview: what is waiting on you (question, blocker, pending and similar kinds) and headline numbers for the last 7 days.
    • Queue: lane cards, running jobs with live progress, queued jobs.
    • Cycles: one row per test cycle.
    • Suites: slowest suites by median duration, with the last 20 runs.
    • Flaky: open flaky items by times seen.
    • Load: load average at the start and end of each run.
    • Hygiene: open items not seen for 14 days, with a button that copies a brain list command.

Lean Brain: Show resume digest runs brain resume into an output channel.

Lane cards and progress

The Queue tab has one card for this machine and one for each [remote NAME] section of remotes.ini (it reads TEST_PHASE_REMOTES_FILE, and shows none when TEST_PHASE_REMOTES=off). A card shows busy or idle, the job it runs, how many queued jobs it may take, and jobs done and failed in the last 24 hours. See Remote Lanes.

Progress for a running job comes from its log under the test-phase run directory. Every 3 seconds the page shows the passed, failed and skipped lines so far, the last test, and how long the log has been quiet. Passed lines appear only when the runner prints them.

Route and move buttons

On a queued job, in the view and on the dashboard:

  • Send to a remote lane, run on this machine only, or run on any lane. These run brain queue route.
  • Run earlier or later swaps the job with its neighbour, by brain queue move. The buttons appear only when the installed brain has that command and the database has the priority column. Routing needs brain schema 7 (lean-agent 1.10.0).

Answering a question

A question item's page has an answer box. Sending the answer closes the question as answered, then delivers it to the Claude session that filed it. Brain keeps that session id, which the session-env hook sets (see Hooks).

  • The extension's own terminal runs that session: the answer is typed in.
  • The session has ended: claude --resume starts it again in its folder with the answer.
  • The session may still be open elsewhere: you pick between its next prompt (the hook hands the answer over) and a fork (--fork-session).
  • No session on record: the answer is saved.

It never resumes a session that is still open, so one conversation does not run twice.

Opening Claude Code

Lean Brain: Open Claude Code and the terminal button in the views open claude in an editor tab. Pending, risk and question items have Send to Claude, which starts a new session on that item. For a question it asks for a recommendation and leaves the item open. Other kinds are sent to be fixed and closed.

How it reads and runs

sql.js loads the database file into memory on each refresh. Refresh runs 2 seconds after brain.db changes, and on Lean Brain: Refresh. A failed read is retried once, then the last good data stays with a note. sql.js reads only the main file, so it expects brain's default rollback journal, not WAL mode.

Changes run bin/brain with an argument array and no shell.

Settings

All three are machine scope, and an untrusted workspace cannot set them.

Setting Default What it does
leanBrain.dbPath empty Path to brain.db. Empty uses LEAN_BRAIN_DB, then ~/.local/share/lean/brain.db.
leanBrain.brainPath empty Path to bin/brain. Empty uses brain on PATH, then the newest plugin in ~/.claude/plugins/cache/lean-agent/lean-agent/.
leanBrain.claudeCommand empty Absolute path to claude, the program only with no arguments. Empty searches the absolute PATH entries, then ~/.local/bin, ~/.claude/local, /opt/homebrew/bin and /usr/local/bin. Windows .cmd and .bat shims are refused.

Tests

npm test in vscode/ runs the vitest tests. See Development.

Clone this wiki locally