> ## Documentation Index
> Fetch the complete documentation index at: https://codegeninc-fix-system-prompt-typo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Notebook Command

> Open a Jupyter notebook with the current codebase loaded

The `notebook` command launches a Jupyter Lab instance with a pre-configured notebook for exploring your codebase.

## Usage

```bash theme={null}
codegen notebook [--background]
```

### Options

* `--background`: Run Jupyter Lab in the background (default: false)

By default, Jupyter Lab runs in the foreground, making it easy to stop with Ctrl+C. Use `--background` if you want to run it in the background.

## What it Does

This will:

1. Create a Python virtual environment in `.codegen/.venv` if it doesn't exist
2. Install required packages (codegen and jupyterlab)
3. Create a starter notebook in `.codegen/jupyter/tmp.ipynb`
4. Launch Jupyter Lab with the notebook open

The notebook comes pre-configured with:

```python theme={null}
from codegen import Codebase

# Initialize codebase
codebase = Codebase('../../')
```

<Note>
  The notebook is created in `.codegen/jupyter/`, so the relative path `../../`
  points to your repository root.
</Note>

## Directory Structure

After running `codegen notebook`, your repository will have this structure:

```
.codegen/
├── .venv/          # Virtual environment for this project
├── jupyter/        # Jupyter notebooks
│   └── tmp.ipynb   # Pre-configured notebook
└── config.toml     # Project configuration
```

## Examples

```bash theme={null}
# Run Jupyter in the foreground (default)
codegen notebook

# Run Jupyter in the background
codegen notebook --background

# Initialize a new repository and launch notebook
codegen init && codegen notebook
```

<Tip>
  The notebook command will automatically initialize codegen if needed, so you
  can run it directly in a new repository.
</Tip>
