document-gen-resilient-workflow
Skill này làm gì
Skill này là phương pháp từng bước để tạo tài liệu Word, PDF hoặc HTML, có phương án dự phòng và chi tiết lỗi. Dành cho người có tác vụ tài liệu liên tục thất bại với lỗi không rõ nguyên nhân.
Khi nào nên dùng
- ✓Khi một lệnh shell trả về lỗi không rõ với không có chi tiết hữu ích.
- ✓Khi PDF thất bại vì thiếu LaTeX engine hoặc có lỗi mã hóa.
- ✓Khi việc tạo tài liệu đã thất bại nhiều lần với các công việc tương tự.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced-enhanced/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tạo PDF của tôi liên tục thất bại với một lỗi không rõ. Hãy kiểm tra các công cụ, thử engine khác và cho tôi biết đã sai ở đâu.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI kiểm tra thư mục làm việc và các công cụ, viết nội dung, ghi lại đầu ra lỗi, thử các PDF engine theo thứ tự cho đến khi một engine chạy được, rồi xác nhận tệp đầu ra đọc được.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Resilient Document Generation Workflow
When to Use
Use this skill when document generation tasks encounter tool errors or failures, especially:
run_shellcommands 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_agenthas failed multiple times on similar tasks
Core Technique
Split document generation into observable, verifiable steps with explicit error capture and progressive fallback:
- Validate workspace → Confirm current directory and write permissions
- Pre-flight checks → Verify required tools (pandoc, LaTeX engines) are available
- Content creation → Use
write_filefor source Markdown with full visibility - Unicode sanitization → Preprocess for PDF conversion when needed
- Progressive conversion → Try multiple engines/methods until one succeeds
- Explicit error capture → Redirect stderr to diagnose failures
- 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
Câu hỏi thường gặp
Công cụ nào được kiểm tra trước?
AI kiểm tra pandoc và các LaTeX engine trước khi chuyển đổi.
Vì sao phải ghi lại đầu ra lỗi?
Chi tiết lỗi cho thấy nguyên nhân thật, nên AI không phải đoán.
Nếu thư mục là nguyên nhân thì sao?
Hướng dẫn yêu cầu kiểm tra thư mục hiện tại và quyền ghi trước khi chuyển đổi.
Chi tiết
Mô tả gốc của tác giả
Robust document generation with engine fallback chain, error diagnostics, and Python alternatives
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12862
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.