[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KJV2XMDS6ZRKQNPDFVB2KP":3,"skill-same:01M6KJV2XMDS6ZRKQNPDFVB2KP":64},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":22,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":35,"frontMatter":36,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":13,"repositoryHtmlUrl":40,"repositoryHomepageUrl":6,"ownerHtmlUrl":41,"ownerBlogUrl":6,"ownerDescription":42,"updatedAt":43,"install":44,"resources":57},"01M6KJV2XMDS6ZRKQNPDFVB2KP","python-heredoc-fallback",null,"Use shell Python heredoc as fallback when code sandbox fails","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpython-heredoc-fallback\u002FSKILL.md",[17],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",[23,24,25,26,27,28,29,30,31],"python","fallback","python heredoc fallback","sandbox","code","shell","use","as","shell python heredoc","2026-11-10 10:12:30",false,"---\nname: python-heredoc-fallback\ndescription: Use shell Python heredoc as fallback when code sandbox fails\n---\n\n# Python Heredoc Fallback for Code Execution\n\n## When to Use\n\nUse this pattern when `execute_code_sandbox` fails with e2b initialization errors, sandbox connection issues, or other execution environment problems. This is especially reliable for file generation tasks.\n\n## Core Pattern\n\nInstead of `execute_code_sandbox`, run Python code directly in the shell using a heredoc:\n\n```bash\npython3 \u003C\u003C 'EOF'\n# Your Python code here\nimport sys\nprint(\"Python code executing in shell\")\nEOF\n```\n\n## Key Syntax Rules\n\n1. **Use single-quoted EOF** (`\u003C\u003C 'EOF'`) to prevent shell variable expansion within the Python code\n2. **No indentation before EOF** - the closing delimiter must be at the start of the line\n3. **Install packages first** if needed, before the Python heredoc block\n\n## Common Use Cases\n\n### 1. Matplotlib Graph Generation\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\n# Load data\ndata = pd.read_excel('input.xlsx')\n\n# Create visualization\nplt.figure(figsize=(10, 6))\nplt.plot(data['x'], data['y'])\nplt.xlabel('X Label')\nplt.ylabel('Y Label')\nplt.title('Graph Title')\nplt.savefig('output_graph.png', dpi=300, bbox_inches='tight')\nplt.close()\n\nprint(\"Graph saved successfully\")\nEOF\n```\n\n### 2. Python-docx Document Creation\n\n```bash\npip install python-docx -q\n\npython3 \u003C\u003C 'EOF'\nfrom docx import Document\nfrom docx.shared import Inches, Pt\nfrom docx.enum.text import WD_ALIGN_PARAGRAPH\n\ndoc = Document()\n\n# Add title\ntitle = doc.add_heading('Document Title', 0)\ntitle.alignment = WD_ALIGN_PARAGRAPH.CENTER\n\n# Add sections\ndoc.add_heading('Section 1', level=1)\ndoc.add_paragraph('Content for section 1.')\n\n# Add table\ntable = doc.add_table(rows=3, cols=3)\ntable.style = 'Table Grid'\n\n# Save document\ndoc.save('output.docx')\nprint(\"Document created successfully\")\nEOF\n```\n\n### 3. General File Operations\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport json\nimport os\n\n# Read input file\nwith open('input.json', 'r') as f:\n    data = json.load(f)\n\n# Process data\nresult = {'processed': True, 'items': len(data)}\n\n# Write output\nwith open('output.json', 'w') as f:\n    json.dump(result, f, indent=2)\n\nprint(f\"Processed {result['items']} items\")\nEOF\n```\n\n## Best Practices\n\n1. **Install dependencies first**: Run `pip install package-name -q` before the Python block if packages aren't guaranteed to be available\n2. **Verify file paths**: Files are read from and written to the current working directory\n3. **Add print statements**: Include progress\u002Foutput messages to verify execution succeeded\n4. **Close resources**: Explicitly close matplotlib figures and file handles\n5. **Handle errors gracefully**: Add try\u002Fexcept blocks for production code\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Module not found | Add `pip install \u003Cmodule> -q` before Python block |\n| File not found | Verify file exists in current directory with `ls` |\n| Permission denied | Check file permissions and directory write access |\n| Syntax errors | Ensure proper Python indentation within heredoc |\n\n## Advantages Over execute_code_sandbox\n\n- **No initialization overhead** - runs immediately in existing shell\n- **Persistent environment** - maintains state across multiple commands\n- **Direct file system access** - no sandbox isolation issues\n- **Full system Python** - access to all installed packages\n- **Reliable for large files** - no sandbox size restrictions","# Python Heredoc Fallback for Code Execution\n\n## When to Use\n\nUse this pattern when `execute_code_sandbox` fails with e2b initialization errors, sandbox connection issues, or other execution environment problems. This is especially reliable for file generation tasks.\n\n## Core Pattern\n\nInstead of `execute_code_sandbox`, run Python code directly in the shell using a heredoc:\n\n```bash\npython3 \u003C\u003C 'EOF'\n# Your Python code here\nimport sys\nprint(\"Python code executing in shell\")\nEOF\n```\n\n## Key Syntax Rules\n\n1. **Use single-quoted EOF** (`\u003C\u003C 'EOF'`) to prevent shell variable expansion within the Python code\n2. **No indentation before EOF** - the closing delimiter must be at the start of the line\n3. **Install packages first** if needed, before the Python heredoc block\n\n## Common Use Cases\n\n### 1. Matplotlib Graph Generation\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\n# Load data\ndata = pd.read_excel('input.xlsx')\n\n# Create visualization\nplt.figure(figsize=(10, 6))\nplt.plot(data['x'], data['y'])\nplt.xlabel('X Label')\nplt.ylabel('Y Label')\nplt.title('Graph Title')\nplt.savefig('output_graph.png', dpi=300, bbox_inches='tight')\nplt.close()\n\nprint(\"Graph saved successfully\")\nEOF\n```\n\n### 2. Python-docx Document Creation\n\n```bash\npip install python-docx -q\n\npython3 \u003C\u003C 'EOF'\nfrom docx import Document\nfrom docx.shared import Inches, Pt\nfrom docx.enum.text import WD_ALIGN_PARAGRAPH\n\ndoc = Document()\n\n# Add title\ntitle = doc.add_heading('Document Title', 0)\ntitle.alignment = WD_ALIGN_PARAGRAPH.CENTER\n\n# Add sections\ndoc.add_heading('Section 1', level=1)\ndoc.add_paragraph('Content for section 1.')\n\n# Add table\ntable = doc.add_table(rows=3, cols=3)\ntable.style = 'Table Grid'\n\n# Save document\ndoc.save('output.docx')\nprint(\"Document created successfully\")\nEOF\n```\n\n### 3. General File Operations\n\n```bash\npython3 \u003C\u003C 'EOF'\nimport json\nimport os\n\n# Read input file\nwith open('input.json', 'r') as f:\n    data = json.load(f)\n\n# Process data\nresult = {'processed': True, 'items': len(data)}\n\n# Write output\nwith open('output.json', 'w') as f:\n    json.dump(result, f, indent=2)\n\nprint(f\"Processed {result['items']} items\")\nEOF\n```\n\n## Best Practices\n\n1. **Install dependencies first**: Run `pip install package-name -q` before the Python block if packages aren't guaranteed to be available\n2. **Verify file paths**: Files are read from and written to the current working directory\n3. **Add print statements**: Include progress\u002Foutput messages to verify execution succeeded\n4. **Close resources**: Explicitly close matplotlib figures and file handles\n5. **Handle errors gracefully**: Add try\u002Fexcept blocks for production code\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Module not found | Add `pip install \u003Cmodule> -q` before Python block |\n| File not found | Verify file exists in current directory with `ls` |\n| Permission denied | Check file permissions and directory write access |\n| Syntax errors | Ensure proper Python indentation within heredoc |\n\n## Advantages Over execute_code_sandbox\n\n- **No initialization overhead** - runs immediately in existing shell\n- **Persistent environment** - maintains state across multiple commands\n- **Direct file system access** - no sandbox isolation issues\n- **Full system Python** - access to all installed packages\n- **Reliable for large files** - no sandbox size restrictions",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Fpython-heredoc-fallback","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace","https:\u002F\u002Fgithub.com\u002FAG064","AG064, E.Mi.\r\n\r\nA person who thinks all the time, yet all they have to think is nothing. I want to improve the world and work on open source projects","2026-10-08 06:53:48",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add AG064\u002FOpenSpace --skill python-heredoc-fallback",{"tool":50,"command":51},"bunx","bunx skills add AG064\u002FOpenSpace --skill python-heredoc-fallback",{"tool":53,"command":54},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill python-heredoc-fallback","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpython-heredoc-fallback\u002FSKILL.md",true,[58],{"path":59,"resourceType":60,"resourceTypeDesc":61,"sizeBytes":62,"sourceHtmlUrl":63},".skill_id","OTHER","其他",37,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fpython-heredoc-fallback\u002F.skill_id",[65,88,105,113,143,159],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":32},"01M6KKMPWA0B5SCCH766F8M5EA","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,23,87],"write special chars ts check","check","write","filters","Existing","type-checking","for","errors","script","output","type","files","only","template","file","typescript",{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":32},"01M6KKMJXVBNVEY3TRK055F4A7","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[95,96,74,85,97,98,86,23,99,100,101,102,103,78,80,104],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper","with",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":32},"01M6KKMEGX9M9NC105J0W3Q5B9","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[74,112,23,78,101,85,28,86,80],"write special chars heredoc",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":124,"publishedAt":32},"01M6KKM8EJ2AATVHZBNB916WT0","worldmonitor-reference","Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[119],{"categoryNo":120,"categoryName":121,"taxonomyType":122,"taxonomyTypeDesc":123},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[125,126,127,128,87,129,130,131,132,133,78,134,135,136,137,138,139,140,141,142],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":32},"01M6KKM39PHYK627F19GE2B9XN","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[150,151,152,153,78,154,104,155,156,157,158],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":32},"01M6KKKY7T2P61Y0JH54CDEJKQ","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[166,167,168,169,170,171,86,172,173,174],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]