---
name: load-context
description: Load narrative context for scripting sessions (generation, treatment, development). Do NOT use during engine/pipeline code work — it wastes context window on irrelevant files.
allowed-tools: Read, Glob, Bash, Write
argument-hint: "[project] [mode]"
---

# /load-context — Session Context Loader

Load narrative context for scripting sessions. **Use only when doing generation, treatment, or development work — NOT during engine/pipeline coding.**

## Usage

```
/load-context [project] [mode]
/load-context [mode]              # Infer project from current directory
/load-context                     # Auto-detect everything
```

**Modes:**
- `generate` — Episode generation (default)
- `develop` — Development/pre-production work
- `treatment` — Creating or revising treatment.md

**Examples:**
```
/load-context leviathan generate
/load-context leviathan develop
/load-context treatment
/load-context
```

---

## Execution Instructions

When this skill is invoked, follow these steps:

### Step 1: Parse Arguments

Extract `[project]` and `[mode]` from arguments.

**If project not specified:** Detect from current working directory:
- If in `/leviathan/` → project = leviathan
- If in `/olympus/` → project = olympus
- If in `/projects/[name]/development/` → project = [name], set mode = develop

**If mode not specified:** Default to `generate`

### Step 2: Load Files by Mode

**ALWAYS load (all modes):**
```
/CONSTANTS.md                             ← Numeric values (single source of truth)
/skills/format_v12/SKILL.md               ← V12 format rules
```

---

**For `generate` mode, ALSO load:**

**Core files (REQUIRED):**
```
/[project]/treatment.md                           ← **MASTER** generation input
/[project]/ORCHESTRATION.md                       ← Project-specific rules
/[project]/scripting/bible/characters.md          ← Voice patterns (CRITICAL)
/[project]/_pipeline/state/current_state.json     ← Position tracking
```

**Reference files (for correct generation):**
```
/skills/orchestration_process/SKILL.md    ← Batch loop, checkpoint protocol
/appendix_a_cliffhangers_hooks.md         ← Hook/cliffhanger taxonomy
/docs/dramaturgy_core.md                  ← 5 narrative physics rules (VALUE TURN, DANGLING CAUSE, COVER TEST, ESCALATION, INTEGRATION)
```

**Continuity files (if episodes exist):**
Check `current_state.json` for `last_completed_episode`, then load:
```
/[project]/scripting/episodes/ep_[N-1].md         ← Previous episode (if exists)
/[project]/scripting/episodes/ep_[N].md           ← Last completed (if exists)
```

---

**For `treatment` mode, ALSO load:**

**Core files (REQUIRED):**
```
/[project]/scripting/bible/series_bible.md        ← World, characters, theme
/[project]/scripting/bible/episode_arc.md         ← Beat schedule (60 episodes)
/[project]/scripting/bible/characters.md          ← Voice patterns for prose
```

**Reference files:**
```
/skills/treatment/SKILL.md                ← Treatment format rules
```

---

**For `develop` mode, ALSO load:**

**Core files:**
```
/projects/[project]/development/STATUS.md           ← Progress tracking (34-point)
/SCRIPTING_REQUIREMENTS.md                ← 34-point checklist
```

**Reference files:**
```
/templates/dev_templates/characters_template.md     ← Required format for characters.md
/appendix_c_emotion.md                    ← Anchor types, emotional architecture
```

**Existing dev docs (if present):**
```
/projects/[project]/development/characters.md
/projects/[project]/development/thematic_spine.md
/projects/[project]/development/structure_outline.md
/projects/[project]/development/relationship_map.md
/projects/[project]/development/plant_payoff_plan.md
/projects/[project]/development/series_bible.md
```

---

### Step 3: Report What Was Loaded

Output a confirmation block:

```
═══════════════════════════════════════════════════════════════
CONTEXT LOADED: [project] — [mode] mode
═══════════════════════════════════════════════════════════════

ENGINE:
  ✓ CONSTANTS.md (numeric values)
  ✓ format_v12/SKILL.md (V12 rules)
  ✓ [mode-specific reference files]

PROJECT:
  ✓ [list each project file that was successfully read]
  ✗ [list any files that were missing]

CURRENT POSITION: (generate mode only)
  Last completed: Batch [N] (Episode [M])
  Next batch: [N+1] (Episodes [start]-[end])

READY FOR: [mode description]
═══════════════════════════════════════════════════════════════
```

### Step 4: Warn on Missing Critical Files

**For generate mode, these are CRITICAL (blocks generation):**
- `treatment.md` — Cannot generate without this
- `characters.md` — Cannot maintain voice without this
- `ORCHESTRATION.md` — Cannot apply project rules without this

If missing, output:
```
⚠️  BLOCKED: Missing [file].
    → Run /treatment [project] to create treatment.md
    → Run /promote [project] to create bible/ files
```

**For treatment mode, these are CRITICAL:**
- `bible/episode_arc.md` — Cannot write treatment without beat schedule
- `bible/characters.md` — Cannot write prose without character voices

If missing, output:
```
⚠️  BLOCKED: Missing [file].
    → Run /promote [project] first to create bible/ structure
```

**For develop mode, these trigger recommendations:**
- `STATUS.md` missing → "Create STATUS.md to track 34-point progress"
- `characters.md` missing → "Characters are built FIRST in the checklist"

---

### Step 5: Write Context Loaded Flag (CRITICAL)

**For `generate` mode only**, write a flag file so the enforcement hook knows context was loaded.

Run this Bash command:
```bash
echo '{"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%S)'", "project": "[project]", "mode": "[mode]"}' > /[project]/_pipeline/state/.context_loaded
```

Replace `[project]` with the actual project name (e.g., `the-hike`).

**Why this matters:** The `enforce_context_load.py` hook blocks episode writes if this flag is missing or stale. This prevents blind generation after context compaction.

---

## Why This Matters

**Problem:** Context drift and blind generation produce poor results.

**Solution:** Explicit context loading ensures:
1. All required files are read into context
2. Current position is known before work begins
3. Missing prerequisites are caught early
4. Engine constants are always available

**Rule:** After seeing "CONTEXT LOADED" confirmation, proceed with work.

---

## Quick Reference

| Mode | Core Files | Reference Files |
|------|------------|-----------------|
| `generate` | treatment.md, characters.md, ORCHESTRATION.md, state.json | orchestration_process, appendix_a |
| `treatment` | episode_arc.md, series_bible.md, characters.md | treatment/SKILL.md |
| `develop` | STATUS.md, SCRIPTING_REQUIREMENTS.md | characters_template, appendix_c |

**All modes load:** CONSTANTS.md, format_v12/SKILL.md

---

## Batch Reload (During Generation)

Per CLAUDE.md, after each batch you must reload context to prevent drift:

```
MANDATORY RELOAD (prevents context drift):
  - Re-read treatment.md (next batch section)
  - Re-read characters.md (voice patterns)
  - Re-read format_v12/SKILL.md (constraints)
```

You can call `/load-context [project] generate` between batches, or manually re-read the specific files.
