# Document Gen Fallback

Fallback workflow for multi-format document generation when shell_agent encounters errors

- 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-fallback -g -a claude-code -y`
Codex: `npx skills add HKUDS/AgentPilot --skill document-gen-fallback -g -a codex -y`
Cursor: `npx skills add HKUDS/AgentPilot --skill document-gen-fallback -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/AgentPilot --skill document-gen-fallback -g -a gemini-cli -y`

## Description

Fallback workflow for multi-format document generation when shell_agent encounters errors

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

# Document Generation Fallback Workflow

## When to Use

Use this skill when `shell_agent` returns unknown or unclear errors on complex document generation tasks, especially when:
- Generating documents in multiple formats (e.g., `.docx`, `.pdf`, `.html`)
- The error message doesn't provide clear debugging information
- You need better visibility into each step of the generation process

## Core Technique

Instead of delegating the entire document generation to `shell_agent`, manually split the workflow into discrete, observable steps:
1. **Content creation** → Use `write_file` to create source document (Markdown)
2. **Format conversion** → Use `run_shell` with `pandoc` for each target format
3. **Verification** → Check output files exist and are valid

## Step-by-Step Workflow

### Step 1: Create Source Content with write_file

Write your document content as Markdown to a temporary source file. This gives you full visibility into the content being generated.

```
write_file
path: /tmp/document_source.md
content: |
  # Document Title
  
  ## Section 1
  Content here...
  
  ## Section 2
  More content...
```

### Step 2: Convert to Target Formats with run_shell

Use `run_shell` with explicit `pandoc` commands for each format. This isolates conversion errors.

```
run_shell
command: pandoc /tmp/document_source.md -o output.docx
```

```
run_shell
command: pandoc /tmp/document_source.md -o output.pdf
```

### Step 3: Verify Outputs

Check that files were created successfully:

```
run_shell
command: ls -lh output.docx output.pdf
```

## Complete Example

```markdown
# Generate Negotiation Strategy Document

## Step 1: Write Markdown source
write_file
path: /tmp/negotiation_strategy.md
content: |
  # Negotiation Strategy
  
  ## Executive Summary
  [Content...]
  
  ## Resolution Path
  [Content...]
  
  ## BATNA Analysis
  [Content...]

## Step 2: Convert to DOCX
run_shell
command: pandoc /tmp/negotiation_strategy.md -o negotiation_strategy.docx

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