---
name: compile
description: Compile episodes or treatment into .fountain format for reading.
allowed-tools: Read, Bash, Glob
argument-hint: "[project] [--treatment | --metadata]"
---

# /compile - Episode & Treatment Compiler

Compile episodes or treatment into readable .fountain format.

## Usage

```
/compile [project]
/compile [project] --metadata
/compile [project] --treatment
/compile [project] [output_name]
```

**Examples:**
```
/compile leviathan                    # Clean screenplay (no metadata)
/compile leviathan --metadata         # With episode titles + cliffhanger callouts
/compile leviathan --treatment        # Treatment to Fountain
/compile the-hike MY_SERIES.fountain  # Custom output name
```

## Modes

### Episode Mode (default)
Compiles all episode scripts into a clean screenplay file.

| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `project` | Yes | — | Project folder name |
| `output_name` | No | `[TITLE]_COMPLETE.fountain` | Custom output filename |

**Output:** `/[project]/[TITLE]_COMPLETE.fountain`

**Strips:** Word counts, dialogue percentages, cliffhanger annotations

### Metadata Mode (`--metadata`)
Compiles episodes with **episode titles and cliffhanger callouts preserved**.

**Output:** `/[project]/[TITLE]_WITH_METADATA.fountain`

**Preserves:**
- Episode title as centered heading (e.g., `> EPISODE 1: THE VOID <`)
- Cliffhanger type at end of each episode (e.g., `> [CLIFFHANGER: Mid-Action (M-PT) - Physical Threat] <`)

**Use case:** Review scripts with structural context visible.

### Treatment Mode (`--treatment`)
Extracts readable prose from treatment.md — just episode titles, prose paragraphs, and cliffhangers.

**Strips:** Metadata lines, thread markers, validation metrics, sequence headers

**Output:** `/[project]/treatment_reader.fountain`

## What It Does

### Episode Mode (Clean)
1. Finds all `ep_XXX.md` files in `/[project]/scripting/episodes/`
2. Strips ALL metadata (word counts, loglines, cliffhanger annotations)
3. Extracts clean Fountain content from each episode
4. Combines with page breaks (`===`) between episodes
5. Adds title page with series name and date

### Metadata Mode
1. Finds all `ep_XXX.md` files in `/[project]/scripting/episodes/`
2. Extracts episode title (# Episode N: Title)
3. Extracts cliffhanger type (**CLIFFHANGER TYPE:** ...)
4. Preserves both as centered Fountain elements
5. Combines with page breaks between episodes

### Treatment Mode
1. Reads `/[project]/treatment.md`
2. Extracts episode titles (### Episode N: "Title")
3. Extracts prose paragraphs
4. Extracts cliffhanger images (**[CLIFFHANGER: ...]**)
5. Strips all metadata, threads, metrics
6. Outputs clean reading version

## Execution

When this skill is invoked:

1. **Parse arguments** for project name and mode
2. **Run the compile script:**
   ```bash
   python3 "/tools/compile_episodes.py" "/path/to/[project]" [--treatment | --metadata]
   ```
3. **Report results:** output path, file size

## Requirements

- **Episode/Metadata mode:** Episodes must exist in `/[project]/scripting/episodes/`
- **Treatment mode:** `treatment.md` must exist in project root

## Compatible Apps

The output `.fountain` file works with:
- Highland 2
- Fade In
- Final Draft (import)
- WriterSolo
- Any Fountain-compatible editor
