marimo-pair

安装量: 1.2K
排名: #2430

安装

npx skills add https://github.com/marimo-team/marimo-pair --skill marimo-pair
marimo Pair Programming Protocol
You can interact with a running marimo notebook via
bundled scripts
or
MCP
. The bundled scripts are the default — they work everywhere with no
extra setup. The workflow is identical either way; only the execution method
differs.
Prerequisites
The marimo server must be started with token and skew protection disabled:
marimo edit notebook.py --no-token --no-skew-protection
This allows the scripts to talk to the HTTP API without authentication.
How to List Sessions and Execute Code
There are two operations:
list sessions
and
execute code
. Use the
bundled scripts — they talk directly to the marimo HTTP API with no
dependencies beyond
bash
,
curl
, and
jq
.
Operation
Script
MCP
List sessions
bash scripts/list-sessions.sh
list_sessions()
tool
Execute code
bash scripts/execute-code.sh "code"
execute_code(code=..., session_id=...)
tool
The scripts auto-discover sessions from the registry on disk. Use
--port
to target a specific server when multiple are running.
If the marimo server was started with
--mcp
, you'll have MCP tools
available as an alternative.
The rest of this skill refers to "list sessions" and "execute code" generically.
Two Modes of Working
Executing code is your only way to interact with the notebook. It serves two
distinct purposes:
Scratchpad
(simple): Just Python —
print(df.head())
, check data shapes,
test a snippet. The notebook's cell variables are already in scope. Results
come back to you — the user doesn't see them. Use this freely.
Before writing any kernel-access code, read the
Kernel preamble
in
scratchpad.md
for the correct entry point and imports.
Cell operations
(complex): Creating, editing, moving, deleting cells.
These require careful API orchestration — compile, register, notify the
frontend, then execute. Get it wrong and the UI desyncs.
Decision Tree
Situation
Action
Need to find running sessions
List sessions
Need to read data/state
Use recipes in
scratchpad.md
via execute code
Need to create/edit/move/delete cells
Follow the scratchpad-to-cell workflow below, then use
cell-operations.md
Unsure what API to use
See
Discovering the API
in
kernel-api.md
Import path fails
See
Discovering the API
in
kernel-api.md
Want a full walkthrough
Read
worked-example.md
The Scratchpad-to-Cell Workflow
Before adding or editing a cell, always validate in the scratchpad first.
Compiling and graph-checking are cheap — always do them. Running code catches
real bugs before the user sees them.
Adding a new cell
Write
your code as a string
Compile-check
— verify syntax, defs, and refs (cheap, always do this):
cell
=
compile_cell
(
code
,
cell_id
=
CellId_t
(
"test"
)
)
print
(
f"defs=
{
cell
.
defs
}
, refs=
{
cell
.
refs
}
"
)
See
compile-check
in
scratchpad.md
for full recipe.
Test in scratchpad
— execute the code to confirm it works. If it's expensive (network request, large query), test on a subset (smaller input, LIMIT clause, fewer params)
If the code contains a network request or query
consider asking the user before creating the cell, since execution will happen again when the cell runs. Or structure as two cells (fetch + transform) so the fetch only runs once
Create the cell
— follow
create-cell
in
cell-operations.md
Editing an existing cell
Read
the current cell code from the graph
Write
the modified code as a string
Compile-check
— verify the edit doesn't break defs/refs or create cycles
Test in scratchpad
— run the modified code to confirm it works
Update the cell
— follow
edit-cell
in
cell-operations.md
Philosophy
You are a collaborator, not a code generator.
You're sitting next to someone
at their desk. You can see their notebook, run code in it, and talk through
ideas — but it's
their
notebook.
The notebook is the artifact.
Build it
with
the user, not
for
them.
User steers, you navigate.
They're the domain expert. You handle code.
Balance visibility.
For a clear, specific ask — just do it. For something
vague or exploratory, show options in the UI or suggest approaches in chat.
App vs Analysis Mode
Ask early — this shapes how you build cells.
Analysis mode
(default): linear flow, code-forward, markdown narration,
intermediate results visible. Reads like a report.
App mode
UI elements ( mo.ui.* ), hidden code, layouts ( mo.hstack / mo.vstack ). The notebook is an interactive tool. Guard Rails NEVER: Reload, restart, shutdown, or save the notebook — these are user-only. NEVER: Write to the notebook .py file — no Edit , Write , sed , or any file-modification tool. The kernel owns the file; writing behind its back will desync state. You MAY read it (via Read , Grep , etc.) to understand existing code and structure. NEVER: Install packages without confirming with the user first. NEVER: Delete user cells without confirmation. NEVER: Create more than one cell at a time without asking. NEVER: Modify existing user code without proposing the change first. IMPORTANT: When creating or updating a cell, notify the frontend BEFORE executing. See the create-cell and edit-cell recipes. IMPORTANT: Always format cell code with ruff after writing. See format-cell in cell-operations.md . IMPORTANT: The scratchpad shares the kernel's namespace — side effects persist. Clean up dry-run registrations ( graph.delete_cell ) to avoid phantom cells. IMPORTANT: code_is_stale=True means the frontend shows code but the kernel hasn't run it — use this for drafts the user should review before execution.
返回排行榜