document-gen-resilient-multiformat
What it does
This skill guides the AI through turning one document source into several formats, checking the tools first. It is for people who want one document in multiple file types without guessing what is installed.
When to use it
- ✓When I need the same document as a Word file, a PDF and a web page.
- ✓When pandoc or a PDF engine may be missing from my computer.
- ✓When the text includes special characters that behave differently in each format.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-618c9b/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Please make this document available as Word, PDF and HTML, and tell me if any tool is missing.”
5 new skills a week. 1 minute to read.
How it works
The AI checks which tools are installed, writes the source document, adjusts special characters for each format, converts it, and confirms each output file exists and is valid.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Resilient Document Generation Workflow (Multi-Format + Unicode-Safe)
When to Use
Use this skill when generating documents in multiple formats (.docx, .pdf, .html) and you need:
- Reliable execution with pre-flight environment verification
- Automatic Unicode handling based on target format
- Fallback options when primary tools (pandoc/LaTeX) are unavailable
- Clear error isolation through discrete, observable steps
Trigger this workflow when:
shell_agentreturns unknown/unclear errors on document generation- You need multiple output formats from one source
- Documents contain special characters, symbols, or non-ASCII text
- Previous PDF generation attempts failed due to encoding or missing dependencies
Pre-Flight Environment Check
Before starting, verify your environment has the required tools:
run_shell
command: which pandoc && pandoc --version | head -1
run_shell
command: which pdflatex || which xelatex || which wkhtmltopdf || echo "No PDF engine found"
run_shell
command: python3 -c "import fpdf; print('fpdf2 available')" 2>/dev/null || echo "fpdf2 not available"
run_shell
command: python3 -c "import reportlab; print('reportlab available')" 2>/dev/null || echo "reportlab not available"
If pandoc is missing: Install via apt-get install pandoc or brew install pandoc
If no PDF engine found: Choose fallback approach:
- Install LaTeX:
apt-get install texlive-latex-recommended texlive-fonts-recommended - Or use wkhtmltopdf:
apt-get install wkhtmltopdf - Or use Python fallback (fpdf2/reportlab) - see Alternative PDF Generation section
Core Technique
Split the workflow into discrete, observable steps with automatic format detection:
- Environment check → Verify tools are available
- Content creation → Use
write_fileto create source Markdown - Auto-sanitization → Conditionally sanitize based on target format (PDF needs it, DOCX/HTML don't)
- Format conversion → Use appropriate tool for each format with fallback options
- Verification → Check output files exist and validate content
⚠️ Unicode & Format Compatibility Matrix
| Format | Unicode Support | Sanitization Needed | Recommended Engine |
|---|---|---|---|
.docx |
Excellent | No | pandoc (default) |
.html |
Excellent | No | pandoc (default) |
.pdf |
Limited (LaTeX) | Yes | xelatex > pdflatex > wkhtmltopdf > fpdf2 |
.pptx |
Good | No | pandoc (if available) or python-pptx |
Critical Unicode Characters for PDF
| Character | Issue | Safe Replacement |
|---|---|---|
— (em dash) |
May not render | -- or - |
– (en dash) |
May not render | - |
" " (curly quotes) |
Encoding errors | " " (straight quotes) |
' ' (curly apostrophe) |
Encoding errors | ' (straight apostrophe) |
… (ellipsis) |
May not render | ... |
→ ← ↑ ↓ (arrows) |
LaTeX incompatibility | -> <- ^ v |
✓ ✗ (checkmarks) |
May not render | [x] [ ] |
★ ● (symbols) |
May not render | * - |
© ® ™ |
May require packages | (c) (r) (tm) |
| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |
Step-by-Step Workflow
Step 0: Pre-Flight Check
Verify environment before proceeding:
run_shell
command: pandoc --version >/dev/null 2>&1 && echo "PANDOC_OK" || echo "PANDOC_MISSING"
If PANDOC_MISSING: Either install pandoc or use Alternative PDF Generation (Python-based)
Step 1: Create Source Content with write_file
Write your document content as Markdown to a source file:
write_file
path: /tmp/document_source.md
content: |
# Document Title
## Section 1
Content with original unicode characters...
## Section 2
More content...
Step 2: Conditional Unicode Sanitization
Only sanitize if generating PDF. Create sanitized version for PDF conversion:
write_file
path: /tmp/document_source_sanitized.md
content: |
# Document Title
## Section 1
Content with unicode replaced (em-dash -> --, curly quotes -> straight, etc.)
## Section 2
More content...
Optional: Use sanitization script (see Unicode Sanitization Script section below):
run_shell
command: ./sanitize_for_pdf.sh /tmp/document_source.md /tmp/document_source_sanitized.md
Note: Keep the original unsanitized file for DOCX/HTML conversion (these
FAQ
What if no PDF engine is found?
The guide offers Python fallbacks such as fpdf2 or reportlab.
Does it install the missing tools?
The guide mentions installing pandoc or LaTeX engines with system package commands when they are missing.
Why are special characters a concern?
Each format handles Unicode differently, so the guide plans for it.
Details
Original description by the author
Resilient multi-format document generation with environment checks, auto-sanitization, and fallback engines
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12858
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.