[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KKCG6THQZMPY1SMMCJ2D9Q":3,"skill-same:01M6KKCG6THQZMPY1SMMCJ2D9Q":79},{"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":27,"publishedAt":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":13,"repositoryHtmlUrl":55,"repositoryHomepageUrl":6,"ownerHtmlUrl":56,"ownerBlogUrl":6,"ownerDescription":57,"updatedAt":58,"install":59,"resources":72},"01M6KKCG6THQZMPY1SMMCJ2D9Q","large-file-write-via-temp-script",null,"Reliable fallback technique for writing large or special-character-heavy file content when inline write_file or shell_agent calls fail with unknown errors — uses a Python helper script written to a temp file to avoid escaping and truncation pitfalls.","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Flarge-file-write-via-temp-script\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000036","内容创作者","PROFESSION","适用职业",[28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"large file write via temp script","file","write","via","script","helper","unknown","inline","for","calls","pitfalls","errors","with","writing","character","fallback","shell","content","python","2026-11-10 10:12:30",false,"---\nname: large-file-write-via-temp-script\ndescription: Reliable fallback technique for writing large or special-character-heavy file content when inline write_file or shell_agent calls fail with unknown errors — uses a Python helper script written to a temp file to avoid escaping and truncation pitfalls.\n---\n\n# Large File Write via Temp Script\n\n## Problem\n\nWriting large files — especially TypeScript, TSX, or any content containing\nUnicode emoji, backticks, `${}` template literals, or multi-line heredoc\nconflicts — can silently fail or truncate content when passed inline.\n\n**Failure modes observed:**\n- `write_file` returns `[ERROR] unknown error` on large payloads\n- `node -e '...'` with backtick template literals silently empties the target file\n- `python3 -c '...'` breaks on unescaped quotes or special characters\n- `shell_agent` may time out or fail when the inline content is too large\n\n---\n\n## Solution: Write a Python Script to a Temp File First\n\nInstead of passing file content inline, write a small Python helper script to\n`\u002Ftmp\u002Fwrite_task.py` (or similar), then execute it. The helper script holds\nthe target file content as a raw Python string or via base64 decoding.\n\n---\n\n## Approach A — Python Triple-Quoted String (preferred for readability)\n\nUse `write_file` or a heredoc to create the helper, then run it:\n\n```bash\n# Step 1: Write the helper script to \u002Ftmp\ncat > \u002Ftmp\u002Fwrite_task.py \u003C\u003C 'PYEOF'\nimport pathlib\n\ncontent = r\"\"\"\n\u002F\u002F Your TypeScript \u002F file content goes here\n\u002F\u002F Backticks `like this`, ${template} literals, and emoji ? are all safe\nexport const MyComponent = () => {\n  const msg = `Hello, world!`;\n  return \u003Cdiv>{msg}\u003C\u002Fdiv>;\n};\n\"\"\"\n\npathlib.Path(\"\u002Fpath\u002Fto\u002Ftarget\u002Ffile.ts\").write_text(content.lstrip(\"\\n\"), encoding=\"utf-8\")\nprint(\"Written successfully.\")\nPYEOF\n\n# Step 2: Execute the helper\npython3 \u002Ftmp\u002Fwrite_task.py\n```\n\n> **Why `r\"\"\"`?** A raw triple-quoted string avoids all backslash escaping\n> issues. The only content that cannot appear verbatim is `\"\"\"` itself — if\n> needed, split the string or escape that sequence only.\n\n---\n\n## Approach B — Base64-Encoded Content (most robust for binary\u002Fcomplex content)\n\nWhen the content contains `\"\"\"` or other Python string edge cases:\n\n```bash\n# Step 1: Base64-encode your content (done once, outside the target system)\n# python3 -c \"import base64; print(base64.b64encode(open('file.ts').read().encode()).decode())\"\n\n# Step 2: Embed the base64 blob in the helper script\ncat > \u002Ftmp\u002Fwrite_task.py \u003C\u003C 'PYEOF'\nimport base64, pathlib\n\nb64 = (\n    \"aW1wb3J0IFJlYWN0IGZyb20gJ3JlYWN0JzsKCmV4cG9ydCBjb25zdCBNeUNvbXBvbmVudCA9\"\n    \"ICgpID0+IHsKICByZXR1cm4gPGRpdj5IZWxsbzwvZGl2PjsKfTsK\"\n    # ... more lines if needed\n)\n\ncontent = base64.b64decode(b64).decode(\"utf-8\")\npathlib.Path(\"\u002Fpath\u002Fto\u002Ftarget\u002Ffile.ts\").write_text(content, encoding=\"utf-8\")\nprint(f\"Written {len(content)} bytes successfully.\")\nPYEOF\n\npython3 \u002Ftmp\u002Fwrite_task.py\n```\n\n---\n\n## Approach C — shell_agent Delegation (simplest for agents)\n\nAsk `shell_agent` to perform the write using the temp-script pattern:\n\n> \"Write the following TypeScript content to `\u002Fsrc\u002Fcomponents\u002FMyPanel.ts`.\n> Do NOT use `node -e` or inline Python. Instead write a Python script to\n> `\u002Ftmp\u002Fwrite_panel.py` using a triple-quoted raw string, then execute it.\"\n\n---\n\n## Decision Guide\n\n| Situation | Recommended Approach |\n|---|---|\n| Content has backticks \u002F `${}` template literals | Approach A (raw `r\"\"\"`) |\n| Content has `\"\"\"` sequences | Approach B (base64) |\n| Content is binary or non-UTF-8 | Approach B (base64) |\n| Delegating to shell_agent | Approach C with explicit instructions |\n| Quick small file | Direct `write_file` (no workaround needed) |\n\n---\n\n## Anti-Patterns to Avoid\n\n```bash\n# ❌ DANGEROUS — backtick template literals will break node -e\nnode -e \"const fs = require('fs'); fs.writeFileSync('out.ts', \\`${content}\\`);\"\n\n# ❌ FRAGILE — breaks on unescaped quotes and special characters\npython3 -c \"open('out.ts','w').write('${content}')\"\n\n# ❌ UNRELIABLE for large payloads — may silently truncate\necho \"${large_content}\" > out.ts\n```\n\n---\n\n## Verification Step\n\nAlways verify the write succeeded:\n\n```bash\n# Check file exists and has non-zero size\npython3 -c \"\nimport pathlib\np = pathlib.Path('\u002Fpath\u002Fto\u002Ftarget\u002Ffile.ts')\nassert p.exists() and p.stat().st_size > 0, f'Write failed: {p}'\nprint(f'OK — {p.stat().st_size} bytes written to {p}')\n\"\n```\n\n---\n\n## Notes\n\n- The temp script approach works for **any file type**: `.ts`, `.tsx`, `.js`, `.json`, `.md`, `.py`, etc.\n- Always `lstrip(\"\\n\")` the triple-quoted string to avoid a leading blank line.\n- For very large files (>50 KB), prefer base64 to avoid any risk of heredoc conflicts.\n- Clean up temp scripts after use: `rm \u002Ftmp\u002Fwrite_task.py`","# Large File Write via Temp Script\n\n## Problem\n\nWriting large files — especially TypeScript, TSX, or any content containing\nUnicode emoji, backticks, `${}` template literals, or multi-line heredoc\nconflicts — can silently fail or truncate content when passed inline.\n\n**Failure modes observed:**\n- `write_file` returns `[ERROR] unknown error` on large payloads\n- `node -e '...'` with backtick template literals silently empties the target file\n- `python3 -c '...'` breaks on unescaped quotes or special characters\n- `shell_agent` may time out or fail when the inline content is too large\n\n---\n\n## Solution: Write a Python Script to a Temp File First\n\nInstead of passing file content inline, write a small Python helper script to\n`\u002Ftmp\u002Fwrite_task.py` (or similar), then execute it. The helper script holds\nthe target file content as a raw Python string or via base64 decoding.\n\n---\n\n## Approach A — Python Triple-Quoted String (preferred for readability)\n\nUse `write_file` or a heredoc to create the helper, then run it:\n\n```bash\n# Step 1: Write the helper script to \u002Ftmp\ncat > \u002Ftmp\u002Fwrite_task.py \u003C\u003C 'PYEOF'\nimport pathlib\n\ncontent = r\"\"\"\n\u002F\u002F Your TypeScript \u002F file content goes here\n\u002F\u002F Backticks `like this`, ${template} literals, and emoji ? are all safe\nexport const MyComponent = () => {\n  const msg = `Hello, world!`;\n  return \u003Cdiv>{msg}\u003C\u002Fdiv>;\n};\n\"\"\"\n\npathlib.Path(\"\u002Fpath\u002Fto\u002Ftarget\u002Ffile.ts\").write_text(content.lstrip(\"\\n\"), encoding=\"utf-8\")\nprint(\"Written successfully.\")\nPYEOF\n\n# Step 2: Execute the helper\npython3 \u002Ftmp\u002Fwrite_task.py\n```\n\n> **Why `r\"\"\"`?** A raw triple-quoted string avoids all backslash escaping\n> issues. The only content that cannot appear verbatim is `\"\"\"` itself — if\n> needed, split the string or escape that sequence only.\n\n---\n\n## Approach B — Base64-Encoded Content (most robust for binary\u002Fcomplex content)\n\nWhen the content contains `\"\"\"` or other Python string edge cases:\n\n```bash\n# Step 1: Base64-encode your content (done once, outside the target system)\n# python3 -c \"import base64; print(base64.b64encode(open('file.ts').read().encode()).decode())\"\n\n# Step 2: Embed the base64 blob in the helper script\ncat > \u002Ftmp\u002Fwrite_task.py \u003C\u003C 'PYEOF'\nimport base64, pathlib\n\nb64 = (\n    \"aW1wb3J0IFJlYWN0IGZyb20gJ3JlYWN0JzsKCmV4cG9ydCBjb25zdCBNeUNvbXBvbmVudCA9\"\n    \"ICgpID0+IHsKICByZXR1cm4gPGRpdj5IZWxsbzwvZGl2PjsKfTsK\"\n    # ... more lines if needed\n)\n\ncontent = base64.b64decode(b64).decode(\"utf-8\")\npathlib.Path(\"\u002Fpath\u002Fto\u002Ftarget\u002Ffile.ts\").write_text(content, encoding=\"utf-8\")\nprint(f\"Written {len(content)} bytes successfully.\")\nPYEOF\n\npython3 \u002Ftmp\u002Fwrite_task.py\n```\n\n---\n\n## Approach C — shell_agent Delegation (simplest for agents)\n\nAsk `shell_agent` to perform the write using the temp-script pattern:\n\n> \"Write the following TypeScript content to `\u002Fsrc\u002Fcomponents\u002FMyPanel.ts`.\n> Do NOT use `node -e` or inline Python. Instead write a Python script to\n> `\u002Ftmp\u002Fwrite_panel.py` using a triple-quoted raw string, then execute it.\"\n\n---\n\n## Decision Guide\n\n| Situation | Recommended Approach |\n|---|---|\n| Content has backticks \u002F `${}` template literals | Approach A (raw `r\"\"\"`) |\n| Content has `\"\"\"` sequences | Approach B (base64) |\n| Content is binary or non-UTF-8 | Approach B (base64) |\n| Delegating to shell_agent | Approach C with explicit instructions |\n| Quick small file | Direct `write_file` (no workaround needed) |\n\n---\n\n## Anti-Patterns to Avoid\n\n```bash\n# ❌ DANGEROUS — backtick template literals will break node -e\nnode -e \"const fs = require('fs'); fs.writeFileSync('out.ts', \\`${content}\\`);\"\n\n# ❌ FRAGILE — breaks on unescaped quotes and special characters\npython3 -c \"open('out.ts','w').write('${content}')\"\n\n# ❌ UNRELIABLE for large payloads — may silently truncate\necho \"${large_content}\" > out.ts\n```\n\n---\n\n## Verification Step\n\nAlways verify the write succeeded:\n\n```bash\n# Check file exists and has non-zero size\npython3 -c \"\nimport pathlib\np = pathlib.Path('\u002Fpath\u002Fto\u002Ftarget\u002Ffile.ts')\nassert p.exists() and p.stat().st_size > 0, f'Write failed: {p}'\nprint(f'OK — {p.stat().st_size} bytes written to {p}')\n\"\n```\n\n---\n\n## Notes\n\n- The temp script approach works for **any file type**: `.ts`, `.tsx`, `.js`, `.json`, `.md`, `.py`, etc.\n- Always `lstrip(\"\\n\")` the triple-quoted string to avoid a leading blank line.\n- For very large files (>50 KB), prefer base64 to avoid any risk of heredoc conflicts.\n- Clean up temp scripts after use: `rm \u002Ftmp\u002Fwrite_task.py`",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","showcase\u002Fskills\u002Flarge-file-write-via-temp-script","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 about 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":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add AG064\u002FOpenSpace --skill large-file-write-via-temp-script",{"tool":65,"command":66},"bunx","bunx skills add AG064\u002FOpenSpace --skill large-file-write-via-temp-script",{"tool":68,"command":69},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill large-file-write-via-temp-script","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Flarge-file-write-via-temp-script\u002FSKILL.md",true,[73],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},".skill_id","OTHER","其他",46,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Flarge-file-write-via-temp-script\u002F.skill_id",[80,98,112,120,148,164],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":47},"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",[],[87,88,30,89,90,91,36,39,32,92,93,94,95,96,29,46,97],"write special chars ts check","check","filters","Existing","type-checking","output","type","files","only","template","typescript",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":47},"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",[],[105,106,30,96,107,108,29,46,109,110,31,111,33,36,32,40],"readback","write special chars readback","cleanup","read","scripts","verification","post",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":47},"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",[],[30,119,46,36,31,96,44,29,32],"write special chars heredoc",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":129,"publishedAt":47},"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",[126],{"categoryNo":127,"categoryName":128,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000033","数据分析师",[130,131,132,133,97,134,135,136,137,138,36,139,140,141,142,143,144,145,146,147],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":149,"name":150,"nameZh":6,"description":151,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":152,"categories":153,"keywords":154,"publishedAt":47},"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",[],[155,156,157,158,36,159,40,160,161,162,163],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":165,"name":166,"nameZh":6,"description":167,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":168,"categories":169,"keywords":170,"publishedAt":47},"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",[],[171,172,173,174,175,176,29,177,178,179],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]