This skill should be used when the user asks to "use marimo", "create a marimo notebook", "debug a marimo notebook", "inspect cells", "understand reactive execution", "fix marimo errors", "convert...
Marimo is a reactive Python notebook where cells form a DAG and auto-execute on dependency changes. Notebooks are stored as pure .py files.
Only edit code INSIDE @app.cell function bodies. This is not negotiable.
NEVER modify:
@app.cell)def _(deps):)ALWAYS verify:
return var,Before claiming ANY marimo notebook works:
marimo check notebook.pymarimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputsThis is not negotiable. Claiming "notebook works" without executing and inspecting outputs is LYING to the user.
| Excuse | Reality | Do Instead |
|---|---|---|
| "marimo check passed, so it works" | Syntax check ≠ runtime correctness | EXECUTE with --include-outputs and inspect |
| "Just a small change, can't break anything" | Reactivity means small changes propagate everywhere | VERIFY with full execution |
| "I'll let marimo handle the dependency tracking" | Verification of correct behavior is still required | CHECK outputs match expectations |
| "The function signature looks right" | Wrong deps/returns break reactivity silently | VALIDATE all vars are in params AND returns |
| "I can modify the function signature" | Breaks marimo's dependency detection | ONLY edit inside function bodies |
| "Variables can be used without returning them" | Will cause NameError in dependent cells | RETURN all created variables |
| "I can skip the trailing comma for single returns" | Python treats return var as returning the value, breaks unpacking |
USE return var, for single returns |
Before every marimo edit:
Structure Validation:
@app.cell function bodiesSyntax Validation:
marimo check notebook.pyRuntime Verification:
marimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputsOnly after ALL checks pass:
Follow this sequence for EVERY marimo task:
1. EDIT → Modify code inside @app.cell function bodies only
2. CHECK → marimo check notebook.py
3. EXECUTE → marimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs
4. INSPECT → Use notebook-debug verification
5. VERIFY → Outputs match expectations
6. CLAIM → "Notebook works" only after all gates passed
NEVER skip verification gates. Marimo's reactivity means changes propagate unpredictably.
Claiming a marimo notebook works without executing it with --include-outputs and inspecting the results is LYING.
Syntax checks and code inspection prove nothing about reactive execution correctness. The user expects a working notebook where all cells execute correctly with proper dependency tracking.
.py files, version control friendly@app.cell decorator patternimport marimo
app = marimo.App()
@app.cell
def _(pl): # Dependencies as parameters
df = pl.read_csv("data.csv")
return df, # Trailing comma required for single return
@app.cell
def _(df, pl):
summary = df.describe()
filtered = df.filter(pl.col("value") > 0)
return summary, filtered # Multiple returns
@app.cell functions only$ in backticks - mo.md("Cost: $50") not mo.md("Cost: $50")| Command | Purpose |
|---|---|
marimo edit notebook.py |
marimo: Open notebook in browser editor for interactive development |
marimo run notebook.py |
marimo: Run notebook as executable app |
marimo check notebook.py |
marimo: Validate notebook structure and syntax without execution |
marimo convert notebook.ipynb |
marimo: Convert Jupyter notebook to marimo format |
# marimo: Export to ipynb with code only
marimo export ipynb notebook.py -o __marimo__/notebook.ipynb
# marimo: Export to ipynb with outputs (runs notebook first)
marimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs
# marimo: Export to HTML (runs notebook by default)
marimo export html notebook.py -o __marimo__/notebook.html
# marimo: Export to HTML with auto-refresh on changes (live preview)
marimo export html notebook.py -o __marimo__/notebook.html --watch
Key difference: HTML export runs the notebook by default. ipynb export does NOT - use --include-outputs to run and capture outputs.
Tip: Use __marimo__/ folder for all exports (ipynb, html). The editor can auto-save there.
mo.ui for interactive widgetsmo.sql(df, "SELECT * FROM df")mo.md("# Heading")1. Pre-execution validation:
# scripts: Validate notebook syntax and cell structure
scripts/check_notebook.sh notebook.py
Runs syntax check, marimo validation, and cell structure overview in one command.
2. Runtime errors: Export with outputs, then use notebook-debug skill:
# marimo: Export to ipynb with outputs for inspection
marimo export ipynb notebook.py -o __marimo__/notebook.ipynb --include-outputs
| Issue | Fix |
|---|---|
| Variable redefinition | Rename one variable or merge cells |
| Circular dependency | Break cycle by merging or restructuring |
| Missing return | Add return var, with trailing comma |
| Import not available | Ensure import cell returns the module |
For detailed patterns and advanced techniques, consult:
references/reactivity.md - DAG execution, variable rules, dependency detection patternsreferences/debugging.md - Error patterns, runtime debugging, environment-specific issuesreferences/widgets.md - Interactive UI components and mo.ui patternsreferences/sql.md - SQL cells and database integration techniquesWorking examples available in examples/:
examples/basic_notebook.py - Minimal marimo notebook structureexamples/data_analysis.py - Data loading, filtering, and visualization patternsexamples/interactive_widgets.py - Interactive UI component usageValidation utilities in scripts/:
scripts/check_notebook.sh - Primary validation: syntax check, marimo validation, cell structure overviewscripts/get_cell_map.py - Extract cell metadata (invoked by check_notebook.sh)notebook-debug - Debugging executed ipynb files with tracebacks and output inspection