[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KFD262CG01ZM3MVEXNQ13R":3,"skill-same:01M6KFD262CG01ZM3MVEXNQ13R":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":29,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":14,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":53,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M6KFD262CG01ZM3MVEXNQ13R","document-gen-dual-backend",null,"Document generation with direct pandoc\u002FReportLab execution (lightweight default) and optional shell_agent fallback for complex scenarios","xyliu-cs\u002FOpenSpace-GDPval","xyliu-cs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F89236536?v=4","01M6KF8Z1V4TXS86CKSH48BY8T","xy","01M6KF8Z67443W0SHXM85JEF0B",0,"MIT","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f\u002FSKILL.md",[18,23,26],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[30,31,32,33,34,35,36,37,38,39,40,41,42],"backend","document","document gen dual backend","execution","shell","direct","fallback","default","generation","pandoc","document generation","with","for","2026-11-10 10:12:30",false,"---\nname: document-gen-dual-backend\ndescription: Document generation with direct pandoc\u002FReportLab execution (lightweight default) and optional shell_agent fallback for complex scenarios\n---\n\n# Document Generation: Dual-Backend Workflow (Unicode-Safe)\n\n## When to Use\n\n**Default Approach: Lightweight Direct Execution (Recommended for 90% of tasks)**\n\nFor most document generation tasks, use direct `write_file` + `run_shell` **without** `shell_agent`:\n- Generating documents in standard formats (`.docx`, `.pdf`, `.html`) from Markdown\n- Content is straightforward with minimal special characters\n- You already know the pandoc\u002FReportLab commands needed\n- Quick single-format or multi-format output is needed\n\n**Fallback Approach: shell_agent Delegation (For Complex Scenarios Only)**\n\nUse `shell_agent` delegation only when:\n- Automated fallback handling between backends requires complex logic\n- Dynamic content generation needs programmatic decision-making\n- You need to capture and analyze error messages for intelligent retry logic\n\n### When shell_agent May Be Useful (Optional)\n\nOnly consider `shell_agent` delegation for:\n- Complex error recovery requiring automated backend switching\n- Dynamic workflows with conditional branching based on generation results\n\n## Core Technique\n\n**For simple tasks (default):** Use direct `write_file` + `run_shell` with pandoc or ReportLab (no shell_agent needed)\n\n**For complex tasks requiring fallback logic:** Split the workflow into discrete, observable steps with **two PDF generation paths**:\n\n**Path A (Pandoc)**: Best for Markdown-to-PDF conversion with rich text formatting\n**Path B (ReportLab)**: Best for programmatic PDF generation without LaTeX dependencies\n\nWorkflow steps:\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Choose PDF backend** → Decide between pandoc (rich formatting) or ReportLab (programmatic control)\n3. **Unicode handling** → Apply sanitization for pandoc; ReportLab handles Unicode natively\n4. **Format conversion** → Use `run_shell` with appropriate commands for each format\n5. **Verification** → Check output files exist and are valid\n\n## ⚠️ Backend Selection Guide\n\n| Requirement | Recommended Backend | Rationale |\n|-------------|---------------------|-----------|\n| Markdown source with headers, lists, tables | **Pandoc** | Native Markdown parsing |\n| Heavy Unicode\u002Fspecial characters | **ReportLab** | Native UTF-8 support, no sanitization needed |\n| LaTeX not available | **ReportLab** | Pure Python, no external dependencies |\n| Precise layout control (positions, graphics) | **ReportLab** | Programmatic canvas control |\n| Quick DOCX + PDF + HTML batch | **Pandoc** | Single tool, multiple outputs |\n| Tables with complex formatting | **Pandoc** | Better table rendering |\n| Dynamic\u002Fcharts\u002Fgraphs in PDF | **ReportLab** | Drawing operations support |\n\n## Unicode & LaTeX Compatibility Warning\n\n**Critical for Pandoc Path**: PDF generation via pandoc typically uses LaTeX (`pdflatex` or `xelatex`), which has limited Unicode support. Common problematic characters include:\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | May not render | `--` or `-` |\n| `–` (en dash) | May not render | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight quotes) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `★` `●` (symbols) | May not render | `*` `-` |\n| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |\n| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |\n\n**ReportLab Path**: Handles Unicode natively. Pass content as UTF-8 strings; no character sanitization required.\n\n## Step-by-Step Workflow\n\n### Quick Start: Lightweight Direct Execution (Default for Most Tasks)\n\n**This is the recommended approach for most document generation tasks. No shell_agent delegation needed:**\n\n```\n# Step 1: Write Markdown content\nwrite_file\npath: \u002Ftmp\u002Fdoc.md\ncontent: |\n  # My Document\n  \n  Simple content here.\n\n# Step 2: Convert with pandoc (direct)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc.md -o output.docx\n\n# Step 3: Verify\nrun_shell\ncommand: ls -lh output.docx\n```\n\n**For PDF with potential Unicode issues:**\n\n```\n# Create sanitized version if needed\nwrite_file\npath: \u002Ftmp\u002Fdoc_sanitized.md\ncontent: |\n  # My Document\n  Content with safe ASCII characters only.\n\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc_sanitized.md -o output.pdf\n```\n\n**For Unicode-heavy content (use ReportLab directly):**\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgen.py\ncontent: |\n  from reportlab.platypus import SimpleDocTemplate, Paragraph\n  from reportlab.lib.styles import getSampleStyleSheet\n  doc = SimpleDocTemplate(\"output.pdf\")\n  styles = getSampleStyleSheet()\n  story = [Paragraph(\"Unicode: é ñ ü 日本語\", styles[\"Normal\"])]\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Fgen.py\n```\n\n---\n\n### Full Workflow: Dual-Backend with Fallback (For Complex Cases)\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here...\n  \n  ## Section 2\n  More content...\n```\n\n### Step 2A: Pandoc Path - Sanitize Unicode (Pre-PDF Conversion)\n\n**Before PDF conversion with pandoc**, create a sanitized version:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here... (with all special chars replaced per table above)\n```\n\n### Step 2B: ReportLab Path - Create Python Script\n\nFor ReportLab, create a Python script that generates PDF directly:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgenerate_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\n  from reportlab.lib import colors\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Create PDF\n  doc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Add content\n  story.append(Paragraph(\"Document Title\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"Section 1 content with Unicode: é ñ ü → ✓ …\", styles[\"Normal\"]))\n  \n  # Build PDF\n  doc.build(story)\n```\n\n### Step 3: Convert to Target Formats\n\n#### Option A: Pandoc Conversion (Use sanitized source for PDF)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n#### Option B: ReportLab Conversion (Direct PDF generation)\n\n```\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_pdf.py\n```\n\nThen use pandoc for other formats from original source:\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n### Step 4: Verify Outputs\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html\n```\n\n## Complete Examples\n\n### Example 1: Pandoc-First Approach\n\n```markdown\n# Generate Report with Pandoc\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Freport.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 2: Create sanitized version for PDF\nwrite_file\npath: \u002Ftmp\u002Freport_sanitized.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.docx\n\n## Step 4: Convert to PDF (from sanitized)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport_sanitized.md -o quarterly_report.pdf\n\n## Step 5: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh quarterly_report.*\n```\n\n### Example 2: ReportLab-First Approach (Heavy Unicode)\n\n```markdown\n# Generate Unicode-Heavy Document with ReportLab\n\n## Step 1: Write Markdown source (for DOCX\u002FHTML)\nwrite_file\npath: \u002Ftmp\u002Fintl_report.md\ncontent: |\n  # International Market Analysis\n  \n  ## Région EMEA\n  Performance in Europe: ↑ 12%\n  Markets: Deutschland, França, España\n  \n  ## Région APAC\n  Growth: ✓ Exceeded targets\n  Key: 日本，中国，한국\n\n## Step 2: Create ReportLab Python script for PDF\nwrite_file\npath: \u002Ftmp\u002Fgenerate_intl_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.lib import colors\n  \n  doc = SimpleDocTemplate(\"intl_analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Title - Unicode handled natively\n  story.append(Paragraph(\"International Market Analysis\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  \n  # EMEA Section\n  story.append(Paragraph(\"Région EMEA\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Performance in Europe: ↑ 12%\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Markets: Deutschland, França, España\", styles[\"Normal\"]))\n  story.append(Spacer(1, 12))\n  \n  # APAC Section\n  story.append(Paragraph(\"Région APAC\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Growth: ✓ Exceeded targets\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Key: 日本，中国，한국\", styles[\"Normal\"]))\n  \n  doc.build(story)\n\n## Step 3: Generate PDF with ReportLab\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_intl_pdf.py\n\n## Step 4: Generate DOCX with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.docx\n\n## Step 5: Generate HTML with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh intl_analysis.*\n```\n\n### Example 3: Hybrid Approach with Fallback\n\n```markdown\n# Generate with Pandoc, Fallback to ReportLab\n\n## Step 1: Create source document\nwrite_file\npath: \u002Ftmp\u002Fanalysis.md\ncontent: |\n  # Analysis Document\n  [Content...]\n\n## Step 2: Try pandoc first\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fanalysis.md -o analysis.pdf\n\n## Step 3: If pandoc fails, use ReportLab fallback\n[If Step 2 returns error...]\nwrite_file\npath: \u002Ftmp\u002Ffallback_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Register Unicode font if needed\n  # pdfmetrics.registerFont(TTFont('UnicodeFont', '\u002Fpath\u002Fto\u002Ffont.ttf'))\n  \n  doc = SimpleDocTemplate(\"analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  story.append(Paragraph(\"Analysis Document\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"[Content from analysis.md parsed here]\", styles[\"Normal\"]))\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Ffallback_pdf.py\n```\n\n## Common pandoc Commands\n\n```bash\n# Markdown to Word\npandoc input.md -o output.docx\n\n# Markdown to PDF (requires LaTeX)\npandoc input.md -o output.pdf\n\n# Markdown to PDF with Unicode-safe engine (better Unicode support)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with wkhtmltopdf (alternative, no LaTeX)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With custom template\npandoc input.md --template=template.html -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n```\n\n## Common ReportLab Patterns\n\n```python\n# Basic PDF creation\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\nfrom reportlab.lib.styles import getSampleStyleSheet\n\ndoc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = []\nstory.append(Paragraph(\"Title\", styles[\"Heading1\"]))\nstory.append(Spacer(1, 12))\nstory.append(Paragraph(\"Content\", styles[\"Normal\"]))\ndoc.build(story)\n\n# With tables\nfrom reportlab.platypus import Table, TableStyle\nfrom reportlab.lib import colors\n\ndata = [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]\ntable = Table(data)\ntable.setStyle(TableStyle([\n    ('BACKGROUND', (0, 0), (-1, 0), colors.grey),\n    ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),\n    ('GRID', (0, 0), (-1, -1), 0.5, colors.black),\n]))\nstory.append(table)\n\n# With custom fonts for Unicode\nfrom reportlab.pdfbase import pdfmetrics\nfrom reportlab.pdfbase.ttfonts import TTFont\n\npdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\ncustom_style = ParagraphStyle('Custom', fontName='NotoSans', fontSize=12)\nstory.append(Paragraph(\"Unicode: 日本語 العربية\", custom_style))\n```\n\n## Troubleshooting\n\n### Pandoc Issues\n\n- **PDF generation fails with encoding error**: \n  - Use the sanitized markdown file\n  - Try `--pdf-engine=xelatex` for better Unicode support\n  - Try `--pdf-engine=wkhtmltopdf` as alternative\n\n- **PDF generation fails: LaTeX not found**: \n  - Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`\n  - **Switch to ReportLab backend** (no LaTeX needed)\n\n- **DOCX formatting issues**: Add `--reference-doc=template.docx` for custom styles\n\n- **Missing pandoc**: Install via `apt-get install pandoc` or `brew install pandoc`\n\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n\n- **Unicode characters not rendering**: \n  - ReportLab handles UTF-8 natively - ensure Python script uses UTF-8\n  - For CJK\u002FArabic\u002Fetc., register a Unicode-capable font:\n    ```python\n    from reportlab.pdfbase import pdfmetrics\n    from reportlab.pdfbase.ttfonts import TTFont\n    pdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\n    ```\n\n- **Complex layouts needed**: Use `reportlab.lib.canvas` for direct drawing operations\n\n- **Tables breaking across pages**: Use `reportlab.platypus.LongTable` instead of `Table`\n\n### General Issues\n\n- **Unicode\u002Fencoding errors in any format**: \n  - Add `-f markdown+utf8` to pandoc command\n  - Ensure source file is UTF-8 encoded: `file -i source.md`\n\n- **Special characters not rendering in PDF**: \n  - For pandoc: Use character replacement table or ReportLab\n  - For ReportLab: Register appropriate Unicode fonts\n\n## Installation Commands\n\n```bash\n# Install pandoc\napt-get install pandoc  # Debian\u002FUbuntu\nbrew install pandoc     # macOS\n\n# Install LaTeX (for pdflatex)\napt-get install texlive-latex-recommended texlive-fonts-recommended\n\n# Install wkhtmltopdf (alternative PDF engine)\napt-get install wkhtmltopdf\n\n# Install ReportLab\npip install reportlab\n\n# Install fonts for Unicode support\napt-get install fonts-noto-core  # Comprehensive Unicode font\n```\n\n## Unicode Sanitization Script (For Pandoc Path)\n\nFor repeated use with pandoc, create a reusable sanitization script:\n\n```bash\n#!\u002Fbin\u002Fbash\n# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX\u002FPDF\nif [ -z \"$1\" ]; then\n  echo \"Usage: $0 \u003Cinput.md> [output.md]\"\n  exit 1\nfi\nINPUT=\"$1\"\nOUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n\nsed -e 's\u002F—\u002F--\u002Fg' \\\n    -e 's\u002F–\u002F-\u002Fg' \\\n    -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' \\\n    -e \"s\u002F'([^']*)'\u002F\\1'\u002Fg\" \\\n    -e 's\u002F…\u002F...\u002Fg' \\\n    -e 's\u002F→\u002F->\u002Fg' \\\n    -e 's\u002F←\u002F\u003C-\u002Fg' \\\n    -e 's\u002F✓\u002F[x]\u002Fg' \\\n    -e 's\u002F✗\u002F[ ]\u002Fg' \\\n    -e 's\u002F©\u002F(c)\u002Fg' \\\n    -e 's\u002F®\u002F(r)\u002Fg' \\\n    -e 's\u002F™\u002F(tm)\u002Fg' \\\n    \"$INPUT\" > \"$OUTPUT\"\n\necho \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\nSave as `sanitize_for_pdf.sh`, make executable with `chmod +x sanitize_for_pdf.sh`, then use:\n\n```\nrun_shell\ncommand: .\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n## Decision Flowchart\n\n```\nNeed PDF generation?\n    │\n    ├─ Heavy Unicode\u002Fsymbols? ──YES──> Use ReportLab\n    │         │\n    │         NO\n    │         │\n    ├─ LaTeX available? ──NO──> Use ReportLab\n    │         │\n    │         YES\n    │         │\n    ├─ Need Markdown formatting? ──YES──> Use Pandoc (with sanitization)\n    │         │\n    │         NO\n    │         │\n    └─ Need programmatic layout? ──YES──> Use ReportLab\n```\n\n## When to Return to shell_agent\n\nAfter 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 or when LaTeX is unavailable, prefer the ReportLab path.\n\n## Related Skills\n\n- `document-gen-unicode-safe`: Parent skill with pandoc-only approach\n- `document-gen-fallback`: Original fallback workflow without Unicode guidance\n- Use this skill when you need flexible PDF generation with multiple backend options\n### Example 0: Lightweight Single-Format Generation\n\n```markdown\n# Quick DOCX Generation (No shell_agent needed)\n\n## Step 1: Write content\nwrite_file\npath: \u002Ftmp\u002Fbrief.md\ncontent: |\n  # Meeting Notes\n  \n  ## Attendees\n  - Alice\n  - Bob\n  \n  ## Decisions\n  Project approved.\n\n## Step 2: Convert directly\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fbrief.md -o meeting_notes.docx\n\n## Step 3: Verify\nrun_shell\ncommand: ls -lh meeting_notes.docx\n```\n\n---\n\n### Example 1: Pandoc-First Approach (Multi-Format with Sanitization)\n\n### Example 2: ReportLab-First Approach (Heavy Unicode — Direct Execution)\n\n## Mode Selection Quick Reference\n\n| Scenario | Recommended Mode | Why |\n|----------|------------------|-----|\n| Simple Markdown → DOCX | **Lightweight** | Direct pandoc call is fastest |\n| Single PDF from ASCII content | **Lightweight** | No sanitization needed |\n| Multi-format batch (DOCX + PDF + HTML) | **Full Workflow** | Coordinated conversion with error handling |\n| Content with Unicode\u002Fsymbols | **Lightweight + ReportLab** | Direct Python script avoids LaTeX issues |\n| Uncertain about LaTeX availability | **Full Workflow** | Built-in fallback detection |\n| Need programmatic layout control | **Full Workflow** | ReportLab integration with fallback logic |\n| Production pipeline with error recovery | **Full Workflow** | Automated retry and backend switching |\n\n---\n\n## Troubleshooting\n\n- **Missing reportlab**: Install\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n","# Document Generation: Dual-Backend Workflow (Unicode-Safe)\n\n## When to Use\n\n**Default Approach: Lightweight Direct Execution (Recommended for 90% of tasks)**\n\nFor most document generation tasks, use direct `write_file` + `run_shell` **without** `shell_agent`:\n- Generating documents in standard formats (`.docx`, `.pdf`, `.html`) from Markdown\n- Content is straightforward with minimal special characters\n- You already know the pandoc\u002FReportLab commands needed\n- Quick single-format or multi-format output is needed\n\n**Fallback Approach: shell_agent Delegation (For Complex Scenarios Only)**\n\nUse `shell_agent` delegation only when:\n- Automated fallback handling between backends requires complex logic\n- Dynamic content generation needs programmatic decision-making\n- You need to capture and analyze error messages for intelligent retry logic\n\n### When shell_agent May Be Useful (Optional)\n\nOnly consider `shell_agent` delegation for:\n- Complex error recovery requiring automated backend switching\n- Dynamic workflows with conditional branching based on generation results\n\n## Core Technique\n\n**For simple tasks (default):** Use direct `write_file` + `run_shell` with pandoc or ReportLab (no shell_agent needed)\n\n**For complex tasks requiring fallback logic:** Split the workflow into discrete, observable steps with **two PDF generation paths**:\n\n**Path A (Pandoc)**: Best for Markdown-to-PDF conversion with rich text formatting\n**Path B (ReportLab)**: Best for programmatic PDF generation without LaTeX dependencies\n\nWorkflow steps:\n1. **Content creation** → Use `write_file` to create source document (Markdown)\n2. **Choose PDF backend** → Decide between pandoc (rich formatting) or ReportLab (programmatic control)\n3. **Unicode handling** → Apply sanitization for pandoc; ReportLab handles Unicode natively\n4. **Format conversion** → Use `run_shell` with appropriate commands for each format\n5. **Verification** → Check output files exist and are valid\n\n## ⚠️ Backend Selection Guide\n\n| Requirement | Recommended Backend | Rationale |\n|-------------|---------------------|-----------|\n| Markdown source with headers, lists, tables | **Pandoc** | Native Markdown parsing |\n| Heavy Unicode\u002Fspecial characters | **ReportLab** | Native UTF-8 support, no sanitization needed |\n| LaTeX not available | **ReportLab** | Pure Python, no external dependencies |\n| Precise layout control (positions, graphics) | **ReportLab** | Programmatic canvas control |\n| Quick DOCX + PDF + HTML batch | **Pandoc** | Single tool, multiple outputs |\n| Tables with complex formatting | **Pandoc** | Better table rendering |\n| Dynamic\u002Fcharts\u002Fgraphs in PDF | **ReportLab** | Drawing operations support |\n\n## Unicode & LaTeX Compatibility Warning\n\n**Critical for Pandoc Path**: PDF generation via pandoc typically uses LaTeX (`pdflatex` or `xelatex`), which has limited Unicode support. Common problematic characters include:\n\n| Character | Issue | Safe Replacement |\n|-----------|-------|------------------|\n| `—` (em dash) | May not render | `--` or `-` |\n| `–` (en dash) | May not render | `-` |\n| `\" \"` (curly quotes) | Encoding errors | `\" \"` (straight quotes) |\n| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |\n| `…` (ellipsis) | May not render | `...` |\n| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `\u003C-` `^` `v` |\n| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |\n| `★` `●` (symbols) | May not render | `*` `-` |\n| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |\n| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |\n\n**ReportLab Path**: Handles Unicode natively. Pass content as UTF-8 strings; no character sanitization required.\n\n## Step-by-Step Workflow\n\n### Quick Start: Lightweight Direct Execution (Default for Most Tasks)\n\n**This is the recommended approach for most document generation tasks. No shell_agent delegation needed:**\n\n```\n# Step 1: Write Markdown content\nwrite_file\npath: \u002Ftmp\u002Fdoc.md\ncontent: |\n  # My Document\n  \n  Simple content here.\n\n# Step 2: Convert with pandoc (direct)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc.md -o output.docx\n\n# Step 3: Verify\nrun_shell\ncommand: ls -lh output.docx\n```\n\n**For PDF with potential Unicode issues:**\n\n```\n# Create sanitized version if needed\nwrite_file\npath: \u002Ftmp\u002Fdoc_sanitized.md\ncontent: |\n  # My Document\n  Content with safe ASCII characters only.\n\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdoc_sanitized.md -o output.pdf\n```\n\n**For Unicode-heavy content (use ReportLab directly):**\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgen.py\ncontent: |\n  from reportlab.platypus import SimpleDocTemplate, Paragraph\n  from reportlab.lib.styles import getSampleStyleSheet\n  doc = SimpleDocTemplate(\"output.pdf\")\n  styles = getSampleStyleSheet()\n  story = [Paragraph(\"Unicode: é ñ ü 日本語\", styles[\"Normal\"])]\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Fgen.py\n```\n\n---\n\n### Full Workflow: Dual-Backend with Fallback (For Complex Cases)\n\n### Step 1: Create Source Content with write_file\n\nWrite your document content as Markdown to a temporary source file:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here...\n  \n  ## Section 2\n  More content...\n```\n\n### Step 2A: Pandoc Path - Sanitize Unicode (Pre-PDF Conversion)\n\n**Before PDF conversion with pandoc**, create a sanitized version:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fdocument_source_sanitized.md\ncontent: |\n  # Document Title\n  \n  ## Section 1\n  Content here... (with all special chars replaced per table above)\n```\n\n### Step 2B: ReportLab Path - Create Python Script\n\nFor ReportLab, create a Python script that generates PDF directly:\n\n```\nwrite_file\npath: \u002Ftmp\u002Fgenerate_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\n  from reportlab.lib import colors\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Create PDF\n  doc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Add content\n  story.append(Paragraph(\"Document Title\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"Section 1 content with Unicode: é ñ ü → ✓ …\", styles[\"Normal\"]))\n  \n  # Build PDF\n  doc.build(story)\n```\n\n### Step 3: Convert to Target Formats\n\n#### Option A: Pandoc Conversion (Use sanitized source for PDF)\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source_sanitized.md -o output.pdf\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n#### Option B: ReportLab Conversion (Direct PDF generation)\n\n```\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_pdf.py\n```\n\nThen use pandoc for other formats from original source:\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.docx\n```\n\n```\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fdocument_source.md -o output.html\n```\n\n### Step 4: Verify Outputs\n\n```\nrun_shell\ncommand: ls -lh output.docx output.pdf output.html\n```\n\n## Complete Examples\n\n### Example 1: Pandoc-First Approach\n\n```markdown\n# Generate Report with Pandoc\n\n## Step 1: Write Markdown source\nwrite_file\npath: \u002Ftmp\u002Freport.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 2: Create sanitized version for PDF\nwrite_file\npath: \u002Ftmp\u002Freport_sanitized.md\ncontent: |\n  # Quarterly Report\n  \n  ## Executive Summary\n  Performance improved by 15% this quarter...\n  \n  ## Key Metrics\n  - Revenue: $1.2M\n  - Growth: +15%\n  - Customers: 500+\n\n## Step 3: Convert to DOCX (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.docx\n\n## Step 4: Convert to PDF (from sanitized)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport_sanitized.md -o quarterly_report.pdf\n\n## Step 5: Convert to HTML (from original)\nrun_shell\ncommand: pandoc \u002Ftmp\u002Freport.md -o quarterly_report.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh quarterly_report.*\n```\n\n### Example 2: ReportLab-First Approach (Heavy Unicode)\n\n```markdown\n# Generate Unicode-Heavy Document with ReportLab\n\n## Step 1: Write Markdown source (for DOCX\u002FHTML)\nwrite_file\npath: \u002Ftmp\u002Fintl_report.md\ncontent: |\n  # International Market Analysis\n  \n  ## Région EMEA\n  Performance in Europe: ↑ 12%\n  Markets: Deutschland, França, España\n  \n  ## Région APAC\n  Growth: ✓ Exceeded targets\n  Key: 日本，中国，한국\n\n## Step 2: Create ReportLab Python script for PDF\nwrite_file\npath: \u002Ftmp\u002Fgenerate_intl_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.lib import colors\n  \n  doc = SimpleDocTemplate(\"intl_analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  \n  # Title - Unicode handled natively\n  story.append(Paragraph(\"International Market Analysis\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  \n  # EMEA Section\n  story.append(Paragraph(\"Région EMEA\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Performance in Europe: ↑ 12%\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Markets: Deutschland, França, España\", styles[\"Normal\"]))\n  story.append(Spacer(1, 12))\n  \n  # APAC Section\n  story.append(Paragraph(\"Région APAC\", styles[\"Heading2\"]))\n  story.append(Paragraph(\"Growth: ✓ Exceeded targets\", styles[\"Normal\"]))\n  story.append(Paragraph(\"Key: 日本，中国，한국\", styles[\"Normal\"]))\n  \n  doc.build(story)\n\n## Step 3: Generate PDF with ReportLab\nrun_shell\ncommand: python \u002Ftmp\u002Fgenerate_intl_pdf.py\n\n## Step 4: Generate DOCX with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.docx\n\n## Step 5: Generate HTML with pandoc\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fintl_report.md -o intl_analysis.html\n\n## Step 6: Verify\nrun_shell\ncommand: ls -lh intl_analysis.*\n```\n\n### Example 3: Hybrid Approach with Fallback\n\n```markdown\n# Generate with Pandoc, Fallback to ReportLab\n\n## Step 1: Create source document\nwrite_file\npath: \u002Ftmp\u002Fanalysis.md\ncontent: |\n  # Analysis Document\n  [Content...]\n\n## Step 2: Try pandoc first\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fanalysis.md -o analysis.pdf\n\n## Step 3: If pandoc fails, use ReportLab fallback\n[If Step 2 returns error...]\nwrite_file\npath: \u002Ftmp\u002Ffallback_pdf.py\ncontent: |\n  from reportlab.lib.pagesizes import letter\n  from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\n  from reportlab.lib.styles import getSampleStyleSheet\n  from reportlab.pdfbase import pdfmetrics\n  from reportlab.pdfbase.ttfonts import TTFont\n  \n  # Register Unicode font if needed\n  # pdfmetrics.registerFont(TTFont('UnicodeFont', '\u002Fpath\u002Fto\u002Ffont.ttf'))\n  \n  doc = SimpleDocTemplate(\"analysis.pdf\", pagesize=letter)\n  styles = getSampleStyleSheet()\n  story = []\n  story.append(Paragraph(\"Analysis Document\", styles[\"Heading1\"]))\n  story.append(Spacer(1, 12))\n  story.append(Paragraph(\"[Content from analysis.md parsed here]\", styles[\"Normal\"]))\n  doc.build(story)\n\nrun_shell\ncommand: python \u002Ftmp\u002Ffallback_pdf.py\n```\n\n## Common pandoc Commands\n\n```bash\n# Markdown to Word\npandoc input.md -o output.docx\n\n# Markdown to PDF (requires LaTeX)\npandoc input.md -o output.pdf\n\n# Markdown to PDF with Unicode-safe engine (better Unicode support)\npandoc input.md -o output.pdf --pdf-engine=xelatex\n\n# Markdown to PDF with wkhtmltopdf (alternative, no LaTeX)\npandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf\n\n# Markdown to HTML\npandoc input.md -o output.html\n\n# With custom template\npandoc input.md --template=template.html -o output.html\n\n# With metadata\npandoc input.md -o output.pdf --metadata title=\"Document Title\"\n```\n\n## Common ReportLab Patterns\n\n```python\n# Basic PDF creation\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer\nfrom reportlab.lib.styles import getSampleStyleSheet\n\ndoc = SimpleDocTemplate(\"output.pdf\", pagesize=letter)\nstyles = getSampleStyleSheet()\nstory = []\nstory.append(Paragraph(\"Title\", styles[\"Heading1\"]))\nstory.append(Spacer(1, 12))\nstory.append(Paragraph(\"Content\", styles[\"Normal\"]))\ndoc.build(story)\n\n# With tables\nfrom reportlab.platypus import Table, TableStyle\nfrom reportlab.lib import colors\n\ndata = [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]\ntable = Table(data)\ntable.setStyle(TableStyle([\n    ('BACKGROUND', (0, 0), (-1, 0), colors.grey),\n    ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),\n    ('GRID', (0, 0), (-1, -1), 0.5, colors.black),\n]))\nstory.append(table)\n\n# With custom fonts for Unicode\nfrom reportlab.pdfbase import pdfmetrics\nfrom reportlab.pdfbase.ttfonts import TTFont\n\npdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\ncustom_style = ParagraphStyle('Custom', fontName='NotoSans', fontSize=12)\nstory.append(Paragraph(\"Unicode: 日本語 العربية\", custom_style))\n```\n\n## Troubleshooting\n\n### Pandoc Issues\n\n- **PDF generation fails with encoding error**: \n  - Use the sanitized markdown file\n  - Try `--pdf-engine=xelatex` for better Unicode support\n  - Try `--pdf-engine=wkhtmltopdf` as alternative\n\n- **PDF generation fails: LaTeX not found**: \n  - Install LaTeX: `apt-get install texlive-latex-recommended texlive-fonts-recommended`\n  - **Switch to ReportLab backend** (no LaTeX needed)\n\n- **DOCX formatting issues**: Add `--reference-doc=template.docx` for custom styles\n\n- **Missing pandoc**: Install via `apt-get install pandoc` or `brew install pandoc`\n\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n\n- **Unicode characters not rendering**: \n  - ReportLab handles UTF-8 natively - ensure Python script uses UTF-8\n  - For CJK\u002FArabic\u002Fetc., register a Unicode-capable font:\n    ```python\n    from reportlab.pdfbase import pdfmetrics\n    from reportlab.pdfbase.ttfonts import TTFont\n    pdfmetrics.registerFont(TTFont('NotoSans', 'NotoSans-Regular.ttf'))\n    ```\n\n- **Complex layouts needed**: Use `reportlab.lib.canvas` for direct drawing operations\n\n- **Tables breaking across pages**: Use `reportlab.platypus.LongTable` instead of `Table`\n\n### General Issues\n\n- **Unicode\u002Fencoding errors in any format**: \n  - Add `-f markdown+utf8` to pandoc command\n  - Ensure source file is UTF-8 encoded: `file -i source.md`\n\n- **Special characters not rendering in PDF**: \n  - For pandoc: Use character replacement table or ReportLab\n  - For ReportLab: Register appropriate Unicode fonts\n\n## Installation Commands\n\n```bash\n# Install pandoc\napt-get install pandoc  # Debian\u002FUbuntu\nbrew install pandoc     # macOS\n\n# Install LaTeX (for pdflatex)\napt-get install texlive-latex-recommended texlive-fonts-recommended\n\n# Install wkhtmltopdf (alternative PDF engine)\napt-get install wkhtmltopdf\n\n# Install ReportLab\npip install reportlab\n\n# Install fonts for Unicode support\napt-get install fonts-noto-core  # Comprehensive Unicode font\n```\n\n## Unicode Sanitization Script (For Pandoc Path)\n\nFor repeated use with pandoc, create a reusable sanitization script:\n\n```bash\n#!\u002Fbin\u002Fbash\n# sanitize_for_pdf.sh - Replace problematic unicode chars for LaTeX\u002FPDF\nif [ -z \"$1\" ]; then\n  echo \"Usage: $0 \u003Cinput.md> [output.md]\"\n  exit 1\nfi\nINPUT=\"$1\"\nOUTPUT=\"${2:-${1%.md}_sanitized.md}\"\n\nsed -e 's\u002F—\u002F--\u002Fg' \\\n    -e 's\u002F–\u002F-\u002Fg' \\\n    -e 's\u002F\"([^\"]*)\"\u002F\"\\1\"\u002Fg' \\\n    -e \"s\u002F'([^']*)'\u002F\\1'\u002Fg\" \\\n    -e 's\u002F…\u002F...\u002Fg' \\\n    -e 's\u002F→\u002F->\u002Fg' \\\n    -e 's\u002F←\u002F\u003C-\u002Fg' \\\n    -e 's\u002F✓\u002F[x]\u002Fg' \\\n    -e 's\u002F✗\u002F[ ]\u002Fg' \\\n    -e 's\u002F©\u002F(c)\u002Fg' \\\n    -e 's\u002F®\u002F(r)\u002Fg' \\\n    -e 's\u002F™\u002F(tm)\u002Fg' \\\n    \"$INPUT\" > \"$OUTPUT\"\n\necho \"Sanitized: $INPUT -> $OUTPUT\"\n```\n\nSave as `sanitize_for_pdf.sh`, make executable with `chmod +x sanitize_for_pdf.sh`, then use:\n\n```\nrun_shell\ncommand: .\u002Fsanitize_for_pdf.sh \u002Ftmp\u002Fdocument_source.md \u002Ftmp\u002Fdocument_source_sanitized.md\n```\n\n## Decision Flowchart\n\n```\nNeed PDF generation?\n    │\n    ├─ Heavy Unicode\u002Fsymbols? ──YES──> Use ReportLab\n    │         │\n    │         NO\n    │         │\n    ├─ LaTeX available? ──NO──> Use ReportLab\n    │         │\n    │         YES\n    │         │\n    ├─ Need Markdown formatting? ──YES──> Use Pandoc (with sanitization)\n    │         │\n    │         NO\n    │         │\n    └─ Need programmatic layout? ──YES──> Use ReportLab\n```\n\n## When to Return to shell_agent\n\nAfter 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 or when LaTeX is unavailable, prefer the ReportLab path.\n\n## Related Skills\n\n- `document-gen-unicode-safe`: Parent skill with pandoc-only approach\n- `document-gen-fallback`: Original fallback workflow without Unicode guidance\n- Use this skill when you need flexible PDF generation with multiple backend options\n### Example 0: Lightweight Single-Format Generation\n\n```markdown\n# Quick DOCX Generation (No shell_agent needed)\n\n## Step 1: Write content\nwrite_file\npath: \u002Ftmp\u002Fbrief.md\ncontent: |\n  # Meeting Notes\n  \n  ## Attendees\n  - Alice\n  - Bob\n  \n  ## Decisions\n  Project approved.\n\n## Step 2: Convert directly\nrun_shell\ncommand: pandoc \u002Ftmp\u002Fbrief.md -o meeting_notes.docx\n\n## Step 3: Verify\nrun_shell\ncommand: ls -lh meeting_notes.docx\n```\n\n---\n\n### Example 1: Pandoc-First Approach (Multi-Format with Sanitization)\n\n### Example 2: ReportLab-First Approach (Heavy Unicode — Direct Execution)\n\n## Mode Selection Quick Reference\n\n| Scenario | Recommended Mode | Why |\n|----------|------------------|-----|\n| Simple Markdown → DOCX | **Lightweight** | Direct pandoc call is fastest |\n| Single PDF from ASCII content | **Lightweight** | No sanitization needed |\n| Multi-format batch (DOCX + PDF + HTML) | **Full Workflow** | Coordinated conversion with error handling |\n| Content with Unicode\u002Fsymbols | **Lightweight + ReportLab** | Direct Python script avoids LaTeX issues |\n| Uncertain about LaTeX availability | **Full Workflow** | Built-in fallback detection |\n| Need programmatic layout control | **Full Workflow** | ReportLab integration with fallback logic |\n| Production pipeline with error recovery | **Full Workflow** | Automated retry and backend switching |\n\n---\n\n## Troubleshooting\n\n- **Missing reportlab**: Install\n### ReportLab Issues\n\n- **Missing reportlab**: Install via `pip install reportlab`\n",{"name":5,"description":7},"main","af1b40a42167d09c30b3a63000aa14ace4c1e229","gdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs","https:\u002F\u002Fxyliu-cs.github.io","PhD Student in CS, CUHK-Shenzhen.","2026-04-06 20:32:15",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add xyliu-cs\u002FOpenSpace-GDPval --skill document-gen-dual-backend",{"tool":62,"command":63},"bunx","bunx skills add xyliu-cs\u002FOpenSpace-GDPval --skill document-gen-dual-backend",{"tool":65,"command":66},"pnpm","pnpm dlx skills add xyliu-cs\u002FOpenSpace-GDPval --skill document-gen-dual-backend","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f\u002FSKILL.md",true,[70],{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},".skill_id","OTHER","其他",60,"https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdocument-gen-fallback-enhanced-enhanced-9f3b1f\u002F.skill_id",[77,90,98,112,137,153],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":43},"01M6KG8MF1S664SWBDENYRSCK8","zip-export-deliverable","Ensures codebase deliverables are properly exported as ZIP archives through a dedicated finalization step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-export-deliverable\u002FSKILL.md",[],[84,85,86,87,88,89],"zip export deliverable","zip","export","deliverables","codebase","as",{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":43},"01M6KG8GAZWHHEK7VNJDW0ME21","zip-deliverable-finalization","Ensure codebase deliverables are properly packaged as ZIP exports in a dedicated final step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-deliverable-finalization\u002FSKILL.md",[],[97,85,87,88,89],"zip deliverable finalization",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":43},"01M6KG8CMQQ1PYMNTSRZ9VS1MD","zero-iteration-failure-analysis","Identify and handle agent failures with 0 iterations as pre-execution system issues","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzero-iteration-failure-analysis\u002FSKILL.md",[],[105,106,107,108,109,41,110,33,89,111],"failure analysis","ZeRO","analysis","iteration","zero iteration failure analysis","issues","system",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":123,"publishedAt":43},"01M6KG86W3PA07FT9W58YHHERM","write-file-fallback-report","Generate professional documents using write_file when primary data sources fail, leveraging embedded domain knowledge instead of external retrieval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report\u002FSKILL.md",[118],{"categoryNo":119,"categoryName":120,"taxonomyType":121,"taxonomyTypeDesc":122},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[36,124,125,126,127,128,129,130,131,132,133,134,135,136],"write","file","report","write file fallback report","domain","professional","sources","retrieval","generate","embedded","documents","data","knowledge",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":144,"publishedAt":43},"01M6KG82GAEY3GG77CMGCK1C2T","fallback-doc-with-delegation","Generate professional documents after tool failures using shell_agent for complex formats or write_file for simple text\u002Fmarkdown","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced\u002FSKILL.md",[143],{"categoryNo":27,"categoryName":28,"taxonomyType":21,"taxonomyTypeDesc":22},[145,41,36,146,147,34,134,132,125,148,149,150,124,151,129,152,42],"fallback doc with delegation","doc","delegation","markdown","tool","text","simple","formats",{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":157,"categories":158,"keywords":160,"publishedAt":43},"01M6KG7WT7GX5NYCGEFHW22NV7","context-anchored-fallback-report","Generate documents with write_file when retrieval tools fail, with explicit guardrails against task context drift","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced-4bc5c2\u002FSKILL.md",[159],{"categoryNo":119,"categoryName":120,"taxonomyType":121,"taxonomyTypeDesc":122},[36,126,161,162,132,125,163,164,124,165,166,131,41,167,134],"context","context anchored fallback report","Guardrails","Tools","task","drift","context drift"]