marimo-notebooklisted
Install: claude install-skill minicoohei/ai-agent-camp
## トリガーワード
「marimoノートブック」「インタラクティブノートブック」「Pythonノートブック」「marimo」
# Notes for marimo Notebooks
## Running Marimo Notebooks
```bash
# Run as script (non-interactive, for testing)
uv run <notebook.py>
# Run interactively in browser
uv run marimo run <notebook.py>
# Edit interactively
uv run marimo edit <notebook.py>
```
## Script Mode Detection
Use `mo.app_meta().mode == "script"` to detect CLI vs interactive:
```python
@app.cell
def _(mo):
is_script_mode = mo.app_meta().mode == "script"
return (is_script_mode,)
```
## Key Principle: Keep It Simple
**Show all UI elements always.** Only change the data source in script mode.
- Sliders, buttons, widgets should always be created and displayed
- In script mode, just use synthetic/default data instead of waiting for user input
- Don't wrap everything in `if not is_script_mode` conditionals
- Don't use try/except for normal control flow
### Good Pattern
```python
# Always show the widget
@app.cell
def _(ScatterWidget, mo):
scatter_widget = mo.ui.anywidget(ScatterWidget())
scatter_widget
return (scatter_widget,)
# Only change data source based on mode
@app.cell
def _(is_script_mode, make_moons, scatter_widget, np, torch):
if is_script_mode:
# Use synthetic data for testing
X, y = make_moons(n_samples=200, noise=0.2)
X_data = torch.tensor(X, dtype=torch.float32)
y_data = torch.tensor(y)
data_error = None
else:
# Use widget data in interactive mode