본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12862

document-gen-resilient-workflow

하는 일

이 스킬은 Word, PDF 또는 HTML 문서를 만드는 단계별 방법으로, 예비 방법과 오류 정보를 포함합니다. 알 수 없는 오류로 문서 작업이 계속 실패하는 사람에게 맞습니다.

사용하는 경우

  • ✓셸 명령이 유용한 정보 없이 알 수 없는 오류를 반환할 때.
  • ✓LaTeX 엔진이 없거나 인코딩 문제 때문에 PDF가 실패할 때.
  • ✓비슷한 작업에서 문서 생성이 여러 번 실패한 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“PDF 만들기가 알 수 없는 오류로 계속 실패합니다. 도구를 확인하고 다른 엔진을 시도한 뒤, 무엇이 잘못됐는지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 변환 전에 작업 폴더와 도구를 확인하고, 내용을 쓰고, 오류 출력을 기록합니다. 작동할 때까지 PDF 엔진을 순서대로 시도한 뒤 결과 파일을 읽을 수 있는지 확인합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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:

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

### Check 3: Check LaTeX engines
run_shell
command: which pdflatex xelatex wkhtmltopdf 2>&1 || echo "Some engines missing"

### Check 4: Check Python libraries (fallback option)
run_shell
command: python3 -c "import fpdf; print('fpdf OK')" 2>&1 || echo "fpdf missing"
run_shell
command: python3 -c "import docx; print('python-docx OK')" 2>&1 || echo "python-docx missing"

Complete Step-by-Step Workflow

Step 1: Validate Workspace

Confirm you're in the correct directory and can write files:

run_shell
command: pwd && echo "Test write" > /tmp/workspace_test_$$.txt && ls -la /tmp/workspace_test_$$.txt && rm /tmp/workspace_test_$$.txt

If this fails, you may have directory permission issues. Use absolute paths for all files.

Step 2: Create Source Content with write_file

Write document content as Markdown to a source file:

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

Step 3: Unicode Sanitization (PDF Only)

Only needed for PDF conversion via LaTeX engines. DOCX and HTML handle Unicode natively.

Create a sanitized version replacing LaTeX-problematic characters:

write_file
path: /tmp/document_source_sanitized.md
content: |
  # Document Title
  
  [Same content with: em-dash → --, curly quotes → straight, → arrows → text, etc.]

Common replacements (see full table below):

Original Replace With
— (em dash) --
" " (curly quotes) " " (straight)
… (ellipsis) ...
→ ← (arrows) -> <-
✓ ✗ [x] [ ]
© ® ™ (c) (r) (tm)

Alternative: Use sanitization script (see Scripts section below).

Step 4: Progressive Format Conversion

Try multiple methods in order of preference. Capture stderr explicitly for diagnosis.

Method A: DOCX Conversion (Most Reliable)

run_shell
command: pandoc /tmp/document_source.md -o output.docx 2>&1 && echo "SUCCESS" || echo "FAILED: $?"

If this fails, try with explicit UTF-8 flag:

run_shell
command: pandoc /tmp/document_source.md -f markdown+utf8 -o output.docx 2>&1

Method B: PDF Conversion (Progressive Fallback)

Try engines in this order until one succeeds:

run_shell
command: pandoc /tmp/document_source_sanitized.md -o output.pdf 2>&1 | tee /tmp/pdf_error.log && echo "PDF SUCCESS"

If Method B fails, check error log and try next engine:

run_shell
command: pandoc /tmp/document_source_sanitized.md --pdf-engine=xelatex -o output.pdf 2>&1 | tee 
자주 묻는 질문

먼저 어떤 도구를 확인하나요?

변환 전에 pandoc과 LaTeX 엔진이 있는지 확인합니다.

오류 출력을 기록하는 이유는 무엇인가요?

오류 상세 정보가 실제 원인을 보여 주므로 AI가 추측하지 않아도 됩니다.

폴더에 문제가 있으면 어떻게 하나요?

변환 전에 현재 폴더와 쓰기 권한을 확인하라고 가이드가 안내합니다.

상세 정보

작성자의 원본 설명

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

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12862
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬