Skilllibrary pptx-generation
Generate PowerPoint (.pptx) presentations programmatically using python-pptx — apply slide layouts, insert charts and tables, set speaker notes, manage slide masters, and produce presentation-ready decks from data. Use when creating automated slide decks, building presentation pipelines, or converting structured data into slide format. Do not use for manual presentation design advice or non-PowerPoint slide formats.
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/15-docs-artifacts-media/pptx-generation" ~/.claude/skills/merceralex397-collab-skilllibrary-pptx-generation && rm -rf "$T"
manifest:
15-docs-artifacts-media/pptx-generation/SKILL.mdsource content
Purpose
Generate PowerPoint (.pptx) presentations programmatically using python-pptx. Build pipelines that convert structured data into slide decks with consistent layouts, charts, tables, images, and speaker notes — suitable for automated reporting, executive summaries, and data-driven presentations.
When to use this skill
- The task requires generating .pptx files from structured data (JSON, CSV, database queries, API responses).
- Building an automated reporting pipeline that produces slide decks on a schedule.
- Converting analysis results, dashboards, or metrics into presentation format.
- The user needs a template-based slide generation system with branded layouts.
- Populating an existing .pptx template with dynamic content (mail-merge style).
Do not use this skill
- For manual presentation design advice or visual design critiques — this skill is for programmatic generation.
- For generating Google Slides, Keynote, or reveal.js — this skill targets the .pptx format via python-pptx.
- For generating PDF slide handouts — prefer
after creating the .pptx.pdf-generation - For Word document generation — prefer
.docx-generation
Operating procedure
- Define the deck structure. List the slides needed: title slide, agenda, content slides, chart slides, summary, appendix. Map each slide to a data source (dict key, DataFrame, image path).
- Select or create a slide master. Open an existing branded .pptx template with
or create a blank presentation. Identify available slide layouts by iteratingPresentation('template.pptx')
and mapping layout names to indices.prs.slide_layouts - Initialize the presentation object. Instantiate
or load the template. Set slide dimensions if non-standard:Presentation()
andprs.slide_width
usingprs.slide_height
orInches()
.Emu() - Add slides with appropriate layouts. For each content section, select the matching layout:
thenslide_layout = prs.slide_layouts[index]
. Access placeholders by index to populate title and body text.slide = prs.slides.add_slide(slide_layout) - Insert tables. Use
to create tables. Populate cells withslide.shapes.add_table(rows, cols, left, top, width, height)
. Apply formatting: font size, bold headers, cell margins, and alternating row colors viatable.cell(row, col).text = value
.cell.fill.solid() - Insert charts. Build chart data with
orCategoryChartData()
. Add charts viaXyChartData()
. Configure axes, legends, data labels, and colors through theslide.shapes.add_chart(chart_type, x, y, cx, cy, chart_data)
object properties.chart - Insert images and shapes. Add images with
. For generated charts (matplotlib, plotly), save to a BytesIO buffer first, then insert. Maintain aspect ratios.slide.shapes.add_picture(image_path, left, top, width, height) - Set speaker notes. Access
to add presenter notes for each slide. Include data sources, talking points, and caveats.slide.notes_slide.notes_text_frame.text - Apply consistent formatting. Set font families, sizes, and colors programmatically across all text frames. Use
andrun.font.size = Pt(N)
. Maintain brand consistency.run.font.color.rgb = RGBColor(r, g, b) - Save and validate. Save with
. Open the result in PowerPoint or LibreOffice to verify layouts, chart rendering, and text overflow. Test with varying data lengths.prs.save('output.pptx')
Decision rules
- Always start from a branded template .pptx when one exists — avoid recreating slide masters in code.
- Use placeholder-based population when the template has defined placeholders — it preserves the designer's layout.
- Fall back to absolute-positioned shapes only when placeholders are insufficient.
- Prefer
for bar/line/pie charts andCategoryChartData
for scatter plots.XyChartData - Limit slides to 1 key message per slide — split dense data across multiple slides rather than cramming.
- Embed images at 150 DPI for presentation use — higher resolution inflates file size without visible benefit on projectors.
Output requirements
- A Python script or module that accepts structured data and produces a .pptx file.
- Clear separation between data preparation, template selection, and slide population logic.
- Speaker notes on every content slide with data source attribution.
- The output .pptx must open without errors in PowerPoint 2016+ and LibreOffice Impress.
References
- python-pptx documentation: https://python-pptx.readthedocs.io/
- python-pptx API reference for charts: https://python-pptx.readthedocs.io/en/latest/api/chart.html
- Office Open XML (OOXML) slide format: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-pptx/
Related skills
— for Word document output from similar data pipelines.docx-generation
— for PDF output or converting the generated .pptx to PDF.pdf-generation
— for narrative-form documents rather than slide decks.document-writing
Anti-patterns
- Hardcoding slide layout indices (e.g.,
) without verifying the layout name — breaks when the template changes.slide_layouts[1] - Adding 50+ data rows to a single slide table instead of paginating across multiple slides.
- Ignoring text overflow in placeholders — long strings silently clip or shrink to unreadable sizes.
- Using
everywhere instead of leveraging template placeholders — produces inconsistent formatting.add_textbox - Saving matplotlib charts as low-resolution PNGs — use SVG or high-DPI PNG for crisp rendering.
Failure handling
- If python-pptx is not installed, output
and halt.pip install python-pptx - If the template file is missing or corrupt, raise a clear error with the expected path.
- If a slide layout index is out of range, list available layouts with names and indices, then halt.
- If chart data is empty, skip the chart slide and log a warning rather than producing a blank chart.
- If an image file is missing, insert a placeholder shape with error text instead of crashing the pipeline.
- If the output file exceeds 50 MB, log a warning suggesting image compression.