PPTX Skill

From aipoch/medical-research-skills · View interactive version

PPTX Skill is an AI agent skill from the GitHub repository aipoch/medical-research-skills. Create, edit, and extract content from PowerPoint (.pptx) files; use when you need to generate slides programmatically, update existing decks, or export slide previews.

How to use this skill

Skill file

Source: https://github.com/aipoch/medical-research-skills

When to Use

Key Features

Dependencies

Example Usage

# pip install python-pptx Pillow requests

from pptx import Presentation
from pptx.util import Inches
from PIL import Image
import requests
from io import BytesIO

def create_presentation(output_path: str) -> None:
    prs = Presentation()

    # Slide 1: Title slide
    slide = prs.slides.add_slide(prs.slide_layouts[0])
    slide.shapes.title.text = "Machine Learning"
    slide.placeholders[1].text = "A 5-slide overview generated programmatically"

    # Slide 2: Bullets
    slide = prs.slides.add_slide(prs.slide_layouts[1])
    slide.shapes.title.text = "What is Machine Learning?"
    tf = slide.shapes.placeholders[1].text_frame
    tf.clear()
    tf.text = "A field of AI focused on learning patterns from data"
    for bullet in [
        "Supervised learning",
        "Unsupervised learning",
        "Reinforcement learning",
    ]:
        p = tf.add_paragraph()
        p.text = bullet

    # Slide 3: Add an image (downloaded)
    img_url = "https://upload.wikimedia.org/wikipedia/commons/4/44/Neural_network.svg"
    resp = requests.get(img_url, timeout=30)
    resp.raise_for_status()

    # Ensure the image is in a format python-pptx can embed reliably
    img = Image.open(BytesIO(resp.content)).convert("RGBA")
    buf = BytesIO()
    img.save(buf, format="PNG")
    buf.seek(0)

    slide = prs.slides.add_slide(prs.slide_layouts[5])  # Title Only
    slide.shapes.title.text = "Neural Networks (Illustration)"
    slide.shapes.add_picture(buf, Inches(1), Inches(1.6), width=Inches(8))

    # Slide 4: Edit text on an existing slide (example: update slide 2 title)
    prs.slides[1].shapes.title.text = "Machine Learning: Definition & Types"

    # Slide 5: Summary
    slide = prs.slides.add_slide(prs.slide_layouts[1])
    slide.shapes.title.text = "Summary"
    tf = slide.shapes.placeholders[1].text_frame
    tf.clear()
    tf.text = "Key takeaways"
    for bullet in [
        "ML learns from data to make predictions or decisions",
        "Model choice depends on task and constraints",
        "Evaluation and iteration are essential",
    ]:
        p = tf.add_paragraph()
        p.text = bullet

    prs.save(output_path)

def list_slide_titles(pptx_path: str) -> list[str]:
    prs = Presentation(pptx_path)
    titles = []
    for slide in prs.slides:
        title_shape = slide.shapes.title if hasattr(slide.shapes, "title") else None
        if title_shape is not None and getattr(title_shape, "text", "").strip():
            titles.append(title_shape.text.strip())
        else:
            titles.append("(no title)")
    return titles

if __name__ == "__main__":
    out = "machine_learning.pptx"
    create_presentation(out)
    print("Created:", out)
    print("Slide titles:", list_slide_titles(out))

Implementation Details

When Not to Use

Required Inputs

Recommended Workflow

  1. Validate the request against the skill boundary and confirm all required inputs are present.
  2. Select the documented execution path and prefer the simplest supported command or procedure.
  3. Produce the expected output using the documented file format, schema, or narrative structure.
  4. Run a final validation pass for completeness, consistency, and safety before returning the result.

Deterministic Output Rules

Output Contract

Validation and Safety Rules

Failure Handling

Completion Checklist

Quick Validation

Run this minimal verification path before full execution when possible:

python scripts/__init__.py --help

Expected output format:

Result file: pptx_skill_result.md
Validation summary: PASS/FAIL with brief notes
Assumptions: explicit list if any

Scope Reminder

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.