backend/onyx/skills/builtin/pptx/editing.md
Path convention: All commands run from the session workspace. Never
cdinto the skill directory. Prefix all skill scripts with.opencode/skills/pptx/. All generated files go inoutputs/.
When using an existing presentation as a template:
Preserve the template's design. Your job is to fill the template with the user's content, not to restyle it. Keep its fonts, colors, and layout language exactly. In particular, do not substitute fonts — a template often embeds fonts that aren't installed system-wide (check
ppt/fonts/); they render correctly as-is, and replacing them with an "installed" font breaks the look. New text you add should reuse the fonts already on that slide.
Analyze existing slides:
python .opencode/skills/pptx/scripts/thumbnail.py template.pptx outputs/thumbnails
python -m markitdown template.pptx
Review outputs/thumbnails.jpg to see layouts, and markitdown output to see placeholder text.
Plan slide mapping: For each content section, choose a template slide.
⚠️ USE VARIED LAYOUTS — monotonous presentations are a common failure mode. Don't default to basic title + bullet slides. Actively seek out:
Avoid: Repeating the same text-heavy layout for every slide.
Match content type to layout style (e.g., key points → bullet slide, team info → multi-column, testimonials → quote slide).
Unpack: python .opencode/skills/pptx/scripts/office/unpack.py template.pptx outputs/unpacked/
Build presentation (do this yourself, not with subagents):
<p:sldIdLst>)add_slide.py)<p:sldIdLst>First pack (do this EARLY): as soon as the structure is set and first-pass content is in, clean + pack so a viewable deck exists:
python .opencode/skills/pptx/scripts/clean.py outputs/unpacked/
python .opencode/skills/pptx/scripts/office/pack.py outputs/unpacked/ outputs/output.pptx --original template.pptx
A turn that ends with edits stranded in outputs/unpacked/ delivers nothing — the packed .pptx is the deliverable (SKILL.md → Build Order). Never do fine-grained restyling before the first pack exists.
Refine content: update text in each slide{N}.xml.
Use subagents here if available — slides are separate XML files, so subagents can edit in parallel.
Re-clean + re-pack after each batch of edits (same commands as step 5) — the packed deck in outputs/ should always reflect your latest good state.
| Script | Purpose |
|---|---|
unpack.py | Extract and pretty-print PPTX |
add_slide.py | Duplicate slide or create from layout |
clean.py | Remove orphaned files |
pack.py | Repack with validation |
thumbnail.py | Create visual grid of slides |
python .opencode/skills/pptx/scripts/office/unpack.py input.pptx outputs/unpacked/
Extracts PPTX, pretty-prints XML, escapes smart quotes.
python .opencode/skills/pptx/scripts/add_slide.py outputs/unpacked/ slide2.xml # Duplicate slide
python .opencode/skills/pptx/scripts/add_slide.py outputs/unpacked/ slideLayout2.xml # From layout
Prints <p:sldId> to add to <p:sldIdLst> at desired position.
python .opencode/skills/pptx/scripts/clean.py outputs/unpacked/
Removes slides not in <p:sldIdLst>, unreferenced media, orphaned rels.
python .opencode/skills/pptx/scripts/office/pack.py outputs/unpacked/ outputs/output.pptx --original input.pptx
Validates, repairs, condenses XML, re-encodes smart quotes.
python .opencode/skills/pptx/scripts/thumbnail.py input.pptx outputs/thumbnails [--cols N]
Creates outputs/thumbnails.jpg with slide filenames as labels. Default 3 columns, max 12 per grid.
Use for template analysis only (choosing layouts). For visual QA, use soffice + pdftoppm to create full-resolution individual slide images—see SKILL.md.
Slide order is in outputs/unpacked/ppt/presentation.xml → <p:sldIdLst>.
Reorder: Rearrange <p:sldId> elements.
Delete: Remove <p:sldId>, then run clean.py.
See available layouts: ls outputs/unpacked/ppt/slideLayouts/
Add: Use add_slide.py. Never manually copy slide files—the script handles notes references, Content_Types.xml, and relationship IDs that manual copying misses.
Subagents: If available, use them here (after completing step 4). Each slide is a separate XML file, so subagents can edit in parallel. In your prompt to subagents, include:
For each slide:
.opencode/skills/pptx/scripts/icon.js (see pptxgenjs.md); insert either as slide media at the placeholder's sizeUse the Edit tool, not sed or Python scripts. The Edit tool forces specificity about what to replace and where, yielding better reliability.
b="1" on <a:rPr>. This includes:
<a:buChar> or <a:buAutoNum><a:buChar> or <a:buNone>.When source content has fewer items than the template:
When replacing text with different length content:
Template slots ≠ Source items: If template has 4 team members but source has 3 users, delete the 4th member's entire group (image + text boxes), not just the text.
If source has multiple items (numbered lists, multiple sections), create separate <a:p> elements for each — never concatenate into one string.
❌ WRONG — all items in one paragraph:
<a:p>
<a:r><a:rPr .../><a:t>Step 1: Do the first thing. Step 2: Do the second thing.</a:t></a:r>
</a:p>
✅ CORRECT — separate paragraphs with bold headers:
<a:p>
<a:pPr algn="l"><a:lnSpc><a:spcPts val="3919"/></a:lnSpc></a:pPr>
<a:r><a:rPr lang="en-US" sz="2799" b="1" .../><a:t>Step 1</a:t></a:r>
</a:p>
<a:p>
<a:pPr algn="l"><a:lnSpc><a:spcPts val="3919"/></a:lnSpc></a:pPr>
<a:r><a:rPr lang="en-US" sz="2799" .../><a:t>Do the first thing.</a:t></a:r>
</a:p>
<a:p>
<a:pPr algn="l"><a:lnSpc><a:spcPts val="3919"/></a:lnSpc></a:pPr>
<a:r><a:rPr lang="en-US" sz="2799" b="1" .../><a:t>Step 2</a:t></a:r>
</a:p>
<!-- continue pattern -->
Copy <a:pPr> from the original paragraph to preserve line spacing. Use b="1" on headers.
Handled automatically by unpack/pack. But the Edit tool converts smart quotes to ASCII.
When adding new text with quotes, use XML entities:
<a:t>the “Agreement”</a:t>
| Character | Name | Unicode | XML Entity |
|---|---|---|---|
“ | Left double quote | U+201C | “ |
” | Right double quote | U+201D | ” |
‘ | Left single quote | U+2018 | ‘ |
’ | Right single quote | U+2019 | ’ |
xml:space="preserve" on <a:t> with leading/trailing spacesdefusedxml.minidom, not xml.etree.ElementTree (corrupts namespaces)