Agent skill

Document Gen Resilient

by HKUDS in HKUDS/OpenSpace

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

MITAuto-check passedDocuments & Office

Install Document Gen Resilient

skills CLI
$ npx skills add HKUDS/OpenSpace --skill document-gen-resilient -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install HKUDS/OpenSpace document-gen-resilient --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/HKUDS/OpenSpace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-96865f .claude/skills/document-gen-resilient && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
document-gen-resilient
GitHub stars
7.8k
Token cost
~3.1k tokens
SKILL.md length
869 words
Files
2
Skills in repo
199
Repo updated
First seen
Licence
MIT

At a glance

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

  • Works in 5 steps: Check Tool Availability → Create Source Content with write_file → Assess and Handle Unicode (Conditional) → …
  • Tasks that involve PDF
  • SKILL.md covers When to Use, Core Technique, ⚠️ Format-Specific Unicode… and Step-by-Step Workflow, plus 8 more sections
  • Calls pandoc, apt-get and python3

What it does

Document Gen Resilient is an agent skill from HKUDS/OpenSpace. Multi-path document generation with tool checks, Unicode handling, and Python fallbacks

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 1 other file.

It sits in Documents & Office, covering PDF. It works with Python, Pandoc, LaTeX and Microsoft Word. The repository describes itself as: "OpenSpace: The Skill Management Layer for AI Agents" -- https://open-space.cloud/. The licence is MIT.

When your agent uses it

  • Tasks that involve PDF

Example prompts

  • “/document-gen-resilient”

Requirements

  • Python 3

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Check Tool Availability
  2. Create Source Content with write_file
  3. Assess and Handle Unicode (Conditional)
  4. Convert to Target Formats with run_shell
  5. Verify Outputs

What it can do on your machine

Read from SKILL.md and the folder at commit 3827781. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pandoc
    • apt-get
    • python3
    • brew

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Document Gen Resilient loads about 3.1k tokens when it runs. Until then it costs about 28 tokens; SKILL.md has 869 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~28
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from HKUDS/OpenSpace at commit 3827781, republished under its MIT licence (© HKUDS). 869 words, ~3,058 tokens.

Download SKILL.mdSave it as .claude/skills/document-gen-resilient/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
document-gen-resilient
description
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"
run_shell
command: which pdflatex && echo "PDFLATEX: OK" || echo "PDFLATEX: MISSING"
run_shell
command: which xelatex && echo "XELATEX: OK" || echo "XELATEX: MISSING"
run_shell
command: python3 -c "import fpdf; print('FPDF2: OK')" 2>/dev/null || echo "FPDF2: MISSING"

Decision Tree Based on Availability:

  • pandoc + xelatex available → Use pandoc with xelatex engine (best Unicode support)
  • pandoc + pdflatex only → Use pandoc with sanitization (Step 2)
  • pandoc missing, Python available → Use Python libraries (Step 3 Alternative)
  • All missing → Install dependencies or use shell_agent with explicit instructions
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: Assess and Handle Unicode (Conditional)

Before PDF conversion, check if your content contains problematic characters:

run_shell
command: grep -P '[\x{2014}\x{2013}\x{201C}\x{201D}\x{2026}]' /tmp/document_source.md && echo "UNICODE_DETECTED" || echo "UNICODE_CLEAN"

If Unicode detected AND using pdflatex, create a sanitized version:

write_file
path: /tmp/document_source_sanitized.md
content: |
  # Document Title
  
  ## Section 1
  Content here... (with all special chars replaced per table below)

Common Problematic Characters:

CharacterIssueSafe Replacement
— (em dash)May not render-- or -
– (en dash)May not render-
" " (curly quotes)Encoding errors" " (straight quotes)
' ' (curly apostrophe)Encoding errors' (straight apostrophe)
… (ellipsis)May not render...
→ ← ↑ ↓ (arrows)LaTeX incompatibility-> <- ^ v
✓ ✗ (checkmarks)May not render[x] [ ]
© ® ™May require packages(c) (r) (tm)

Note: Keep the original unsanitized file for DOCX/HTML conversion (these formats handle Unicode better).

Step 3: Convert to Target Formats with run_shell

Use run_shell with explicit commands for each format. Try primary method first, fall back on failure.

For DOCX (from original, no sanitization needed):
run_shell
command: pandoc /tmp/document_source.md -o output.docx
For PDF (try in order):

Option A: xelatex (best Unicode support)

run_shell
command: pandoc /tmp/document_source.md -o output.pdf --pdf-engine=xelatex

Option B: wkhtmltopdf (good alternative)

run_shell
command: pandoc /tmp/document_source.md -o output.pdf --pdf-engine=wkhtmltopdf

Option C: pdflatex with sanitization

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

Option D: Python fpdf2 fallback

run_shell
command: python3 -c "
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', size=12)
with open('/tmp/document_source.md', 'r', encoding='utf-8') as f:
    content = f.read()
pdf.multi_cell(0, 10, content)
pdf.output('output.pdf')
"
For HTML (from original, no sanitization needed):
run_shell
command: pandoc /tmp/document_source.md -o output.html
Step 4: Verify Outputs

Check that files were created successfully:

run_shell
command: ls -lh output.docx output.pdf output.html 2>/dev/null
run_shell
command: file output.pdf 2>/dev/null

Complete Example

markdown
# Generate Negotiation Strategy Document

## Step 0: Check tools
run_shell
command: which pandoc && which xelatex && echo "TOOLS_OK" || echo "TOOLS_MISSING"

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

## Step 2: Check for Unicode (if PDF needed)
run_shell
command: grep -P '[\x{2014}\x{2013}\x{201C}\x{201D}]' /tmp/negotiation_strategy.md && echo "UNICODE_DETECTED" || echo "UNICODE_CLEAN"

## Step 3: Convert to DOCX (from original)
run_shell
command: pandoc /tmp/negotiation_strategy.md -o negotiation_strategy.docx

## Step 4: Convert to PDF (try xelatex first)
run_shell
command: pandoc /tmp/negotiation_strategy.md -o negotiation_strategy.pdf --pdf-engine=xelatex

## Step 5: If Step 4 failed, try wkhtmltopdf
run_shell
command: pandoc /tmp/negotiation_strategy.md -o negotiation_strategy.pdf --pdf-engine=wkhtmltopdf

## Step 6: Convert to HTML (from original)
run_shell
command: pandoc /tmp/negotiation_strategy.md -o negotiation_strategy.html

## Step 7: Verify
run_shell
command: ls -lh negotiation_strategy.*

Advantages Over shell_agent

Aspectshell_agentManual Workflow
Error visibilityOpaque, may retry silentlyEach step shows explicit output
RecoveryAutomatic but may loopManual intervention at specific step
DebuggingHard to isolate failure pointClear which step failed
Unicode controlAgent may not handle encodingYou control character sanitization
Tool fallbackSingle approachMultiple fallback options
ControlAgent decides approachYou control each conversion

Common pandoc Commands

bash
# Markdown to Word
pandoc input.md -o output.docx

# Markdown to PDF (requires LaTeX or wkhtmltopdf)
pandoc input.md -o output.pdf

# Markdown to PDF with Unicode-safe engine (better Unicode support)
pandoc input.md -o output.pdf --pdf-engine=xelatex

# Markdown to PDF with wkhtmltopdf (good alternative)
pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf

# Markdown to HTML
pandoc input.md -o output.html

# With custom template
pandoc input.md --template=template.html -o output.html

# With metadata
pandoc input.md -o output.pdf --metadata title="Document Title"

Troubleshooting

Show full SKILL.md (351 more words)Show less
PDF Generation Failures
  • PDF generation fails with encoding error:

    • Use --pdf-engine=xelatex for better Unicode support
    • Or use --pdf-engine=wkhtmltopdf as alternative
    • Or create sanitized markdown file and use pdflatex
  • PDF generation fails: LaTeX not found:

    • Install LaTeX: apt-get install texlive-latex-recommended texlive-fonts-recommended
    • Or use --pdf-engine=wkhtmltopdf instead
    • Or fall back to Python fpdf2 (Step 3 Option D)
  • PDF generation fails: wkhtmltopdf not found:

    • Install: apt-get install wkhtmltopdf
    • Or use xelatex or pdflatex with sanitization
    • Or fall back to Python fpdf2
DOCX Formatting Issues
  • Add --reference-doc=template.docx for custom styles
  • Ensure pandoc version is 2.0+ for best DOCX support
Unicode/Encoding Errors in Any Format
  • Add -f markdown+utf8 to pandoc command
  • Ensure source file is UTF-8 encoded: file -i source.md
  • For PDF: prefer xelatex engine over pdflatex
Special Characters Not Rendering in PDF
  • Use xelatex engine: --pdf-engine=xelatex
  • Or use the character replacement table above
  • Or create sanitized version before PDF conversion
Missing pandoc
  • Install via apt-get install pandoc or brew install pandoc
  • Or use Python libraries directly (fpdf2, reportlab)
Python PDF Library Fallback

If pandoc is unavailable or consistently failing:

bash
# Using fpdf2
python3 -c "
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font('Arial', size=12)
pdf.multi_cell(0, 10, open('input.md').read())
pdf.output('output.pdf')
"

# Using reportlab (more control)
python3 -c "
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate('output.pdf', pagesize=letter)
styles = getSampleStyleSheet()
story = [Paragraph(open('input.md').read(), styles['Normal'])]
doc.build(story)
"

Unicode Sanitization Script (Optional)

For repeated use, create a reusable sanitization script:

bash
#!/bin/bash
# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX/PDF
if [ -z "$1" ]; then
  echo "Usage: $0 <input.md> [output.md]"
  exit 1
fi
INPUT="$1"
OUTPUT="${2:-${1%.md}_sanitized.md}"

sed -e 's/—/--/g' \
    -e 's/–/-/g' \
    -e 's/"([^"]*)"/"\1"/g' \
    -e "s/'([^']*)/'\1'/g" \
    -e 's/…/.../g' \
    -e 's/→/->/g' \
    -e 's/←/<-/g' \
    -e 's/✓/[x]/g' \
    -e 's/✗/[ ]/g' \
    -e 's/©/(c)/g' \
    -e 's/®/(r)/g' \
    -e 's/™/(tm)/g' \
    "$INPUT" > "$OUTPUT"

echo "Sanitized: $INPUT -> $OUTPUT"

Save as sanitize_for_pdf.sh, make executable with chmod +x sanitize_for_pdf.sh, then use:

run_shell
command: ./sanitize_for_pdf.sh /tmp/document_source.md /tmp/document_source_sanitized.md

Decision Matrix: Which Approach to Use

ScenarioRecommended Approach
DOCX only, any contentpandoc (no sanitization needed)
HTML only, any contentpandoc (no sanitization needed)
PDF, simple ASCII contentpandoc + pdflatex
PDF, Unicode contentpandoc + xelatex (preferred)
PDF, Unicode, xelatex unavailablepandoc + sanitization + pdflatex
PDF, pandoc unavailablePython fpdf2 or reportlab
Multiple formats neededpandoc for all, sanitization for PDF only
shell_agent failing repeatedlyUse this manual workflow

When to Return to shell_agent

After successfully completing the manual workflow once, you can attempt shell_agent again for similar tasks, now with a known-working fallback if errors recur. For documents with heavy Unicode content requiring PDF output, consider always using the manual workflow with xelatex or sanitization.

  • write-file-fallback-report: Use when web sourcing fails, create from embedded knowledge
  • spreadsheet-direct-python: Use Python libraries directly for spreadsheet operations
  • Use this skill when your documents contain special characters, symbols, or non-ASCII text that may cause LaTeX/PDF conversion issues

© HKUDS, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-96865f of HKUDS/OpenSpace.

  • SKILL.md
  • .skill_id

Open the folder on GitHubat commit 3827781

Compare with similar skills

Document Gen Resilient next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Document Gen Resilient compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Document Gen Resilient this skillHKUDS/OpenSpace7.8k—~3.1kAutomated safety check: PassMIT
MineruNebutra/MinerU-Skill122—~504Automated safety check: PassMIT
Pandic OfficeTeam-Commonly/commonly1.4k—~642Automated safety check: PassApache-2.0
Article Format Adjustmentaipoch/medical-research-skills2k—~2.4kAutomated safety check: PassMIT
MineruNebutra/MinerU-Skill122—~1.4kAutomated safety check: PassMIT
Lexoid CLIoidlabs-com/Lexoid109—~2kAutomated safety check: NotesApache-2.0

Similar skills

  • Mineru

    Nebutra/MinerU-Skill

    An AI-Native skill for parsing PDF / Office / image files into Markdown with MinerU — a fast, zero-config document parser for AI agents.

    122 GitHub stars~504 tokensUpdated 15 days ago
    Documents & OfficeAuto-check passed
  • Pandic Office

    Team-Commonly/commonly

    Convert Markdown to PDF (or DOCX/EPUB/HTML) using the pandoc CLI.

    1.4k GitHub stars~642 tokensUpdated today
    Documents & OfficeAuto-check passed
  • Article Format Adjustment

    aipoch/medical-research-skills

    Adjust academic paper formatting and convert between DOCX/LaTeX/Markdown when you need to meet a journal or school template requirement.

    2k GitHub stars~2.4k tokensUpdated 22 days ago
    Documents & OfficeAuto-check passed
  • Mineru

    Nebutra/MinerU-Skill

    An AI-Native skill for parsing PDF / Office / image files into clean Markdown with MinerU — a fast, zero-config document parser for AI agents.

    122 GitHub stars~1.4k tokensUpdated 15 days ago
    Documents & OfficeAuto-check passed
  • Lexoid CLI

    oidlabs-com/Lexoid

    Parse and convert documents (PDFs, images, web pages, DOCX/XLSX/PPTX, audio) from the terminal using the lexoid CLI.

    109 GitHub stars~2k tokensUpdated yesterday
    Documents & OfficeAuto-check: notes
  • Harness Book Best Practice

    wquguru/harness-books

    Best practices for working on the Harness books repo. An agent skill from wquguru/harness-books.

    3.2k GitHub stars~4.1k tokensUpdated 5 mo ago
    Documents & OfficeAuto-check passed

More from HKUDS/OpenSpace

All 199 skills in this repo
  • Walks through producing a master audio track plus stems in Python, from checking a reference file and timing sections by BPM to effects, a zip archive and final verification.

    7.8k GitHub stars~2.9k tokensUpdated 1 mo ago
    Auto-check passed
  • Handle cascading data retrieval tool failures by falling back to embedded knowledge generation

    7.8k GitHub stars~765 tokensUpdated 1 mo ago
    Auto-check passed
  • Gives an agent a workaround when its code-execution sandbox keeps failing: save the Python script to a file and run it through the shell instead.

    7.8k GitHub stars~588 tokensUpdated 1 mo ago
    Auto-check passed
  • A recovery routine for agents whose sandboxed code runner keeps failing: save the Python script to disk, then run it through the shell and read the output.

    7.8k GitHub stars~652 tokensUpdated 1 mo ago
    Auto-check passed
  • Fallback ladder for failed sandboxed code runs, plus the habit of fixing the working directory first so generated files land in the right place.

    7.8k GitHub stars~1.1k tokensUpdated 1 mo ago
    Auto-check passed
  • Fallback workflow for executing Python code when executecodesandbox fails repeatedly

    7.8k GitHub stars~1.1k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Document Gen Resilient

What does Document Gen Resilient do?

Multi-path document generation with tool checks, Unicode handling, and Python fallbacks. Document Gen Resilient is an agent skill from HKUDS/OpenSpace.

When should I use Document Gen Resilient?

Document Gen Resilient fits situations like: tasks that involve PDF.

How do I install Document Gen Resilient in Claude Code?

Run `npx skills add HKUDS/OpenSpace --skill document-gen-resilient -a claude-code`. Or copy the skill folder (benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-96865f in HKUDS/OpenSpace) into .claude/skills/document-gen-resilient in your project. Claude Code loads it when a task matches its description.

How do I install Document Gen Resilient in Codex?

Run `npx skills add HKUDS/OpenSpace --skill document-gen-resilient -a codex`. Or copy the skill folder (benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced-96865f in HKUDS/OpenSpace) into .agents/skills/document-gen-resilient in your project. Codex loads it when a task matches its description.

Can I use Document Gen Resilient in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add HKUDS/OpenSpace --skill document-gen-resilient -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/document-gen-resilient, .gemini/skills/document-gen-resilient, .github/skills/document-gen-resilient and .opencode/skills/document-gen-resilient in your project.

What does Document Gen Resilient need to run?

Going by SKILL.md and its folder, Document Gen Resilient needs the command-line tools its instructions call (pandoc, apt-get, python3 and brew). Our summary lists: Python 3.

Does Document Gen Resilient access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Document Gen Resilient safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Document Gen Resilient use?

Document Gen Resilient is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Document Gen Resilient use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Document Gen Resilient?

Skills that share tags, products or a category with Document Gen Resilient: Mineru (Nebutra/MinerU-Skill, 122 stars), Pandic Office (Team-Commonly/commonly, 1.4k stars), Article Format Adjustment (aipoch/medical-research-skills, 2k stars) and Mineru (Nebutra/MinerU-Skill, 122 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Document Gen Resilient?

HKUDS (a GitHub organization) maintains it in HKUDS/OpenSpace, which has 7,750 GitHub stars. The repository holds 199 skills in this directory. The repository was last updated on August 12, 2026.

Source: HKUDS/OpenSpace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.