---
name: deckcraft
description: >
  AI PPT creation skill with structured 5-stage generation, machine-readable QA gates,
  checkpoint recovery, and experience accumulation. 20 layout methods, native charts,
  visual QA pipeline, and automated gate checks.
---

# DeckCraft v5.1.0 — Release Notes
> **Released**: 2026-05-19 · **Status**: STABLE

### Changelog

#### v5.1.0 — Native Charts + Visual QA (2026-05-19)
- **Charts fully native**: bar/pie/line/gauge use python-pptx native chart API — all charts are double-click editable in PowerPoint
- **Visual QA pipeline**: soffice → PDF → PNG → image analysis before delivery
- **CJK font fix**: Microsoft YaHei → Noto Sans CJK SC (Linux-native)
- **Section divider layout**: redesigned to eliminate text overlap
- **Stat cards contrast**: auto-detect dark/light card background, use contrasting label color
- **generate_ppt.py**: full coverage of all 23 layout types
- **gate_check_content.py**: supported types expanded to 25

#### v5.0.1 → prior
- See git history

---

# DeckCraft v5 — Harness Engineering

> **Version**: 5.1.0 · **Engine**: DeckEngine (python-pptx native charts) + ChartEngine (native)
>
> **Required tools**: Read, Write, Bash
> **Requires**: `pip install python-pptx lxml Pillow`
> **Render QA**: LibreOffice Impress (soffice --headless) + poppler-utils (pdftoppm)

---

## Anti-Patterns (Read Before Every Generation)

### Anti-Pattern 1: Declaring "Gate Passed" Verbally

**Wrong**: "QA found 5 errors but all are minor, gate passed."
**Correct**: Run `gate_check.py`, read the JSON, only `"passed": true` means pass.

### Anti-Pattern 2: "I Checked In My Head"

Format errors in content JSON are invisible to mental review.
**Correct**: Run `gate_check_content.py`, read the JSON output.

### Anti-Pattern 3: Skipping the Process for "Simple" Decks

Even simple decks can have overflow, font issues, or broken layouts.
**Correct**: Use Fast Track (see below), but **never skip the QA gate**.

---

## HARD RULES

1. **Every generation must follow the 5-stage flow**
2. **Gates must be machine-readable** — run the script, read the JSON
3. **Experience accumulation is recommended** — note pattern-level fixes for future improvement
4. **All positioning values must use `int()` wrapping** for python-pptx
5. **Clear paragraphs before adding runs** — never assume `p.runs[0]` exists

---

## 5-Stage Generation Flow

```
S1 Brief → S2 Structure → S3 Content → S4 Render+QA → S5 Deliver
                          ⭐ gate        ⭐⭐ gate
```

### Stage 1: Brief

Collect: audience, goal, duration, key messages, style preference.
**Output**: `<project>/brief.md`

### Stage 2: Structure

Assign page types, write key points (full insight sentences).
**Output**: `<project>/outline.json`

### Stage 3: Content

Fill copy, numbers, chart data. Respect char budgets in `designs/layout_matrix.yaml`.
**Output**: `<project>/content.json`

**⭐ Gate S3**:

```bash
python3 scripts/gate_check_content.py <project>/content.json <project>
```

Read `gate_content.json` — only `"passed": true` allows proceeding.

### Stage 4: Render + QA

Generate PPTX from content.json, then run QA.

```bash
python3 scripts/gate_check.py <pptx_path> <project>
```

Read `gate_result.json` — only `"passed": true` allows proceeding.

**Visual QA (render preview)**:

```bash
# Render PPT → PDF → PNG for visual inspection
soffice --headless --convert-to pdf <pptx_path> --outdir <project>/
pdftoppm -png -r 200 <pdf_path> <project>/preview/slide
```

Inspect the PNG images to verify layout, fonts, colors, and chart rendering.
Fix any visual issues found, regenerate, and re-run gate.

### Stage 5: Deliver + Self-Refinement

Deliver the PPTX.

---

## Fast Track (Simple Requests)

When **all** conditions are met, skip S2/S3 gates:
- Total pages ≤ 5
- No data charts
- User says "quick" / "fast" / "简单"

**Still required**: S1 + S4 QA gate + S5 delivery.

---

## Checkpoint Recovery

When resuming a deck project, check which files exist:

- No `brief.md` → Stage 1
- No `outline.json` → Stage 2
- No `content.json` → Stage 3
- No `gate_content.json` → Stage 3-gate
- No `.pptx` → Stage 4
- No `gate_result.json` → Stage 4-gate
- All present → Stage 5

Resume from the identified stage. Do not restart from S1.

---

## DeckEngine API

```python
import sys, os
sys.path.insert(0, '<skill-path>')
from engine import DeckEngine

eng = DeckEngine(theme_name="business")  # 10 themes
eng.cover(title="Title", subtitle="Sub", author="Author", date="2026")
eng.toc(items=[("1", "Chapter", "Description")])
eng.section_divider("Section Title", section_number=1)
eng.content(title="Slide", bullets=["Point 1", "Point 2"], key_point="Insight")
eng.content_with_icon(title="Slide", items=[("01", "Head", "Desc")])
eng.two_col(title="Compare", left_title="A", left_items=[], right_title="B", right_items=[])
eng.vs_compare(title="VS", left_title="Before", right_title="After", rows=[("Dim", "Val1", "Val2")])
eng.table(title="Data", headers=["H1", "H2"], rows=[["a", "b"]], insights=["Key takeaway"])
eng.stat_cards(title="KPIs", stats=[("99%", "Uptime"), ("$2M", "Revenue")])
eng.chart_bar(title="Revenue", data=[[4.2, 3.8]], labels=["A", "B"], series_names=["S1"])
eng.chart_pie(title="Mix", data=[45, 30, 25], labels=["X", "Y", "Z"], donut=True)
eng.chart_line(title="Trend", data=[[1, 2, 3]], labels=["Q1", "Q2", "Q3"])
eng.chart_gauge(title="Score", value=87, max_value=100, label="NPS")
eng.timeline(title="Roadmap", milestones=[("Q1", "Launch"), ("Q2", "Scale")])
eng.process_flow(title="Steps", steps=["Research", "Build", "Launch"])
eng.matrix_2x2(title="Priority", quadrants=[("TL", "desc"), ("TR", "desc"), ("BL", "desc"), ("BR", "desc")])
eng.quote(title="Insight", quote_text="Words matter.", attribution="Author")
eng.image_full(title="Visual", image_path="photo.jpg", caption="Detail")
eng.image_split(title="Split", image_path="photo.jpg", bullets=["Point"])
eng.kpi_dashboard(title="Dashboard", kpis=[("Revenue", 12.4, 15, "M")])
eng.team_grid(title="Team", members=[("Name", "Role")])
eng.checklist(title="Tasks", items=["Task 1", "Task 2"], checked=[True, False])
eng.summary(title="Takeaways", key_points=["Point 1"], conclusion="Next step")
eng.closing(title="Thank You", message="Questions?")  # no page_num (closing slide)
eng.save("output.pptx")
```

**10 themes**: business, business_dark, tech, tech_gradient, minimal, elegant, creative, green, red, ocean

---

## Design Guide

### Color

Extract from user's original PPT first. Pick a bold palette matching the topic.
One dominant color (60-70%), 1-2 supporting, one sharp accent.

### Typography

| Element | Size | Notes |
|---------|------|-------|
| Slide title | 26-36pt bold | Must stand out |
| Body text | 14-16pt | Never below 10pt |
| Captions | 10-12pt | Muted color |

CJK: Noto Sans CJK SC / Latin: Arial / Calibri

### Spacing

- Minimum margin: 0.5"
- Between blocks: 0.3-0.5"
- Leave breathing room

### Avoid

- Repeating the same layout on every slide
- Text-only slides — add visual elements
- Center-aligned body text
- Low-contrast text (light on light, dark on dark)

---

## Dependencies

| Tool | Install |
|------|---------|
| python-pptx | `pip install python-pptx` |
| lxml | `pip install lxml` |
| Pillow | `pip install Pillow` |

**Render QA (optional but recommended)**:

| Tool | Install |
|------|----------|
| LibreOffice Impress | `apt install libreoffice-impress` |
| poppler-utils | `apt install poppler-utils` |
| Noto Sans CJK | `apt install fonts-noto-cjk` |

---

## Skill File Structure

```
deckcraft/
├── SKILL.md                     # This file
├── engine/
│   ├── __init__.py
│   ├── constants.py             # 10 theme color palettes, typography, grid
│   ├── core.py                  # Drawing primitives, XML cleanup, CJK font
│   ├── chart_engine.py          # Native bar/pie/line/gauge charts (python-pptx)
│   └── deck_engine.py           # 20 layout methods, 40+ high-level API
├── scripts/
│   ├── generate_ppt.py          # CLI entry point
│   ├── gate_check.py            # S4 QA gate → gate_result.json
│   └── gate_check_content.py   # S3 content gate → gate_content.json
└── designs/
    └── layout_matrix.yaml       # 23 layout definitions with char budgets
```
