Paper Slide Deck Generator
Transform academic papers and content into professional slide deck images with automatic figure extraction.
Usage
/paper-slide-deck path/to/paper.pdf
/paper-slide-deck path/to/paper.pdf --style academic-paper
/paper-slide-deck path/to/content.md --style sketch-notes
/paper-slide-deck path/to/content.md --audience executives
/paper-slide-deck path/to/content.md --lang zh
/paper-slide-deck path/to/content.md --slides 10
/paper-slide-deck path/to/content.md --outline-only
/paper-slide-deck # Then paste content
Setup (one-time)
The TypeScript scripts (merge-to-*, detect-figures, extract-figure,
apply-template) need Node dependencies. Install them once:
cd ${SKILL_DIR}/scripts && npm install
This installs canvas, pdfjs-dist, pptxgenjs, and pdf-lib (a package-lock.json
pins versions). If a script exits with missing Node dependency "<name>", run the
command above. The Python generator (generate-slides.py) auto-installs google-genai
on first run.
Also install PyMuPDF (pip install pymupdf) — it is the reliable fallback for
extracting figures from pages that embed bitmaps (X-rays, CAM heatmaps, photographs),
where the pdfjs + canvas path in extract-figure.ts fails with
Error: Image or Canvas expected. For medical-imaging papers this is the common case,
not the exception, so treat PyMuPDF as required, not optional.
Image generation & no-API-key path
Image generation needs either a GOOGLE_API_KEY/GEMINI_API_KEY (Gemini API) or the
Gemini Web skill. If no key and no web option is available, the skill still works in
a degraded mode — do not abort:
- Run with
--outline-only to produce the outline + prompts (no images).
- For a source PDF, extract real figures/tables with
detect-figures.ts +
extract-figure.ts + apply-template.ts (no API key needed — pure rendering).
- Merge whatever slides exist (
extract-sourced pages) into PPTX/PDF, and hand the
prompts/ back to the user to generate images later when a key is available.
Script Directory
Important: All scripts are located in the scripts/ subdirectory of this skill.
Agent Execution Instructions:
- Determine this SKILL.md file's directory path as
SKILL_DIR
- Script path =
${SKILL_DIR}/scripts/<script-name>.ts
- Replace all
${SKILL_DIR} in this document with the actual path
Script Reference:
| Script |
Purpose |
scripts/generate-slides.py |
Generate AI slides via Gemini API (Python) |
scripts/merge-to-pptx.ts |
Merge slides into PowerPoint |
scripts/merge-to-pdf.ts |
Merge slides into PDF |
scripts/detect-figures.ts |
Auto-detect figures/tables in PDF (heuristic; verify pages) |
scripts/extract-figure.ts |
Render a full PDF page to PNG (optional --crop; PyMuPDF fallback) |
scripts/apply-template.ts |
Apply figure container template |
Options
| Option |
Description |
--style <name> |
Visual style (see Style Gallery) |
--audience <type> |
Target audience: beginners, intermediate, experts, executives, general |
--lang <code> |
Output language (en, zh, ja, etc.) |
--slides <number> |
Target slide count |
--outline-only |
Generate outline only, skip image generation |
Style Gallery
| Style |
Description |
Best For |
academic-paper |
Clean professional, precise charts |
Academic-style visuals, technical handouts (for a faithful editable talk use scholar-slides) |
blueprint (Default) |
Technical schematics, grid texture |
Architecture, system design |
chalkboard |
Black chalkboard, colorful chalk |
Education, tutorials, classroom |
notion |
SaaS dashboard, card-based layouts |
Product demos, SaaS, B2B |
bold-editorial |
Magazine cover, bold typography, dark |
Product launches, keynotes |
corporate |
Navy/gold, structured layouts |
Investor decks, proposals |
dark-atmospheric |
Cinematic dark mode, glowing accents |
Entertainment, gaming |
editorial-infographic |
Magazine explainers, flat illustrations |
Tech explainers, research |
fantasy-animation |
Ghibli/Disney style, hand-drawn |
Educational, storytelling |
intuition-machine |
Technical briefing, bilingual labels |
Technical docs, academic |
minimal |
Ultra-clean, maximum whitespace |
Executive briefings, premium |
pixel-art |
Retro 8-bit, chunky pixels |
Gaming, developer talks |
scientific |
Academic diagrams, precise labeling |
Biology, chemistry, medical |
sketch-notes |
Hand-drawn, warm & friendly |
Educational, tutorials |
vector-illustration |
Flat vector, retro & cute |
Creative, children's content |
vintage |
Aged-paper, historical styling |
Historical, heritage, biography |
watercolor |
Hand-painted textures, natural warmth |
Lifestyle, wellness, travel |
Auto Style Selection
| Content Signals |
Selected Style |
| paper, thesis, defense, conference, ieee, acm, icml, neurips, cvpr, acl, aaai, iclr |
academic-paper |
| tutorial, learn, education, guide, intro, beginner |
sketch-notes |
| classroom, teaching, school, chalkboard, blackboard |
chalkboard |
| architecture, system, data, analysis, technical |
blueprint |
| creative, children, kids, cute, illustration |
vector-illustration |
| briefing, bilingual, infographic, concept |
intuition-machine |
| executive, minimal, clean, simple, elegant |
minimal |
| saas, product, dashboard, metrics, productivity |
notion |
| investor, quarterly, business, corporate, proposal |
corporate |
| launch, marketing, keynote, bold, impact, magazine |
bold-editorial |
| entertainment, music, gaming, creative, atmospheric |
dark-atmospheric |
| explainer, journalism, science communication |
editorial-infographic |
| story, fantasy, animation, magical, whimsical |
fantasy-animation |
| gaming, retro, pixel, developer, nostalgia |
pixel-art |
| biology, chemistry, medical, pathway, scientific |
scientific |
| history, heritage, vintage, expedition, historical |
vintage |
| lifestyle, wellness, travel, artistic, natural |
watercolor |
| Default |
blueprint |
Academic-signal caution: When the content matches academic-paper signals (paper/thesis/neurips/cvpr/icml/…), this skill still bakes text into an image, so equations, result tables, and exact numbers may be garbled. Extract real figures/tables from the source PDF (Source: extract) rather than letting the model redraw them, and if the deck needs faithful, editable formulas/data, tell the user to use scholar-slides instead.
Layout Gallery
Optional layout hints for individual slides. Specify in outline's // LAYOUT section.
Slide-Specific Layouts
| Layout |
Description |
Best For |
title-hero |
Large centered title + subtitle |
Cover slides, section breaks |
quote-callout |
Featured quote with attribution |
Testimonials, key insights |
key-stat |
Single large number as focal point |
Impact statistics, metrics |
split-screen |
Half image, half text |
Feature highlights, comparisons |
icon-grid |
Grid of icons with labels |
Features, capabilities, benefits |
two-columns |
Content in balanced columns |
Paired information, dual points |
three-columns |
Content in three columns |
Triple comparisons, categories |
image-caption |
Full-bleed image + text overlay |
Visual storytelling, emotional |
agenda |
Numbered list with highlights |
Session overview, roadmap |
bullet-list |
Structured bullet points |
Simple content, lists |
Infographic-Derived Layouts
| Layout |
Description |
Best For |
linear-progression |
Sequential flow left-to-right |
Timelines, step-by-step |
binary-comparison |
Side-by-side A vs B |
Before/after, pros-cons |
comparison-matrix |
Multi-factor grid |
Feature comparisons |
hierarchical-layers |
Pyramid or stacked levels |
Priority, importance |
hub-spoke |
Central node with radiating items |
Concept maps, ecosystems |
bento-grid |
Varied-size tiles |
Overview, summary |
funnel |
Narrowing stages |
Conversion, filtering |
dashboard |
Metrics with charts/numbers |
KPIs, data display |
venn-diagram |
Overlapping circles |
Relationships, intersections |
circular-flow |
Continuous cycle |
Recurring processes |
winding-roadmap |
Curved path with milestones |
Journey, timeline |
tree-branching |
Parent-child hierarchy |
Org charts, taxonomies |
iceberg |
Visible vs hidden layers |
Surface vs depth |
bridge |
Gap with connection |
Problem-solution |
Academic-Specific Layouts
| Layout |
Description |
Best For |
paper-title |
Title, authors, affiliations, venue |
Conference paper cover |
outline-agenda |
Numbered section list with highlights |
Talk structure overview |
methods-diagram |
Central architecture/pipeline diagram |
Methods, system design |
results-chart |
Chart area + data annotations |
Quantitative results |
equation-focus |
Centered equation + variable definitions |
Mathematical derivations |
qualitative-grid |
2x2 or 3x2 image comparison grid |
Visual results, ablations |
references-list |
Numbered citation list |
Key references slide |
contributions |
Numbered contribution points |
Contributions summary |
Usage: Add Layout: <name> in slide's // LAYOUT section to guide visual composition.
Design Philosophy
This deck is designed for reading and sharing, not live presentation:
- Each slide must be self-explanatory without verbal commentary
- Structure content for logical flow when scrolling
- Include all necessary context within each slide
- Optimize for social media sharing and offline reading
File Management
Output Directory
Each session creates an independent directory named by content slug:
slide-deck/{topic-slug}/
├── source-{slug}.{ext} # Source files (text, images, etc.)
├── outline.md
├── outline-{style}.md # Style variant outlines
├── prompts/
│ └── 01-slide-cover.md, 02-slide-{slug}.md, ...
├── 01-slide-cover.png, 02-slide-{slug}.png, ...
├── {topic-slug}.pptx
└── {topic-slug}.pdf
Slug Generation:
- Extract main topic from content (2-4 words, kebab-case)
- Example: "Introduction to Machine Learning" →
intro-machine-learning
Conflict Resolution
If slide-deck/{topic-slug}/ already exists:
- Append timestamp:
{topic-slug}-YYYYMMDD-HHMMSS
- Example:
intro-ml exists → intro-ml-20260118-143052
Source Files
Copy all sources with naming source-{slug}.{ext}:
source-article.md (main text content)
source-diagram.png (image from conversation)
source-data.xlsx (additional file)
Multiple sources supported: text, images, files from conversation.
Workflow
Step 1: Analyze Content
Save source content (if pasted, save as source.md)
Follow references/analysis-framework.md for deep content analysis
Determine style (use --style or auto-select from signals)
Detect languages (source vs. user preference)
Plan slide count (--slides or dynamic)
For academic papers (PDF with figures): Run automatic figure detection:
npx -y bun ${SKILL_DIR}/scripts/detect-figures.ts --pdf source-paper.pdf --output figures.json
This outputs a JSON file with all detected figures/tables, their page numbers, and captions.
Caption detection is heuristic — verify, especially the first-page teaser. The
line-anchored Figure N matcher reliably finds captions that sit on their own line
(single-column layouts), but misses figures whose caption is interleaved with body
text on a two-column first page — which is often the paper's most important
architecture/overview figure. After running detect-figures, cross-check the source's
Figure 1 explicitly: if the paper's text references a Figure N that is absent from
figures.json, add it manually via an // IMAGE_SOURCE block and extract it with the
PyMuPDF fallback. Do not assume figures.json is complete.
Step 2: Generate Outline Variants
- Generate 3 style variant outlines based on content analysis
- Follow
references/outline-template.md for structure
- Auto-populate IMAGE_SOURCE for academic papers:
- Read
figures.json from Step 1
- Map figures to slides using rules in
references/analysis-framework.md Section 8
- Automatically add
// IMAGE_SOURCE blocks to appropriate slides:
- Architecture/pipeline figures → Methods slides (
Source: extract)
- Results tables → Quantitative results slides (
Source: extract)
- Comparison images → Qualitative results slides (
Source: extract)
- Conceptual/simple diagrams → Leave for AI generation (
Source: generate or omit)
- Save as
outline-{style}.md for each variant
Step 3: User Confirmation
Single AskUserQuestion with all applicable options:
| Question |
When to Ask |
| Style variant |
Always (3 options + custom) |
| Language |
Only if source ≠ user language |
After selection:
- Copy selected
outline-{style}.md to outline.md
- Regenerate in different language if requested
- User may edit
outline.md for fine-tuning
If --outline-only, stop here.
Step 4: Generate Prompts
- Read
references/base-prompt.md
- Combine with style instructions from outline
- Add slide-specific content
- If
Layout: specified in outline, include layout guidance in prompt:
- Reference layout characteristics for image composition
- Example:
Layout: hub-spoke → "Central concept in middle with related items radiating outward"
- Save to
prompts/ directory
Step 5: Image Generation Method Selection
Before generating images, ask user to choose generation method:
Use AskUserQuestion with options:
| Option |
Label |
Description |
| 1 |
Gemini API (Recommended) |
Official Google API via Python. Requires GOOGLE_API_KEY env var. |
| 2 |
Gemini Web (Browser-based) |
⚠️ Uses reverse-engineered web API. No API key needed but may break. |
Based on selection:
Option 1: Gemini API (Python)
- Verify API key: Check
GOOGLE_API_KEY or GEMINI_API_KEY environment variable
- Run generation script:
python3 ${SKILL_DIR}/scripts/generate-slides.py <slide-deck-dir>
The default model is gemini-3-pro-image (Nano Banana Pro, GA). Override with
--model <id> if needed. The older gemini-3-pro-image-preview id is deprecated.
Script Features:
- Auto-installs
google-genai package if missing
- Reads prompt files as
*.md (or *.txt) from prompts/
- Errors out (non-zero) if no prompt files are found — no silent "nothing to do"
- Retry logic with exponential backoff (3 retries)
- Sets
response_modalities=["IMAGE"] so the model returns image parts
- Skips already-generated slides (> 10KB, any image extension)
- Writes each slide to the deck root (e.g.
01-slide-cover.png), the same
place extracted-figure slides land — so one merge step picks up both
- Saves with the real image extension (Gemini often returns JPEG even when
PNG is requested → saved as
.jpg, never a mislabeled .png)
- Supports custom model via
--model flag
Troubleshooting:
- If server disconnection errors occur, script auto-retries
- For persistent failures, re-run the script (it skips completed slides)
- Check API quota if many failures occur
Option 2: Gemini Web Skill
Consent Check: Read consent file at:
- Windows:
$APPDATA/baoyu-skills/gemini-web/consent.json
- macOS:
~/Library/Application Support/baoyu-skills/gemini-web/consent.json
- Linux:
~/.local/share/baoyu-skills/gemini-web/consent.json
If no consent or version mismatch, display disclaimer and ask:
⚠️ DISCLAIMER: This uses a reverse-engineered Gemini Web API (NOT official).
Risks: May break anytime, no support, possible account risk.
For each slide, run:
npx -y bun ${GEMINI_WEB_SKILL_DIR}/scripts/main.ts \
--promptfiles prompts/01-slide-cover.md \
--image 01-slide-cover.png \
--sessionId slides-{topic-slug}-{timestamp}
Where GEMINI_WEB_SKILL_DIR = path to baoyu-danger-gemini-web skill directory.
Proxy support: If user is in restricted network, prepend:
HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890
Step 5.5: Process IMAGE_SOURCE (Automatic Figure Extraction)
For academic presentations, IMAGE_SOURCE metadata was auto-populated in Step 2 based on figure detection from Step 1.
Automatic Execution:
Parse outline to identify slides with Source: extract
Create figures directory: mkdir -p figures
For each extract slide, automatically:
- Read the Figure number, Page, and Caption from metadata
- Run figure extraction script:
npx -y bun ${SKILL_DIR}/scripts/extract-figure.ts \
--pdf source-paper.pdf \
--page <page-number> \
--output figures/figure-<N>.png
Note: extract-figure.ts renders the entire page to a high-resolution
PNG — it does not auto-detect or crop a single figure's bounding box. On a
two-column page you will get both columns. To isolate one figure, either pass
--crop "x,y,width,height" (pixels in the rendered/scaled page) or open the
PNG, confirm it visually, and crop manually before applying the template.
- Run template application script:
npx -y bun ${SKILL_DIR}/scripts/apply-template.ts \
--figure figures/figure-<N>.png \
--title "<slide-headline>" \
--caption "Figure <N>: <caption-text>" \
--output <NN>-slide-<slug>.png
- Report: "Extracted: Figure N → slide NN"
For slides with Source: generate (or no IMAGE_SOURCE):
- Proceed to Step 6 for AI generation
Note: Source PDF must be saved as source-paper.pdf in output directory.
Troubleshooting:
- If figure detection missed a figure: manually add
// IMAGE_SOURCE block to outline
- If wrong figure mapped: edit the
Figure: and Page: values in outline
- If extraction fails: check PDF page number (1-indexed)
PyMuPDF Fallback for Page Extraction:
If extract-figure.ts fails with "Image or Canvas expected" error (common with complex PDFs), use PyMuPDF:
import fitz
doc = fitz.open("source-paper.pdf")
page = doc[page_num - 1] # 0-indexed
mat = fitz.Matrix(3, 3) # 3x scale for high resolution
pix = page.get_pixmap(matrix=mat)
pix.save(f"extracted/page-{page_num}.png")
Then apply template using apply-template.ts.
Step 6: Generate Images
- Use selected method from Step 5
- Skip slides already processed in Step 5.5 (those with
Source: extract)
- Generate session ID:
slides-{topic-slug}-{timestamp}
- Generate each remaining slide with same session ID
- Report progress: "Generated X/N"
- Auto-retry once on generation failure
Step 6.5: Proofread Generated Images (Content Integrity)
Text-to-image bakes text into pixels and will garble spelling, math symbols, and
numbers — this is the single biggest risk of this skill. Do not ship unchecked.
For every generated slide (especially any with equations, tables, key numbers,
or non-Latin text), use Read to open the PNG and visually check:
- Spelling / wording — headline and body text match the outline, no invented or
mangled words.
- Math & symbols — equations, subscripts, Greek letters, operators are correct
(or absent). Assume the model got them wrong until you confirm otherwise.
- Numbers & units — any figure that carries data matches the source exactly.
If garbling is found:
- Regenerate that slide with a corrected/simplified prompt (spell risky terms
phonetically, reduce text density, move exact numbers to a caption). Max 2 retries.
- If it still fails after 2 retries, flag the slide
[CHECK] in the Step 8 summary
and recommend one of:
- Replace with an extracted figure/table from the source PDF (
Source: extract), or
- Simplify the slide to remove the fragile text, or
- For a deck that genuinely needs faithful, editable formulas/data, switch to
scholar-slides.
Never silently deliver a slide with garbled math or data — always surface it.
Step 7: Merge to PPTX and PDF
npx -y bun ${SKILL_DIR}/scripts/merge-to-pptx.ts <slide-deck-dir>
npx -y bun ${SKILL_DIR}/scripts/merge-to-pdf.ts <slide-deck-dir>
Step 8: Output Summary
Slide Deck Complete!
Topic: [topic]
Style: [style name]
Location: [directory path]
Slides: N total
- 01-slide-cover.png ✓ Cover
- 02-slide-intro.png ✓ Content
- 04-slide-results.png ⚠ [CHECK] math/numbers — verify or use scholar-slides
- ...
- {NN}-slide-back-cover.png ✓ Back Cover
Outline: outline.md
PPTX: {topic-slug}.pptx
PDF: {topic-slug}.pdf
List any [CHECK]-flagged slides (from Step 6.5) explicitly so the user knows which
slides may contain garbled text/math/data and how to remediate them.
Slide Modification
See references/modification-guide.md for:
- Edit single slide workflow
- Add new slide (with renumbering)
- Delete slide (with renumbering)
- File naming conventions
Image Generation Dependencies
Gemini API (Option 1 - Recommended)
Requires:
GOOGLE_API_KEY or GEMINI_API_KEY environment variable
- Python 3.8+ with pip
google-genai package (auto-installed by script)
Model: gemini-3-pro-image (default; Nano Banana Pro, GA). The older
gemini-3-pro-image-preview id is deprecated — override with --model only if needed.
Gemini Web Skill (Option 2)
Requires:
baoyu-danger-gemini-web skill installed at .claude/skills/baoyu-danger-gemini-web
- Google Chrome browser with logged-in Google account
- User consent for reverse-engineered API disclaimer
PDF Figure Extraction
Requires (install via cd ${SKILL_DIR}/scripts && npm install):
- Primary:
pdfjs-dist npm package (use legacy build for Node.js)
canvas npm package for extract-figure.ts / apply-template.ts
- Fallback:
pymupdf Python package (more reliable for complex PDFs)
References
| File |
Content |
references/analysis-framework.md |
Deep content analysis for presentations |
references/outline-template.md |
Outline structure and STYLE_INSTRUCTIONS format |
references/modification-guide.md |
Edit, add, delete slide workflows |
references/content-rules.md |
Content and style guidelines |
references/base-prompt.md |
Base prompt for image generation |
references/figure-container-template.md |
Visual specs for extracted figure containers |
references/styles/<style>.md |
Full style specifications |
Notes
Image Generation
- Nano Banana Pro API: Recommended. Stable, reliable, requires API key
- Gemini Web: No API key needed, but uses reverse-engineered API with account risk
- Generation time: 10-30 seconds per slide
- Auto-retry once on generation failure
- Maintain style consistency via session ID
Content Guidelines
- Use stylized alternatives for sensitive public figures
- Both methods use the same underlying Gemini model for image generation
Extension Support
Custom styles and configurations via EXTEND.md.
Check paths (priority order):
.paper-skills/paper-slide-deck/EXTEND.md (project)
~/.paper-skills/paper-slide-deck/EXTEND.md (user)
If found, load before Step 1. Extension content overrides defaults.
1---2name: paper-slide-deck3description: Use when the user wants visually striking, shareable slide-deck IMAGES from any content — an article, blog post, topic, or paper — where look-and-feel matters more than editable precision (风格化幻灯/小红书配图/公众号配图/视觉化海报), optimized for reading and social sharing rather than live presentation. Offers 17 T2I aesthetic styles (watercolor, sketch-notes, pixel-art, editorial, chalkboard, etc.); each slide is an AI-generated image (Gemini/Nano Banana), so the look is distinctive but text/math/data are baked into the image (not editable). NOT for a faithful academic talk where equations, numbers, tables, and citations must stay exact, editable, and projector-ready (组会/答辩/thesis defense/conference/results-heavy talks) — for that use scholar-slides instead, since text-to-image will garble math and data.4---5
6# Paper Slide Deck Generator
7
8Transform academic papers and content into professional slide deck images with automatic figure extraction.
9
10## Usage
11
12```bash
13/paper-slide-deck path/to/paper.pdf
14/paper-slide-deck path/to/paper.pdf --style academic-paper
15/paper-slide-deck path/to/content.md --style sketch-notes
16/paper-slide-deck path/to/content.md --audience executives
17/paper-slide-deck path/to/content.md --lang zh
18/paper-slide-deck path/to/content.md --slides 10
19/paper-slide-deck path/to/content.md --outline-only
20/paper-slide-deck # Then paste content
21```
22
23## Setup (one-time)
24
25The TypeScript scripts (`merge-to-*`, `detect-figures`, `extract-figure`,
26`apply-template`) need Node dependencies. Install them once:
27
28```bash
29cd ${SKILL_DIR}/scripts && npm install
30```
31
32This installs `canvas`, `pdfjs-dist`, `pptxgenjs`, and `pdf-lib` (a `package-lock.json`
33pins versions). If a script exits with `missing Node dependency "<name>"`, run the
34command above. The Python generator (`generate-slides.py`) auto-installs `google-genai`
35on first run.
36
37**Also install PyMuPDF** (`pip install pymupdf`) — it is the reliable fallback for
38extracting figures from pages that embed bitmaps (X-rays, CAM heatmaps, photographs),
39where the `pdfjs` + `canvas` path in `extract-figure.ts` fails with
40`Error: Image or Canvas expected`. For medical-imaging papers this is the common case,
41not the exception, so treat PyMuPDF as required, not optional.
42
43### Image generation & no-API-key path
44
45Image generation needs either a `GOOGLE_API_KEY`/`GEMINI_API_KEY` (Gemini API) or the
46Gemini Web skill. **If no key and no web option is available, the skill still works in
47a degraded mode** — do not abort:
48
491. Run with `--outline-only` to produce the outline + prompts (no images).
502. For a source PDF, extract real figures/tables with `detect-figures.ts` +
51 `extract-figure.ts` + `apply-template.ts` (no API key needed — pure rendering).
523. Merge whatever slides exist (`extract`-sourced pages) into PPTX/PDF, and hand the
53 `prompts/` back to the user to generate images later when a key is available.
54
55## Script Directory
56
57**Important**: All scripts are located in the `scripts/` subdirectory of this skill.
58
59**Agent Execution Instructions**:
601. Determine this SKILL.md file's directory path as `SKILL_DIR`
612. Script path = `${SKILL_DIR}/scripts/<script-name>.ts`
623. Replace all `${SKILL_DIR}` in this document with the actual path
63
64**Script Reference**:
65| Script | Purpose |
66|--------|---------|
67| `scripts/generate-slides.py` | Generate AI slides via Gemini API (Python) |
68| `scripts/merge-to-pptx.ts` | Merge slides into PowerPoint |
69| `scripts/merge-to-pdf.ts` | Merge slides into PDF |
70| `scripts/detect-figures.ts` | Auto-detect figures/tables in PDF (heuristic; verify pages) |
71| `scripts/extract-figure.ts` | Render a full PDF page to PNG (optional `--crop`; PyMuPDF fallback) |
72| `scripts/apply-template.ts` | Apply figure container template |
73
74## Options
75
76| Option | Description |
77|--------|-------------|
78| `--style <name>` | Visual style (see Style Gallery) |
79| `--audience <type>` | Target audience: beginners, intermediate, experts, executives, general |
80| `--lang <code>` | Output language (en, zh, ja, etc.) |
81| `--slides <number>` | Target slide count |
82| `--outline-only` | Generate outline only, skip image generation |
83
84## Style Gallery
85
86| Style | Description | Best For |
87|-------|-------------|----------|
88| `academic-paper` | Clean professional, precise charts | Academic-style visuals, technical handouts (for a faithful *editable* talk use scholar-slides) |
89| `blueprint` (Default) | Technical schematics, grid texture | Architecture, system design |
90| `chalkboard` | Black chalkboard, colorful chalk | Education, tutorials, classroom |
91| `notion` | SaaS dashboard, card-based layouts | Product demos, SaaS, B2B |
92| `bold-editorial` | Magazine cover, bold typography, dark | Product launches, keynotes |
93| `corporate` | Navy/gold, structured layouts | Investor decks, proposals |
94| `dark-atmospheric` | Cinematic dark mode, glowing accents | Entertainment, gaming |
95| `editorial-infographic` | Magazine explainers, flat illustrations | Tech explainers, research |
96| `fantasy-animation` | Ghibli/Disney style, hand-drawn | Educational, storytelling |
97| `intuition-machine` | Technical briefing, bilingual labels | Technical docs, academic |
98| `minimal` | Ultra-clean, maximum whitespace | Executive briefings, premium |
99| `pixel-art` | Retro 8-bit, chunky pixels | Gaming, developer talks |
100| `scientific` | Academic diagrams, precise labeling | Biology, chemistry, medical |
101| `sketch-notes` | Hand-drawn, warm & friendly | Educational, tutorials |
102| `vector-illustration` | Flat vector, retro & cute | Creative, children's content |
103| `vintage` | Aged-paper, historical styling | Historical, heritage, biography |
104| `watercolor` | Hand-painted textures, natural warmth | Lifestyle, wellness, travel |
105
106## Auto Style Selection
107
108| Content Signals | Selected Style |
109|-----------------|----------------|
110| paper, thesis, defense, conference, ieee, acm, icml, neurips, cvpr, acl, aaai, iclr | `academic-paper` |
111| tutorial, learn, education, guide, intro, beginner | `sketch-notes` |
112| classroom, teaching, school, chalkboard, blackboard | `chalkboard` |
113| architecture, system, data, analysis, technical | `blueprint` |
114| creative, children, kids, cute, illustration | `vector-illustration` |
115| briefing, bilingual, infographic, concept | `intuition-machine` |
116| executive, minimal, clean, simple, elegant | `minimal` |
117| saas, product, dashboard, metrics, productivity | `notion` |
118| investor, quarterly, business, corporate, proposal | `corporate` |
119| launch, marketing, keynote, bold, impact, magazine | `bold-editorial` |
120| entertainment, music, gaming, creative, atmospheric | `dark-atmospheric` |
121| explainer, journalism, science communication | `editorial-infographic` |
122| story, fantasy, animation, magical, whimsical | `fantasy-animation` |
123| gaming, retro, pixel, developer, nostalgia | `pixel-art` |
124| biology, chemistry, medical, pathway, scientific | `scientific` |
125| history, heritage, vintage, expedition, historical | `vintage` |
126| lifestyle, wellness, travel, artistic, natural | `watercolor` |
127| Default | `blueprint` |
128
129> **Academic-signal caution**: When the content matches `academic-paper` signals (paper/thesis/neurips/cvpr/icml/…), this skill still bakes text into an image, so **equations, result tables, and exact numbers may be garbled**. Extract real figures/tables from the source PDF (`Source: extract`) rather than letting the model redraw them, and if the deck needs faithful, editable formulas/data, tell the user to use **scholar-slides** instead.
130
131## Layout Gallery
132
133Optional layout hints for individual slides. Specify in outline's `// LAYOUT` section.
134
135### Slide-Specific Layouts
136
137| Layout | Description | Best For |
138|--------|-------------|----------|
139| `title-hero` | Large centered title + subtitle | Cover slides, section breaks |
140| `quote-callout` | Featured quote with attribution | Testimonials, key insights |
141| `key-stat` | Single large number as focal point | Impact statistics, metrics |
142| `split-screen` | Half image, half text | Feature highlights, comparisons |
143| `icon-grid` | Grid of icons with labels | Features, capabilities, benefits |
144| `two-columns` | Content in balanced columns | Paired information, dual points |
145| `three-columns` | Content in three columns | Triple comparisons, categories |
146| `image-caption` | Full-bleed image + text overlay | Visual storytelling, emotional |
147| `agenda` | Numbered list with highlights | Session overview, roadmap |
148| `bullet-list` | Structured bullet points | Simple content, lists |
149
150### Infographic-Derived Layouts
151
152| Layout | Description | Best For |
153|--------|-------------|----------|
154| `linear-progression` | Sequential flow left-to-right | Timelines, step-by-step |
155| `binary-comparison` | Side-by-side A vs B | Before/after, pros-cons |
156| `comparison-matrix` | Multi-factor grid | Feature comparisons |
157| `hierarchical-layers` | Pyramid or stacked levels | Priority, importance |
158| `hub-spoke` | Central node with radiating items | Concept maps, ecosystems |
159| `bento-grid` | Varied-size tiles | Overview, summary |
160| `funnel` | Narrowing stages | Conversion, filtering |
161| `dashboard` | Metrics with charts/numbers | KPIs, data display |
162| `venn-diagram` | Overlapping circles | Relationships, intersections |
163| `circular-flow` | Continuous cycle | Recurring processes |
164| `winding-roadmap` | Curved path with milestones | Journey, timeline |
165| `tree-branching` | Parent-child hierarchy | Org charts, taxonomies |
166| `iceberg` | Visible vs hidden layers | Surface vs depth |
167| `bridge` | Gap with connection | Problem-solution |
168
169### Academic-Specific Layouts
170
171| Layout | Description | Best For |
172|--------|-------------|----------|
173| `paper-title` | Title, authors, affiliations, venue | Conference paper cover |
174| `outline-agenda` | Numbered section list with highlights | Talk structure overview |
175| `methods-diagram` | Central architecture/pipeline diagram | Methods, system design |
176| `results-chart` | Chart area + data annotations | Quantitative results |
177| `equation-focus` | Centered equation + variable definitions | Mathematical derivations |
178| `qualitative-grid` | 2x2 or 3x2 image comparison grid | Visual results, ablations |
179| `references-list` | Numbered citation list | Key references slide |
180| `contributions` | Numbered contribution points | Contributions summary |
181
182**Usage**: Add `Layout: <name>` in slide's `// LAYOUT` section to guide visual composition.
183
184## Design Philosophy
185
186This deck is designed for **reading and sharing**, not live presentation:
187- Each slide must be **self-explanatory** without verbal commentary
188- Structure content for **logical flow** when scrolling
189- Include **all necessary context** within each slide
190- Optimize for **social media sharing** and offline reading
191
192## File Management
193
194### Output Directory
195
196Each session creates an independent directory named by content slug:
197
198```
199slide-deck/{topic-slug}/
200├── source-{slug}.{ext} # Source files (text, images, etc.)
201├── outline.md
202├── outline-{style}.md # Style variant outlines
203├── prompts/
204│ └── 01-slide-cover.md, 02-slide-{slug}.md, ...
205├── 01-slide-cover.png, 02-slide-{slug}.png, ...
206├── {topic-slug}.pptx
207└── {topic-slug}.pdf
208```
209
210**Slug Generation**:
2111. Extract main topic from content (2-4 words, kebab-case)
2122. Example: "Introduction to Machine Learning" → `intro-machine-learning`
213
214### Conflict Resolution
215
216If `slide-deck/{topic-slug}/` already exists:
217- Append timestamp: `{topic-slug}-YYYYMMDD-HHMMSS`
218- Example: `intro-ml` exists → `intro-ml-20260118-143052`
219
220### Source Files
221
222Copy all sources with naming `source-{slug}.{ext}`:
223- `source-article.md` (main text content)
224- `source-diagram.png` (image from conversation)
225- `source-data.xlsx` (additional file)
226
227Multiple sources supported: text, images, files from conversation.
228
229## Workflow
230
231### Step 1: Analyze Content
232
2331. Save source content (if pasted, save as `source.md`)
2342. Follow `references/analysis-framework.md` for deep content analysis
2353. Determine style (use `--style` or auto-select from signals)
2364. Detect languages (source vs. user preference)
2375. Plan slide count (`--slides` or dynamic)
2386. **For academic papers (PDF with figures)**: Run automatic figure detection:
239 ```bash
240 npx -y bun ${SKILL_DIR}/scripts/detect-figures.ts --pdf source-paper.pdf --output figures.json
241 ```
242 This outputs a JSON file with all detected figures/tables, their page numbers, and captions.
243
244 **Caption detection is heuristic — verify, especially the first-page teaser.** The
245 line-anchored `Figure N` matcher reliably finds captions that sit on their own line
246 (single-column layouts), but **misses figures whose caption is interleaved with body
247 text on a two-column first page** — which is often the paper's most important
248 architecture/overview figure. After running detect-figures, cross-check the source's
249 `Figure 1` explicitly: if the paper's text references a `Figure N` that is absent from
250 `figures.json`, add it manually via an `// IMAGE_SOURCE` block and extract it with the
251 PyMuPDF fallback. Do not assume `figures.json` is complete.
252
253### Step 2: Generate Outline Variants
254
2551. Generate 3 style variant outlines based on content analysis
2562. Follow `references/outline-template.md` for structure
2573. **Auto-populate IMAGE_SOURCE** for academic papers:
258 - Read `figures.json` from Step 1
259 - Map figures to slides using rules in `references/analysis-framework.md` Section 8
260 - Automatically add `// IMAGE_SOURCE` blocks to appropriate slides:
261 - Architecture/pipeline figures → Methods slides (`Source: extract`)
262 - Results tables → Quantitative results slides (`Source: extract`)
263 - Comparison images → Qualitative results slides (`Source: extract`)
264 - Conceptual/simple diagrams → Leave for AI generation (`Source: generate` or omit)
2654. Save as `outline-{style}.md` for each variant
266
267### Step 3: User Confirmation
268
269**Single AskUserQuestion with all applicable options:**
270
271| Question | When to Ask |
272|----------|-------------|
273| Style variant | Always (3 options + custom) |
274| Language | Only if source ≠ user language |
275
276After selection:
277- Copy selected `outline-{style}.md` to `outline.md`
278- Regenerate in different language if requested
279- User may edit `outline.md` for fine-tuning
280
281If `--outline-only`, stop here.
282
283### Step 4: Generate Prompts
284
2851. Read `references/base-prompt.md`
2862. Combine with style instructions from outline
2873. Add slide-specific content
2884. If `Layout:` specified in outline, include layout guidance in prompt:
289 - Reference layout characteristics for image composition
290 - Example: `Layout: hub-spoke` → "Central concept in middle with related items radiating outward"
2915. Save to `prompts/` directory
292
293### Step 5: Image Generation Method Selection
294
295**Before generating images**, ask user to choose generation method:
296
297**Use AskUserQuestion** with options:
298
299| Option | Label | Description |
300|--------|-------|-------------|
301| 1 | **Gemini API (Recommended)** | Official Google API via Python. Requires GOOGLE_API_KEY env var. |
302| 2 | **Gemini Web (Browser-based)** | ⚠️ Uses reverse-engineered web API. No API key needed but may break. |
303
304**Based on selection:**
305
306#### Option 1: Gemini API (Python)
307
3081. **Verify API key**: Check `GOOGLE_API_KEY` or `GEMINI_API_KEY` environment variable
3092. **Run generation script**:
310 ```bash
311 python3 ${SKILL_DIR}/scripts/generate-slides.py <slide-deck-dir>
312 ```
313 The default model is `gemini-3-pro-image` (Nano Banana Pro, GA). Override with
314 `--model <id>` if needed. The older `gemini-3-pro-image-preview` id is deprecated.
315
316**Script Features**:
317- Auto-installs `google-genai` package if missing
318- Reads prompt files as `*.md` (or `*.txt`) from `prompts/`
319- **Errors out (non-zero) if no prompt files are found** — no silent "nothing to do"
320- Retry logic with exponential backoff (3 retries)
321- Sets `response_modalities=["IMAGE"]` so the model returns image parts
322- Skips already-generated slides (> 10KB, any image extension)
323- Writes each slide to the **deck root** (e.g. `01-slide-cover.png`), the same
324 place extracted-figure slides land — so one merge step picks up both
325- Saves with the **real** image extension (Gemini often returns JPEG even when
326 PNG is requested → saved as `.jpg`, never a mislabeled `.png`)
327- Supports custom model via `--model` flag
328
329**Troubleshooting**:
330- If server disconnection errors occur, script auto-retries
331- For persistent failures, re-run the script (it skips completed slides)
332- Check API quota if many failures occur
333
334#### Option 2: Gemini Web Skill
335
3361. **Consent Check**: Read consent file at:
337 - Windows: `$APPDATA/baoyu-skills/gemini-web/consent.json`
338 - macOS: `~/Library/Application Support/baoyu-skills/gemini-web/consent.json`
339 - Linux: `~/.local/share/baoyu-skills/gemini-web/consent.json`
340
3412. **If no consent or version mismatch**, display disclaimer and ask:
342 ```
343 ⚠️ DISCLAIMER: This uses a reverse-engineered Gemini Web API (NOT official).
344 Risks: May break anytime, no support, possible account risk.
345 ```
346
3473. **For each slide**, run:
348 ```bash
349 npx -y bun ${GEMINI_WEB_SKILL_DIR}/scripts/main.ts \
350 --promptfiles prompts/01-slide-cover.md \
351 --image 01-slide-cover.png \
352 --sessionId slides-{topic-slug}-{timestamp}
353 ```
354
355 Where `GEMINI_WEB_SKILL_DIR` = path to `baoyu-danger-gemini-web` skill directory.
356
3574. **Proxy support**: If user is in restricted network, prepend:
358 ```bash
359 HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890
360 ```
361
362### Step 5.5: Process IMAGE_SOURCE (Automatic Figure Extraction)
363
364For academic presentations, IMAGE_SOURCE metadata was auto-populated in Step 2 based on figure detection from Step 1.
365
366**Automatic Execution**:
367
3681. **Parse outline** to identify slides with `Source: extract`
3692. **Create figures directory**: `mkdir -p figures`
3703. **For each extract slide**, automatically:
371 - Read the Figure number, Page, and Caption from metadata
372 - Run figure extraction script:
373 ```bash
374 npx -y bun ${SKILL_DIR}/scripts/extract-figure.ts \
375 --pdf source-paper.pdf \
376 --page <page-number> \
377 --output figures/figure-<N>.png
378 ```
379 **Note**: `extract-figure.ts` renders the **entire page** to a high-resolution
380 PNG — it does **not** auto-detect or crop a single figure's bounding box. On a
381 two-column page you will get both columns. To isolate one figure, either pass
382 `--crop "x,y,width,height"` (pixels in the rendered/scaled page) or open the
383 PNG, confirm it visually, and crop manually before applying the template.
384 - Run template application script:
385 ```bash
386 npx -y bun ${SKILL_DIR}/scripts/apply-template.ts \
387 --figure figures/figure-<N>.png \
388 --title "<slide-headline>" \
389 --caption "Figure <N>: <caption-text>" \
390 --output <NN>-slide-<slug>.png
391 ```
392 - Report: "Extracted: Figure N → slide NN"
393
3944. **For slides with `Source: generate`** (or no IMAGE_SOURCE):
395 - Proceed to Step 6 for AI generation
396
397**Note**: Source PDF must be saved as `source-paper.pdf` in output directory.
398
399**Troubleshooting**:
400- If figure detection missed a figure: manually add `// IMAGE_SOURCE` block to outline
401- If wrong figure mapped: edit the `Figure:` and `Page:` values in outline
402- If extraction fails: check PDF page number (1-indexed)
403
404**PyMuPDF Fallback for Page Extraction**:
405If `extract-figure.ts` fails with "Image or Canvas expected" error (common with complex PDFs), use PyMuPDF:
406```python
407import fitz
408doc = fitz.open("source-paper.pdf")
409page = doc[page_num - 1] # 0-indexed
410mat = fitz.Matrix(3, 3) # 3x scale for high resolution
411pix = page.get_pixmap(matrix=mat)
412pix.save(f"extracted/page-{page_num}.png")
413```
414Then apply template using `apply-template.ts`.
415
416### Step 6: Generate Images
417
4181. Use selected method from Step 5
4192. **Skip slides already processed in Step 5.5** (those with `Source: extract`)
4203. Generate session ID: `slides-{topic-slug}-{timestamp}`
4214. Generate each remaining slide with same session ID
4225. Report progress: "Generated X/N"
4236. Auto-retry once on generation failure
424
425### Step 6.5: Proofread Generated Images (Content Integrity)
426
427Text-to-image **bakes text into pixels and will garble spelling, math symbols, and
428numbers** — this is the single biggest risk of this skill. Do not ship unchecked.
429
430**For every generated slide** (especially any with equations, tables, key numbers,
431or non-Latin text), use `Read` to open the PNG and visually check:
432
4331. **Spelling / wording** — headline and body text match the outline, no invented or
434 mangled words.
4352. **Math & symbols** — equations, subscripts, Greek letters, operators are correct
436 (or absent). Assume the model got them wrong until you confirm otherwise.
4373. **Numbers & units** — any figure that carries data matches the source exactly.
438
439**If garbling is found:**
440- Regenerate that slide with a corrected/simplified prompt (spell risky terms
441 phonetically, reduce text density, move exact numbers to a caption). **Max 2 retries.**
442- If it still fails after 2 retries, **flag the slide `[CHECK]`** in the Step 8 summary
443 and recommend one of:
444 - Replace with an **extracted** figure/table from the source PDF (`Source: extract`), or
445 - **Simplify** the slide to remove the fragile text, or
446 - For a deck that genuinely needs faithful, editable formulas/data, switch to
447 **scholar-slides**.
448
449Never silently deliver a slide with garbled math or data — always surface it.
450
451### Step 7: Merge to PPTX and PDF
452
453```bash
454npx -y bun ${SKILL_DIR}/scripts/merge-to-pptx.ts <slide-deck-dir>
455npx -y bun ${SKILL_DIR}/scripts/merge-to-pdf.ts <slide-deck-dir>
456```
457
458### Step 8: Output Summary
459
460```
461Slide Deck Complete!
462
463Topic: [topic]
464Style: [style name]
465Location: [directory path]
466Slides: N total
467
468- 01-slide-cover.png ✓ Cover
469- 02-slide-intro.png ✓ Content
470- 04-slide-results.png ⚠ [CHECK] math/numbers — verify or use scholar-slides
471- ...
472- {NN}-slide-back-cover.png ✓ Back Cover
473
474Outline: outline.md
475PPTX: {topic-slug}.pptx
476PDF: {topic-slug}.pdf
477```
478
479List any `[CHECK]`-flagged slides (from Step 6.5) explicitly so the user knows which
480slides may contain garbled text/math/data and how to remediate them.
481
482## Slide Modification
483
484See `references/modification-guide.md` for:
485- Edit single slide workflow
486- Add new slide (with renumbering)
487- Delete slide (with renumbering)
488- File naming conventions
489
490## Image Generation Dependencies
491
492### Gemini API (Option 1 - Recommended)
493
494Requires:
495- `GOOGLE_API_KEY` or `GEMINI_API_KEY` environment variable
496- Python 3.8+ with pip
497- `google-genai` package (auto-installed by script)
498
499Model: `gemini-3-pro-image` (default; Nano Banana Pro, GA). The older
500`gemini-3-pro-image-preview` id is deprecated — override with `--model` only if needed.
501
502### Gemini Web Skill (Option 2)
503
504Requires:
505- `baoyu-danger-gemini-web` skill installed at `.claude/skills/baoyu-danger-gemini-web`
506- Google Chrome browser with logged-in Google account
507- User consent for reverse-engineered API disclaimer
508
509### PDF Figure Extraction
510
511Requires (install via `cd ${SKILL_DIR}/scripts && npm install`):
512- **Primary**: `pdfjs-dist` npm package (use legacy build for Node.js)
513- `canvas` npm package for extract-figure.ts / apply-template.ts
514- **Fallback**: `pymupdf` Python package (more reliable for complex PDFs)
515
516## References
517
518| File | Content |
519|------|---------|
520| `references/analysis-framework.md` | Deep content analysis for presentations |
521| `references/outline-template.md` | Outline structure and STYLE_INSTRUCTIONS format |
522| `references/modification-guide.md` | Edit, add, delete slide workflows |
523| `references/content-rules.md` | Content and style guidelines |
524| `references/base-prompt.md` | Base prompt for image generation |
525| `references/figure-container-template.md` | Visual specs for extracted figure containers |
526| `references/styles/<style>.md` | Full style specifications |
527
528## Notes
529
530### Image Generation
531
532- **Nano Banana Pro API**: Recommended. Stable, reliable, requires API key
533- **Gemini Web**: No API key needed, but uses reverse-engineered API with account risk
534- Generation time: 10-30 seconds per slide
535- Auto-retry once on generation failure
536- Maintain style consistency via session ID
537
538### Content Guidelines
539
540- Use stylized alternatives for sensitive public figures
541- Both methods use the same underlying Gemini model for image generation
542
543## Extension Support
544
545Custom styles and configurations via EXTEND.md.
546
547**Check paths** (priority order):
5481. `.paper-skills/paper-slide-deck/EXTEND.md` (project)
5492. `~/.paper-skills/paper-slide-deck/EXTEND.md` (user)
550
551If found, load before Step 1. Extension content overrides defaults.