Agent skill

Document Gen Unicode Safe

by HKUDS in HKUDS/OpenSpace

Unicode-safe fallback workflow for multi-format document generation with character sanitization and explicit error capture

MITAuto-check passedDocuments & Office

Install Document Gen Unicode Safe

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

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

GitHub CLI
$ gh skill install HKUDS/OpenSpace document-gen-unicode-safe --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 .claude/skills/document-gen-unicode-safe && 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-unicode-safe
GitHub stars
7.8k
Token cost
~2.6k tokens
SKILL.md length
838 words
Files
2
Skills in repo
199
Repo updated
First seen
Licence
MIT

At a glance

Unicode-safe fallback workflow for multi-format document generation with character sanitization and explicit error capture

  • Works in 4 steps: Create Source Content with write_file → Sanitize Unicode Characters (Pre-PDF… → Convert to Target Formats with run_shell → …
  • Tasks that involve PDF
  • SKILL.md covers When to Use, Core Technique, ⚠️ Unicode & LaTeX… and Step-by-Step Workflow, plus 7 more sections
  • Calls pandoc, apt-get and brew

What it does

Document Gen Unicode Safe is an agent skill from HKUDS/OpenSpace. Unicode-safe fallback workflow for multi-format document generation with character sanitization and explicit error capture

Its SKILL.md is about 2.6k 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 and LaTeX. It works with LaTeX and Pandoc. 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
  • Tasks that involve LaTeX

Example prompts

  • “/document-gen-unicode-safe”

Workflow steps

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

  1. Create Source Content with write_file
  2. Sanitize Unicode Characters (Pre-PDF Conversion)
  3. Convert to Target Formats with run_shell
  4. 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
    • 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 Unicode Safe loads about 2.6k tokens when it runs. Until then it costs about 37 tokens; SKILL.md has 838 words of instructions outside code blocks.

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

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). 838 words, ~2,622 tokens.

Download SKILL.mdSave it as .claude/skills/document-gen-unicode-safe/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
document-gen-unicode-safe
description
Unicode-safe fallback workflow for multi-format document generation with character sanitization and explicit error capture

Document Generation Fallback Workflow (Unicode-Safe)

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 to handle special characters, symbols, or non-ASCII text safely
  • PDF generation fails due to LaTeX encoding issues

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. Unicode sanitization → Preprocess markdown to replace problematic characters before PDF conversion
  3. Format conversion with stderr capture → Use run_shell with pandoc for each target format, capturing full stderr output
  4. Verification → Check output files exist and are valid

⚠️ Unicode & LaTeX Compatibility Warning

Critical: PDF generation via pandoc typically uses LaTeX (pdflatex or xelatex), which has limited Unicode support. Common problematic characters include:

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] [ ]
★ ● (symbols)May not render* -
© ® ™May require packages(c) (r) (tm)
Non-ASCII letters (é, ñ, ü)Font-dependentUse xeLaTeX or replace

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: Sanitize Unicode Characters (Pre-PDF Conversion)

Before PDF conversion, create a sanitized version of your markdown with LaTeX-safe characters:

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

Alternative: Use a shell script to sanitize:

run_shell
command: sed -e 's/—/--/g' -e 's/–/-/g' -e 's/"([^"]*)"/"\1"/g' -e 's/'([^']*)/'\1'/g' /tmp/document_source.md > /tmp/document_source_sanitized.md

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 pandoc commands for each format. Use sanitized source for PDF, original for other formats.

Critical: Always capture stderr output (2>&1) to diagnose failures before retrying with alternative engines.

run_shell
command: pandoc /tmp/document_source.md -o output.docx
run_shell
command: pandoc /tmp/document_source.md -o output.html
Step 3a: PDF Conversion - Try xelatex First (Best Unicode Support)

Use xelatex as the first engine - it has better Unicode support and is commonly available in containerized environments:

run_shell
command: pandoc /tmp/document_source_sanitized.md --pdf-engine=xelatex -o output.pdf 2>&1
Step 3b: If xelatex Fails - Capture Full Error and Retry with wkhtmltopdf

Before retrying, examine the full stderr output from Step 3a to understand the failure cause (missing engine, font issues, etc.). Then try wkhtmltopdf as fallback:

run_shell
command: pandoc /tmp/document_source_sanitized.md --pdf-engine=wkhtmltopdf -o output.pdf 2>&1
Step 4: Verify Outputs

Check that files were created successfully:

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

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 with original unicode...]
  
  ## Resolution Path
  [Content...]
  
  ## BATNA Analysis
  [Content...]

## Step 2: Create sanitized version for PDF
write_file
path: /tmp/negotiation_strategy_sanitized.md
content: |
  # Negotiation Strategy
  
  ## Executive Summary
  [Content with unicode replaced: em-dash -> --, curly quotes -> straight, etc.]
  
  ## Resolution Path
  [Content...]
  
  ## BATNA Analysis
  [Content...]

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

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

## Step 5: Convert to PDF (try xelatex first, capture stderr)
run_shell
command: pandoc /tmp/negotiation_strategy_sanitized.md --pdf-engine=xelatex -o negotiation_strategy.pdf 2>&1

## Step 6: If xelatex fails, retry with wkhtmltopdf (after examining error)
run_shell
command: pandoc /tmp/negotiation_strategy_sanitized.md --pdf-engine=wkhtmltopdf -o negotiation_strategy.pdf 2>&1

## 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
ControlAgent decides approachYou control each conversion
Stderr captureOften lost in retriesExplicit 2>&1 capture at each step

Common pandoc Commands

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

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

# Markdown to PDF with wkhtmltopdf (fallback if xelatex unavailable)
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"
Show full SKILL.md (365 more words)Show less

Troubleshooting

  • PDF generation fails with encoding error:

    • Use the sanitized markdown file (Step 2)
    • Try xelatex first (better Unicode support, more common in containers): --pdf-engine=xelatex
    • Capture full stderr with 2>&1 and examine the error before retrying
    • Then retry with wkhtmltopdf as fallback: --pdf-engine=wkhtmltopdf
  • PDF generation fails: LaTeX not found:

    • Install LaTeX: apt-get install texlive-latex-recommended texlive-fonts-recommended
    • Preferred: Use --pdf-engine=xelatex (often pre-installed in containers)
    • Fallback: Use --pdf-engine=wkhtmltopdf if xelatex unavailable
  • xelatex not found: Install with apt-get install texlive-xetex or use wkhtmltopdf fallback

  • wkhtmltopdf not found: Install with apt-get install wkhtmltopdf

  • DOCX formatting issues: Add --reference-doc=template.docx for custom styles

  • Unicode/encoding errors in any format:

    • Add -f markdown+utf8 to pandoc command
    • Ensure source file is UTF-8 encoded: file -i source.md
  • Special characters not rendering in PDF:

    • Use the character replacement table above
    • Create sanitized version before PDF conversion
    • Use xelatex engine for better Unicode font support
  • Missing pandoc: Install via apt-get install pandoc or brew install pandoc

  • Engine failures not diagnosed: Always append 2>&1 to capture stderr, examine output before retrying with different engine

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

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, consider always using the manual workflow with sanitization.

  • document-gen-fallback: Original fallback workflow without Unicode guidance
  • Use this skill when your documents contain special characters, symbols, or non-ASCII text that may cause LaTeX/PDF conversion issues Return to shell_agent in these scenarios:
  1. Environment diagnostics fail - If pandoc or PDF engines are unavailable and installation isn't possible
  2. Multiple tools returning 'unknown error' - Suggests broader environment issue; shell_agent may have different access
  3. After successful manual completion - For similar future tasks, try shell_agent first with this workflow as fallback
  4. Simple documents - For straightforward documents without complex Unicode, shell_agent is often sufficient
  5. Time-sensitive tasks - When you need quick results and can accept some formatting uncertainty

For documents with heavy Unicode content, consider always using the manual workflow with sanitization, but only after confirming the toolchain is available.

© 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 of HKUDS/OpenSpace.

  • SKILL.md
  • .skill_id

Open the folder on GitHubat commit 3827781

Compare with similar skills

Document Gen Unicode Safe 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 Unicode Safe compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Document Gen Unicode Safe this skillHKUDS/OpenSpace7.8k—~2.6kAutomated safety check: PassMIT
Md To PDFMathews-Tom/armory328—~2.4kAutomated safety check: PassMIT
Md To PDF Academicwentorai/research-plugins2981 repos~1.8kAutomated safety check: NotesMIT
Harness Book Best Practicewquguru/harness-books3.2k—~4.1kAutomated safety check: PassNone
AI Review SkillNeuroDong/Ai-Review626—~2.5kAutomated safety check: PassMIT
MineruNebutra/MinerU-Skill122—~504Automated safety check: PassMIT

Similar skills

  • Md To PDF

    Mathews-Tom/armory

    Convert Markdown to styled PDFs with Mermaid diagrams, LaTeX/KaTeX math, tables, and code highlighting.

    328 GitHub stars~2.4k tokensUpdated 3 days ago
    Documents & OfficeAuto-check passed
  • Md To PDF Academic

    wentorai/research-plugins

    Convert Markdown to publication-quality PDF with LaTeX math rendering

    298 GitHub starsUsed in 1 repo~1.8k tokens
    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
  • AI Review Skill

    NeuroDong/Ai-Review

    Generates structured AI paper reviews (SoT style) for LaTeX, PDF, and Word manuscripts.

    626 GitHub stars~2.5k tokensUpdated 1 mo ago
    Documents & OfficeAuto-check passed
  • 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
  • Lecture To Md

    ysyecust/lecture-to-notes

    把课堂视频(本地或 B 站/YouTube)、文字稿、课件三者(任意组合)整理成一份详细的中文 Markdown 课堂笔记,输出按课程标题命名的 {titlename}.md(首行为 文档标题)+ 相对路径图片。Markdown 工作流,与上游 lecture-to-notes 的 LaTeX/PDF 输出并行存在;上游 skill 完全不动。触发词:markdown 笔记、md 笔记、视频转…

    273 GitHub stars~3.9k tokensUpdated 6 days 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

Works with

Questions about Document Gen Unicode Safe

What does Document Gen Unicode Safe do?

Unicode-safe fallback workflow for multi-format document generation with character sanitization and explicit error capture. Document Gen Unicode Safe is an agent skill from HKUDS/OpenSpace.

When should I use Document Gen Unicode Safe?

Document Gen Unicode Safe fits situations like: tasks that involve PDF; tasks that involve LaTeX.

How do I install Document Gen Unicode Safe in Claude Code?

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

How do I install Document Gen Unicode Safe in Codex?

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

Can I use Document Gen Unicode Safe 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-unicode-safe -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-unicode-safe, .gemini/skills/document-gen-unicode-safe, .github/skills/document-gen-unicode-safe and .opencode/skills/document-gen-unicode-safe in your project.

What does Document Gen Unicode Safe need to run?

Going by SKILL.md and its folder, Document Gen Unicode Safe needs the command-line tools its instructions call (pandoc, apt-get and brew).

Does Document Gen Unicode Safe 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 Unicode Safe 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 Unicode Safe use?

Document Gen Unicode Safe 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 Unicode Safe use?

About 2.6k tokens (SKILL.md is roughly 10k 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 Unicode Safe?

Skills that share tags, products or a category with Document Gen Unicode Safe: Md To PDF (Mathews-Tom/armory, 328 stars), Md To PDF Academic (wentorai/research-plugins, 298 stars), Harness Book Best Practice (wquguru/harness-books, 3.2k stars) and AI Review Skill (NeuroDong/Ai-Review, 626 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Document Gen Unicode Safe?

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.