# Document Gen Resilient

Multi-path document generation with tool checks, Unicode handling, and Python fallbacks

- Repository: https://github.com/HKUDS/AgentPilot (7784 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient -g -a claude-code -y`
Codex: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient -g -a codex -y`
Cursor: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/AgentPilot --skill document-gen-resilient -g -a gemini-cli -y`

## Description

Multi-path document generation with tool checks, Unicode handling, and Python fallbacks

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 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:

| 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"
```

The rest: https://github.com/HKUDS/AgentPilot/blob/HEAD/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-96865f/SKILL.md
