This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Marimushka is a Python CLI tool for exporting marimo notebooks to HTML/WebAssembly format with custom Jinja2 templates. It generates an index page listing all notebooks and enables deployment to static hosting (GitHub Pages, S3, etc.) without requiring Python on the viewer's side.
make install # Create venv and install dependencies using uv
make test # Run pytest with coverage (reports stored in _tests/)
make fmt # Run ruff format and ruff check --fix
make deptry # Check for missing/unused dependencies
make marimo # Start marimo development server
make clean # Clean artifacts and stale branchesCall chain: cli.py → export.py → orchestrator.py → notebook.py
-
cli.py- CLI entry point (Typer app)cli()→app()dispatchesexport,watch,versionsubcommandsconfigure_logging(): sets up loguru based on--debugflagwatch_command(): wrapswatchfilesfor auto re-export on file changes
-
export.py- Public Python APImain(): validates template, scans notebook folders, callsgenerate_index()- Entry point for programmatic use:
from marimushka.export import main
-
orchestrator.py- Core export engine and template renderinggenerate_index(): top-level orchestrator; exports all notebooks then renders indexexport_all_notebooks(): dispatches to parallel or sequential path with Rich progress barexport_notebooks_parallel(): ThreadPoolExecutor-based parallel exportexport_notebooks_sequential(): single-threaded fallbackrender_template(): Jinja2SandboxedEnvironmentrenderingwrite_index_file(): writesindex.htmlwith secure file permissions
-
notebook.py- Notebook abstractionKindenum:NB(static HTML),NB_WASM(interactive edit mode),APP(run mode, code hidden)Notebookdataclass: handles export viauvx marimo exportsubprocessfolder2notebooks(): scans directories for.pyfiles
-
validators.py- Input validationvalidate_template(): checks path traversal, file existence, type, and size (10 MB limit)
-
security.py- Security utilitiesvalidate_path_traversal(),validate_file_size(),validate_max_workers()sanitize_error_message(): redacts paths from error outputsafe_open_file(),set_secure_file_permissions()
-
audit.py- Structured audit loggingAuditLogger: logs file access, template renders, export operations as JSONget_audit_logger(): factory returning a default logger instance
-
config.py- TOML configurationMarimushkaConfig: dataclass with all export options and sensible defaults- Loads from
pyproject.tomlor a custom TOML file viafrom_toml()
-
dependencies.py- Dependency injection containerDependenciesdataclass: bundlesAuditLogger+MarimushkaConfigcreate_dependencies()/create_test_dependencies(): factory functions
-
exceptions.py- Exception hierarchy and result typesMarimushkaErrorbase class with specific subclasses (TemplateNotFoundError,IndexWriteError, etc.)NotebookExportResult,BatchExportResult: typed result containersProgressCallback: type alias for progress hook(completed, total, name) -> None
marimushka export- Export notebooks (default: parallel with 4 workers)marimushka watch- Watch mode for auto re-export on changes (requireswatchfiles)marimushka version- Show version
| Kind | Export Command | Use Case |
|---|---|---|
NB |
marimo export html --sandbox |
Static HTML notebooks |
NB_WASM |
marimo export html-wasm --mode edit --sandbox |
Interactive, editable |
APP |
marimo export html-wasm --mode run --no-show-code --sandbox |
Clean app interface |
Templates receive three lists: notebooks, apps, notebooks_wasm. Each notebook object has:
display_name- Human-friendly name (underscores → spaces)html_path- Relative path to exported HTMLpath- Original.pyfile pathkind- The notebook type
Default template: src/marimushka/templates/tailwind.html.j2
- Ruff for formatting and linting (line-length: 120, target: Python 3.11)
- Google-style docstrings (enforced via ruff pydocstyle)
- Full type annotations expected
- Tests in
tests/using pytest (100% coverage target) - Test fixtures in
tests/resources/(apps/, notebooks/, notebooks_wasm/, templates/)
This project uses the Rhiza framework for standardized Python development. Key conventions:
- Dependencies managed via
pyproject.tomlusinguv add - Makefile includes sub-Makefiles from
tests/,book/,presentation/,.rhiza/,.github/ - Workflow:
make install→ develop →make test→make fmt
| File | Purpose |
|---|---|
README.md |
User guide, installation, CLI usage |
API.md |
Python API reference for programmatic use |
CHANGELOG.md |
Version history and release notes |
CONTRIBUTING.md |
Contribution guidelines |
src/marimushka/templates/README.md |
Template customization guide with examples |