Generate lectures iteratively using Ralph-style architecture with closed feedback loops, per-slide validation, and flexible research sources.
Generate high-quality medical education lectures using an iterative, segment-by-segment approach with continuous validation against source materials.
┌─────────────────────────────────────────────────────────────┐
│ PHASE 1: PLANNING │
│ Parse outline → Generate slide segments → Create PRD │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ PHASE 2: ITERATIVE EXECUTION (per-slide loop) │
│ For each slide: │
│ Research → Generate → Validate → (Retry or Complete) │
└─────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────┐
│ PHASE 3: ASSEMBLY │
│ Merge slides → Coherence pass → Script → References │
└─────────────────────────────────────────────────────────────┘
Use this skill when:
/lecture-gen-iterative --outline course_outline.md --lecture 3
# Phase 1: Plan the lecture
/lecture-gen-plan --outline course_outline.md --lecture 3
# Phase 2: Execute generation (can resume)
/lecture-gen-execute
# Phase 3: Assemble final output
/lecture-gen-assemble
A markdown file with this structure:
# Course Title
## Lecture 1: Introduction to Longevity Medicine
### Learning Objectives
- Understand the hallmarks of aging
- Define key biomarkers
### Section 1: Hallmarks of Aging
- Genomic instability
- Telomere attrition
### Section 2: Clinical Biomarkers
- NAD+ levels
- Inflammatory markers
## Lecture 2: Mitochondrial Dynamics
...
Specify how research is conducted for each slide:
| Mode | Description |
|---|---|
hybrid (default) | Use Perplexity + KB + direct files |
perplexity | Web research only |
kb | Knowledge base only |
files | Direct file access only |
/lecture-gen-iterative --research-mode hybrid
Control validation threshold:
/lecture-gen-iterative --max-retries 3 # Default: 2
All state is persisted in .lecture-gen/:
.lecture-gen/
├── prd.json # Segment definitions + status
├── progress.json # Iteration history (JSON)
├── progress.txt # Human-readable progress log
└── materials_index.json # Source material index
If generation is interrupted, simply run:
/lecture-gen-execute
This will:
.lecture-gen/{
"id": "lecture-3-mitochondrial-dynamics",
"title": "Mitochondrial Dynamics in Disease",
"module": "Systems Cardiology",
"duration": 21,
"slides": [
{
"id": "slide-1",
"title": "Learning Objectives",
"content": [
{"type": "bullets", "items": ["..."]},
{"type": "keyTakeaway", "message": "..."}
]
}
],
"keyTakeaways": ["..."],
"references": [...]
}
Plain text optimized for TTS (ElevenLabs):
JSON array with PubMed citations and relevance notes.
Each slide is validated against two criteria types:
/lecture-gen-iterative \
--outline /path/to/course_outline.md \
--lecture 5 \
--dossier /path/to/research_dossier.md \
--materials /path/to/pdfs/
/lecture-gen-execute
from lib.lecture_gen_iterative import StateManager
state = StateManager()
state.reset_segment("SEG-003") # Reset slide 3
state = StateManager()
summary = state.get_state_summary()
print(f"Completed: {summary['segments']['completed']}/{summary['segments']['total']}")
.lecture-gen/progress.txt for failure reasonsfrom lib.lecture_gen_iterative import StateManager
state = StateManager()
state.reset_segment("SEG-003")
Configure longer timeouts in LectureConfig:
config = LectureConfig(
research_model="sonar-reasoning-pro", # Faster than deep-research
)
Check that your outline follows the expected markdown structure. The parser expects:
## Lecture N: Title for lecture headers### Section Name for section headers- Item for bullet pointsfrom lib.lecture_gen_iterative import StateManager
state = StateManager(output_dir=".lecture-gen")
# Load/save PRD
prd = state.load_prd()
state.save_prd(prd)
# Segment operations
segment = state.get_segment("SEG-001")
state.mark_segment_completed("SEG-001")
state.reset_segment("SEG-001")
# Progress tracking
state.log_iteration(segment, status="PASSED", ...)
state.add_pattern("Clinician prefers mechanism-first explanations")
from lib.lecture_gen_iterative import create_prd_from_outline, StateManager
state = StateManager()
prd = await create_prd_from_outline(
state_manager=state,
outline_text=outline_content,
target_lecture=3,
config=LectureConfig(research_mode=ResearchMode.HYBRID),
)
from lib.lecture_gen_iterative import execute_all_segments, StateManager
state = StateManager()
results = await execute_all_segments(state)
print(f"Completed: {results['summary']['segments_completed']}")
from lib.lecture_gen_iterative import assemble_lecture, StateManager
state = StateManager()
output = await assemble_lecture(
state,
run_coherence_pass=True,
generate_script=True,
find_refs=True,
)
print(f"Lecture saved to: {output['files']['lecture']}")
| Feature | VectorShift Pipeline | Iterative Generator |
|---|---|---|
| Research | Single global pass | Per-slide targeted |
| Validation | None | Dual validation |
| Retry mechanism | None | Up to 2 retries |
| State persistence | None | Full state files |
| Source cross-reference | None | Explicit validation |
| Resumable | No | Yes |