Getting started
Mount Lens in marimo, a reactive Python notebook, create one selection, and inspect the context available to a code-mode agent.
Prerequisites
Use Python 3.10 through 3.14 and uv. The first uvx run downloads marimo and Lens. See Compatibility when adding Lens to an existing environment.
Start a notebook
Open a local notebook with Lens installed:
uvx --with marimo-lens marimo edit notebook.pyThis command creates an isolated environment for marimo and Lens, then opens the notebook editor.
Use an existing uv project
Add Lens to the project, then run marimo in that environment:
uv add marimo-lens
uv run marimo edit notebook.pyMount Lens
Render a result in one cell:
import marimo as mo
revenue = {"January": 42, "February": 58, "March": 39}
rows = [f"| {month} | {value} |" for month, value in revenue.items()]
mo.md(
"\n".join(
[
"| Month | Revenue |",
"| --- | ---: |",
*rows,
]
)
)Mount Lens in another cell:
from marimo_lens import Lens
lens = Lens()
lensKeep this cell mounted. Lens adds its dock to the bottom of the notebook and makes rendered output cells selectable.
Create a selection
Press Select, click one rendered location, and add a note such as “Make these values easier to compare.” The new S<n> selection appears in Open with its notebook target and producing cell.
Press Select again when the request refers to another point or region. An agent can resolve those selections together after one verified change.
Inspect the result
Open Selections from the Lens dock. The new selection appears in Open with a stable S<n> label, its note, target, point or region kind, and image status. Select the image action when capture succeeded to inspect the marked selection image.
Next: connect an agent
Connect an agent gives a notebook agent live code-mode access, reads the current Lens context, verifies a change, reveals the result, and resolves the selection. Read How Lens works first when you want the complete collaboration model. The Selections guide covers gestures, notes, image status, deletion, History, and reopening.