Skills

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_agent returns 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:

  1. Tool availability check → Verify pandoc and PDF engines are available
  2. Content creation → Use write_file to create source document (Markdown)
  3. Unicode assessment → Determine if sanitization is needed based on target format
  4. Format conversion → Try primary method, fall back to alternatives on failure
  5. Verification → Check output files exist and are valid

⚠️ Format-Specific Unicode Guidance

Critical: Different formats handle Unicode differently. Plan accordingly:

FormatUnicode SupportSanitization Needed?Recommended Engine
.docxExcellentNopandoc (default)
.htmlExcellentNopandoc (default)
.pdf (pdflatex)LimitedYespandoc + sanitization
.pdf (xelatex)GoodRarelypandoc --pdf-engine=xelatex
.pdf (wkhtmltopdf)GoodRarelypandoc --pdf-engine=wkhtmltopdf
.pdf (Python)ExcellentNofpdf2 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"
Read the whole SKILL.md on GitHub

More in Engineering