如何用 marimo pair 让 Claude Code 等 agent CLI 操作运行中的 marimo 笔记本【免费下载链接】marimoA reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.项目地址: https://gitcode.com/GitHub_Trending/ma/marimo假设你有一个正在运行的 marimo 笔记本本地marimo编辑器或 molab 云沙箱想让自己的 agent CLI——Claude Code、Codex 或 OpenCode——直接参与操作它读取变量、在 scratchpad 里试验逻辑、运行单元格、增删单元格甚至操作 UI 组件。marimo 官方推荐的做法是marimo pair一个需要单独安装的 agent skill。整条路径是本地安装 skill → 把连接 prompt 交给 agent CLI → 在笔记本 UI 里确认连接成功。主文档marimo pair 官方指南云端部分见 molab 指南。1. 安装 marimo-pair skillskill 装在你的机器上agent 那一侧不是装在笔记本服务端。二选一# 方式一用 npm npx skills add marimo-team/marimo-pair# 方式二用 uv uvx deno -A npm:skills add marimo-team/marimo-pair安装结果稍后可以用marimo pair prompt的校验 flag 复核见第 3 节。2. 连接 agent 到运行中的笔记本方式 A在 agent CLI 里直接发起最简单官方 quickstart 的做法是把下面这句话粘贴进你的 agent CLI对你的第一个笔记本发起 pair/marimo-pair pair with me on my_notebook.pymy_notebook.py是文档中的示例文件名替换成你要协作的笔记本文件名。方式 B用marimo pair prompt生成连接 promptmarimo CLI 内置了pair prompt子命令作用是“为一个运行中的 marimo 笔记本生成 pair programming 的 prompt”见 命令实现。--url必填指运行中的 marimo kernel 的 URL--claude/--codex/--opencode用于校验对应 agent 的 skill 已安装--file可选指定连接到哪个笔记本。命令自带 docstring 给出的示例https://localhost:8000与notebooks/example.py均需替换为你自己的 kernel URL 和笔记本路径claude $(uvx marimolatest pair prompt --url https://localhost:8000 --claude)其他两个 agent 同理codex $(uvx marimolatest pair prompt --url https://localhost:8000 --codex) opencode $(uvx marimolatest pair prompt --url https://localhost:8000 --opencode)连接到指定笔记本claude $(uvx marimolatest pair prompt --url https://localhost:8000 --file notebooks/example.py --claude)如果服务端要求认证加--with-token命令会以隐藏输入提示你输入 auth token并将其写入一个权限为0o600的本地临时文件文件名是 URL 的 SHA-256 前 6 位 -token.txt生成的 prompt 中会带上--token $(cat token 文件路径)的用法。注意这条命令的副作用是会在本地临时目录留下包含 token 的明文文件仅在可信机器上操作。3. 如何确认连接成功文档给出了三个可核对的信号skill 安装校验--claude/--codex/--opencode都会检查本机对应 agent 的 skill 目录里是否存在marimo-pair/SKILL.md。没装好时pair prompt向 stderr 输出The marimo-pair skill for Agent could not be found.并附两条安装命令看到这条输出说明 skill 缺失按提示安装后重试。prompt 输出内容正常执行时pair prompt输出的是给 agent 的文本 prompt包含笔记本 URL、来自 marimo-pair skill 的execute-code.sh执行命令带--url若指定了--file则带--file。URL 和文件路径在输出中会被 shell 引用quote即使路径含空格或元字符也可以直接复制进 shell。UI 里的 toast 确认按生成的 promptagent 连上后会在 marimo 里通过mo.status.toast(...)给用户发一条 toast告知它已准备好 pair。你在笔记本界面看到这条提示即代表 agent 已连上并可用。4. 可选在 molab 云沙箱上配对不想在本地跑笔记本时可以用 molab——免费的云托管 marimo 环境。配对流程见 molab 指南在 molab 上启动一个笔记本打开右上角的 actions panel点击Pair with an agent菜单中会给出连接本地 agent 的完整说明按说明复制 prompt 后在终端里正常使用你的 agent 即可——此后所有 Python 代码都会写进 molab 沙箱里的笔记本方便你之后分享这个成果。molab 侧的限制需要知道每个笔记本默认 4 CPU、32 GB RAM最长运行 12 小时空闲超过 90 分钟会自动关闭。5. 排查与边界pair prompt报could not be found对应 agent 的 skill 未安装或不在它能读取的目录里。错误信息本身附了安装命令按第 1 节安装即可。skill 的查找位置由 agent 决定Claude Code 看~/.claude与.claude下的skills、plugins及 marketplace 目录Codex 看~/.codex与.codexopencode 看.opencode/skills等见 实现。URL 或文件路径含特殊字符无需手工转义pair prompt生成的命令已对--url和--file做了 shell quote直接复制执行。与 MCP 的区别如果你的目标是让 coding agent 驱动一个活的笔记本官方明确建议用 marimo pair 而不是 MCP server——marimo 的 MCP 端点只暴露更低层的只读工具见 MCP 文档。下一步在 molab 上除了外部 agent笔记本还内置了免费的开源模型 AI 辅助重构单元格、生成新单元格两者可以并用见 molab 指南 的 Work with AI 一节。【免费下载链接】marimoA reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.项目地址: https://gitcode.com/GitHub_Trending/ma/marimo创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
