# Document Gen Resilient Workflow

Robust document generation with engine fallback chain, error diagnostics, and Python...

- Repository: https://github.com/HKUDS/AgentPilot (7784 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

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

## Description

Robust document generation with engine fallback chain, error diagnostics, and Python alternatives

## 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 tool errors or failures, especially:
- `run_shell` commands return 'unknown error' without diagnostic details
- PDF generation fails with LaTeX encoding or missing engine errors
- You need fallback options when primary conversion methods fail
- **Workspace or path issues** cause file access problems
- Unicode/special characters cause rendering issues in PDF output
- `shell_agent` has failed multiple times on similar tasks

## Core Technique

Split document generation into **observable, verifiable steps** with explicit error capture and progressive fallback:

1. **Validate workspace** → Confirm current directory and write permissions
2. **Pre-flight checks** → Verify required tools (pandoc, LaTeX engines) are available
3. **Content creation** → Use `write_file` for source Markdown with full visibility
4. **Unicode sanitization** → Preprocess for PDF conversion when needed
5. **Progressive conversion** → Try multiple engines/methods until one succeeds
6. **Explicit error capture** → Redirect stderr to diagnose failures
7. **Verification** → Confirm output files exist and are readable

## ⚠️ Critical: Tool Error Patterns

**'unknown error' from run_shell**: This typically indicates:
- Sandbox execution context issues (not the command itself)
- Missing stderr capture preventing diagnosis
- Transient file access problems

**Solution**: Use explicit error capture with `2>&1` and verify tool availability first:
```
run_shell
command: pandoc --version 2>&1 || echo "PANDOC NOT AVAILABLE"
```

## Pre-Flight Checklist

Before starting conversion, verify your environment:

```markdown
## Pre-Flight Checks

### Check 1: Verify working directory
run_shell
command: pwd && ls -la

### Check 2: Verify pandoc availability
run_shell
command: pandoc --version 2>&1 | head -3 || echo "PANDOC MISSING"

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