---
name: rewrite
description: Fix specific execution issues in episodes — flat dialogue, rushed beats, voice drift, unclear action.
allowed-tools: Read, Write, Edit, Glob
argument-hint: "[project] ep [N] \"[issue]\""
---

# /rewrite - Targeted Script Revision

Fix specific execution issues in microdrama episodes — flat dialogue, rushed beats, voice drift, unclear action.

## Usage

```
/rewrite [project] ep [N] "[issue description]"
/rewrite [project] ep [N-M] "[issue description]"   # Linked arc (max 5 episodes)
/rewrite [project] ep [N]                           # Suggest mode (AI finds issues)
```

**Examples:**
```
/rewrite leviathan ep 23 "Kian's dialogue feels too robotic"
/rewrite leviathan ep 47-49 "The scar revelation arc needs more buildup"
/rewrite leviathan ep 58 "The I love you moment feels rushed"
/rewrite leviathan ep 23                            # AI suggests issues
```

## Parameters

| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `project` | Yes | — | Project folder name |
| `ep [N]` | Yes | — | Single episode number |
| `ep [N-M]` | No | — | Range for linked arc rewrites (max 5 episodes) |
| `"[issue]"` | No | — | Your description of what's not working |

**Optional Flags:**
- `--max-words [N]` — Override word limit for this episode
- `--dialogue [N%]` — Override dialogue limit (default: 40%, per CONSTANTS.md)
- `--exchanges [N]` — Override exchange limit (default: 8)
- `--force` — Apply without constraint warnings

## Two Modes

| Mode | When | Behavior |
|------|------|----------|
| **Suggest** | No issue specified | AI scans episode, presents potential problems |
| **Fix** | Issue specified | Skip to generating rewrite options |

## What It Fixes

- Flat dialogue (no subtext, too on-the-nose)
- Rushed beats (major moments without room to breathe)
- Voice drift (character sounds wrong vs characters.md)
- Unclear action (vague or unfilmable descriptions)
- **Flagged deviations** from generation (see `state/deviation_log.json`)

## Deviation Log Integration

The `/rewrite` skill can consume flagged deviations from the generation phase:

```bash
# View flagged deviations
cat ./[project]/_pipeline/state/deviation_log.json | jq '.history[] | select(.flagged_for_review == true)'
```

Flagged issues include:
- Word count deviations that couldn't be auto-fixed
- Voice drift detected during generation
- Character repetition patterns

## Execution

When this skill is invoked:

1. **Read the agent prompt:** `/agents/rewrite_agent.md`
2. **Read target episode(s)** from `/[project]/scripting/episodes/`
3. **Present 2 AI options + custom input** for interactive selection
4. **Validate against V12 constraints** before applying
