When you launch Start Bonsai, the canvas appears with a first node that corresponds to the code file currently open in your editor.
Mandatory rule (always): your very first action must be Fix the problem.
- 0) Prerequisites
- 1) Open a file & Start Bonsai
- 2) UI at a glance
- 3) Activities (with numeric branching)
- 4) Branch management
- 5) Interaction (selection, borders, reasoning, code & metrics)
- 6) Trim
- 7) Export (save your session)
- 8) Troubleshooting
- 9) Short practice
- 10) Keyboard tips
- VS Code (latest stable)
- Bonsai extension installed
-
Open any source file (e.g.,
.py,.js,.ts,.java) and keep it active in the editor tab.

-
Press Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (macOS) and run “Start Bonsai”.

You should see the graph with a first node representing the currently open file.
-
Bonsai / Node map
-
Activity legend (colors) — each color denotes the activity applied:
-
Details pane (bottom or side)
Shows Code, Reasoning, Similarity, and Code Metrics for the selected node/action.

Click on a node first to select it, you will see a yellow border applied to it
Always start with Fix the problem. After that, you can apply any activity in any order and as many times as you wish.
Common flow to apply an activity:
-
Select a node (usually a leaf or a function you want to act on).
-
Click an Activity:
-
Numeric input for branching appears (e.g., “Number of variants/branches to create”):
-
Generate → Bonsai applies the activity, colors the affected node(s) according to the activity, and records outputs in the Details pane.
Tip: Use multiple variants when you want to explore alternative fixes/test suites/refactors in parallel.
-
Create branches automatically via the numeric input when applying an activity (N > 1).
You can re-apply the same activity multiple times across different branches (e.g., two distinct “Handle exceptions” strategies).
-
Click a node to select it (yellow border = selection).
-
If the selected node is a leaf:
-
If the selected node is not a leaf (container/parent):
Legend reminder: Border = similarity (only when a leaf is selected as anchor).
Fill color = last activity applied on that node (Fix / Generate tests / Refactor / Handle exceptions).
When you select a node (or after an activity runs), the Details pane shows:
- Code: the proposed patch, generated tests, refactor, or exception handling.

- Reasoning (when available): brief explanation of why the suggestion/patch/tests were produced.

- Metrics:
Use them together:
- Borders → where to look (similar candidates)
- Reasoning → why this change might help
- Code & Metrics → what changed and how big/similar it is
- Right-click a node → Trim to prune that node and all its children from the current canvas/branch (like pruning a bonsai).

This does not delete files; it simply removes the selected sub-tree from the bonsai so you can reduce clutter and focus on what matters now.
- Click Export JSON in the Bonsai view.
- Save the export file or copy the export ID.
- You can import it in the future by clicking on Import JSON

Always export before closing VS Code. If you’re in a study, export is required.
- Bonsai shows no initial node → Ensure a file is open and active before running Start Bonsai.
- Selection highlight or borders not visible → Re-select the node.
- Activities disabled → Select a node in the Bonsai canvas first.
- No numeric input when applying activities → Update the extension; verify the activity dialog hasn’t been dismissed.
- Export option missing → Start or resume a Bonsai session first.
- Open a file, Start Bonsai, and select a leaf node.
- Fix the problem (mandatory first action) with a description like “try off-by-one fix”. Set the numeric input to 2 to create two branches.
- In one branch, run Generate tests; in the other, try Refactor.
- Inspect borders (similarity), read reasoning, check metrics.
- Toggle Trim, then Export.












