
Document Gen Resilient
Multi-path document generation with tool checks, Unicode handling, and Python fallbacks
Install
npx skills add HKUDS/AgentPilot --skill document-gen-resilient -g -a claude-code -y- Repository
- HKUDS/AgentPilot7.8k
- Category
- Engineering
- Updated
- 3d ago
- License
- MIT
- Context cost
- Mediumabout 3,000 tokens
- Runs scripts
- No, instructions only
What it does
Multi-path document generation with tool checks, Unicode handling, and Python fallbacks
Resilient Document Generation Workflow
When to Use
Use this skill when document generation tasks encounter errors or when you need reliable multi-format output:
shell_agentreturns unknown or unclear errors on document generation- Generating documents in multiple formats (e.g.,
.docx,.pdf,.html) - PDF generation fails due to LaTeX encoding or missing dependencies
- You need to handle special characters, symbols, or non-ASCII text safely
- Previous document generation attempts have failed
Core Technique
Instead of delegating the entire document generation to shell_agent, manually split the workflow into discrete, observable steps with built-in fallbacks:
- Tool availability check → Verify pandoc and PDF engines are available
- Content creation → Use
write_fileto create source document (Markdown) - Unicode assessment → Determine if sanitization is needed based on target format
- Format conversion → Try primary method, fall back to alternatives on failure
- Verification → Check output files exist and are valid
⚠️ Format-Specific Unicode Guidance
Critical: Different formats handle Unicode differently. Plan accordingly:
| Format | Unicode Support | Sanitization Needed? | Recommended Engine |
|---|---|---|---|
.docx | Excellent | No | pandoc (default) |
.html | Excellent | No | pandoc (default) |
.pdf (pdflatex) | Limited | Yes | pandoc + sanitization |
.pdf (xelatex) | Good | Rarely | pandoc --pdf-engine=xelatex |
.pdf (wkhtmltopdf) | Good | Rarely | pandoc --pdf-engine=wkhtmltopdf |
.pdf (Python) | Excellent | No | fpdf2 or reportlab |
Step-by-Step Workflow
Step 0: Check Tool Availability
Before starting, verify which tools are available:
run_shell
command: which pandoc && echo "PANDOC: OK" || echo "PANDOC: MISSING"
