[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KKKK4YG2P1DTA934C0B2Y9":3,"skill-same:01M6KKKK4YG2P1DTA934C0B2Y9":67},{"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":17,"publishedAt":35,"linkOnly":36,"markdownContent":37,"markdownBody":38,"frontMatter":39,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":13,"repositoryHtmlUrl":43,"repositoryHomepageUrl":6,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M6KKKK4YG2P1DTA934C0B2Y9","unicode-safe-file-writing",null,"How to reliably write files containing multi-byte Unicode (emoji, special symbols) when write_file fails with 'unknown error' by falling back to run_shell with a heredoc.","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\u002Funicode-safe-file-writing\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],"safe","unicode safe file writing","Unicode","file","writing","shell","how","write","files","back","emoji","how to","error","multi","run","with","unknown","2026-11-10 10:12:30",false,"---\nname: unicode-safe-file-writing\ndescription: How to reliably write files containing multi-byte Unicode (emoji, special symbols) when write_file fails with 'unknown error' by falling back to run_shell with a heredoc.\n---\n\n# Unicode-Safe File Writing\n\n## Problem\n\nThe `write_file` tool may fail with `'unknown error'` when the file content\ncontains multi-byte Unicode characters such as:\n\n- Emoji (e.g. `?`, `✅`, `❌`)\n- Special typographic symbols (e.g. `→`, `•`, `—`, `©`)\n- Non-ASCII characters outside the Latin-1 range\n\nThis is a known encoding limitation of `write_file`.\n\n## Solution\n\nFall back to `run_shell` and write the file using a **shell heredoc**\n(`cat > file \u003C\u003C 'EOF' ... EOF`). The single-quoted delimiter `'EOF'`\nprevents the shell from interpreting any special characters inside the\nblock.\n\n---\n\n## Step-by-Step Recovery\n\n### Step 1 — Detect the failure\n\nIf `write_file` returns an error such as:\n\n```\nError: unknown error\n```\n\nand the content contains non-ASCII characters, assume a Unicode encoding\nissue and proceed to the heredoc fallback.\n\n### Step 2 — Strip or replace problematic characters (if needed)\n\nBefore embedding content in the heredoc, decide whether to:\n\n- **Keep** the characters as-is (works if the shell\u002Fterminal is UTF-8 aware)\n- **Replace** emoji\u002Fsymbols with ASCII equivalents (safest, most portable)\n- **Remove** them entirely\n\nCommon replacements:\n\n| Original | Replacement |\n|----------|-------------|\n| `✅`     | `[OK]`      |\n| `❌`     | `[ERROR]`   |\n| `?`     | `[START]`   |\n| `→`      | `->`        |\n| `•`      | `-`         |\n| `—`      | `--`        |\n\n### Step 3 — Write the file via heredoc\n\nUse `run_shell` with the following pattern:\n\n```bash\ncat > path\u002Fto\u002Ffile.ext \u003C\u003C 'EOF'\n...file content here (with Unicode stripped\u002Freplaced if needed)...\nEOF\n```\n\n**Key details:**\n- Use `'EOF'` (single-quoted) as the heredoc delimiter — this disables all\n  shell variable expansion and special character interpretation inside the block.\n- Do **not** indent the closing `EOF` (it must start at column 0).\n- For deeply nested content, choose a delimiter that cannot appear in the\n  content itself (e.g. `'HEREDOC_END'`, `'FILEEND'`).\n\n---\n\n## Example\n\n### Failing call\n\n```python\nwrite_file(\n    path=\"src\u002Fcomponents\u002FStatusPanel.ts\",\n    content=\"\u002F\u002F Status icons\\nconst icons = { ok: '✅', err: '❌', run: '?' };\\n\"\n)\n# → Error: unknown error\n```\n\n### Recovery via heredoc\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '[OK]', err: '[ERROR]', run: '[START]' };\nEOF\n```\n\nOr, if UTF-8 output is acceptable in the environment:\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '✅', err: '❌', run: '?' };\nEOF\n```\n\n---\n\n## Multi-File Scenario\n\nWhen writing several files and one fails, write the others with `write_file`\nas normal and apply the heredoc fallback only to the failing file(s):\n\n```bash\n# Write multiple files that contain Unicode\ncat > src\u002Futils\u002Ficons.ts \u003C\u003C 'EOF'\nexport const ICONS = {\n  success: '[OK]',\n  failure: '[FAIL]',\n  pending: '[...]',\n};\nEOF\n\ncat > src\u002Futils\u002Flabels.ts \u003C\u003C 'EOF'\nexport const LABELS = {\n  title: 'Dashboard',\n  subtitle: 'Real-time status',\n};\nEOF\n```\n\n---\n\n## Important Notes\n\n1. **Always prefer `write_file` first** — only fall back to the heredoc\n   approach when `write_file` fails.\n2. **Verify after writing** — use `run_shell` with `cat path\u002Fto\u002Ffile` or\n   `head -5 path\u002Fto\u002Ffile` to confirm the content was written correctly.\n3. **Directory creation** — `write_file` auto-creates parent directories;\n   the heredoc approach does not. Pre-create directories with\n   `mkdir -p path\u002Fto\u002Fdir` if needed.\n4. **Large files** — heredocs work well for files of any practical size;\n   there is no meaningful shell limit.\n5. **Escaping backslashes** — inside a single-quoted heredoc, backslashes\n   are treated literally (no escaping needed), which is usually desirable.","# Unicode-Safe File Writing\n\n## Problem\n\nThe `write_file` tool may fail with `'unknown error'` when the file content\ncontains multi-byte Unicode characters such as:\n\n- Emoji (e.g. `?`, `✅`, `❌`)\n- Special typographic symbols (e.g. `→`, `•`, `—`, `©`)\n- Non-ASCII characters outside the Latin-1 range\n\nThis is a known encoding limitation of `write_file`.\n\n## Solution\n\nFall back to `run_shell` and write the file using a **shell heredoc**\n(`cat > file \u003C\u003C 'EOF' ... EOF`). The single-quoted delimiter `'EOF'`\nprevents the shell from interpreting any special characters inside the\nblock.\n\n---\n\n## Step-by-Step Recovery\n\n### Step 1 — Detect the failure\n\nIf `write_file` returns an error such as:\n\n```\nError: unknown error\n```\n\nand the content contains non-ASCII characters, assume a Unicode encoding\nissue and proceed to the heredoc fallback.\n\n### Step 2 — Strip or replace problematic characters (if needed)\n\nBefore embedding content in the heredoc, decide whether to:\n\n- **Keep** the characters as-is (works if the shell\u002Fterminal is UTF-8 aware)\n- **Replace** emoji\u002Fsymbols with ASCII equivalents (safest, most portable)\n- **Remove** them entirely\n\nCommon replacements:\n\n| Original | Replacement |\n|----------|-------------|\n| `✅`     | `[OK]`      |\n| `❌`     | `[ERROR]`   |\n| `?`     | `[START]`   |\n| `→`      | `->`        |\n| `•`      | `-`         |\n| `—`      | `--`        |\n\n### Step 3 — Write the file via heredoc\n\nUse `run_shell` with the following pattern:\n\n```bash\ncat > path\u002Fto\u002Ffile.ext \u003C\u003C 'EOF'\n...file content here (with Unicode stripped\u002Freplaced if needed)...\nEOF\n```\n\n**Key details:**\n- Use `'EOF'` (single-quoted) as the heredoc delimiter — this disables all\n  shell variable expansion and special character interpretation inside the block.\n- Do **not** indent the closing `EOF` (it must start at column 0).\n- For deeply nested content, choose a delimiter that cannot appear in the\n  content itself (e.g. `'HEREDOC_END'`, `'FILEEND'`).\n\n---\n\n## Example\n\n### Failing call\n\n```python\nwrite_file(\n    path=\"src\u002Fcomponents\u002FStatusPanel.ts\",\n    content=\"\u002F\u002F Status icons\\nconst icons = { ok: '✅', err: '❌', run: '?' };\\n\"\n)\n# → Error: unknown error\n```\n\n### Recovery via heredoc\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '[OK]', err: '[ERROR]', run: '[START]' };\nEOF\n```\n\nOr, if UTF-8 output is acceptable in the environment:\n\n```bash\ncat > src\u002Fcomponents\u002FStatusPanel.ts \u003C\u003C 'EOF'\n\u002F\u002F Status icons\nconst icons = { ok: '✅', err: '❌', run: '?' };\nEOF\n```\n\n---\n\n## Multi-File Scenario\n\nWhen writing several files and one fails, write the others with `write_file`\nas normal and apply the heredoc fallback only to the failing file(s):\n\n```bash\n# Write multiple files that contain Unicode\ncat > src\u002Futils\u002Ficons.ts \u003C\u003C 'EOF'\nexport const ICONS = {\n  success: '[OK]',\n  failure: '[FAIL]',\n  pending: '[...]',\n};\nEOF\n\ncat > src\u002Futils\u002Flabels.ts \u003C\u003C 'EOF'\nexport const LABELS = {\n  title: 'Dashboard',\n  subtitle: 'Real-time status',\n};\nEOF\n```\n\n---\n\n## Important Notes\n\n1. **Always prefer `write_file` first** — only fall back to the heredoc\n   approach when `write_file` fails.\n2. **Verify after writing** — use `run_shell` with `cat path\u002Fto\u002Ffile` or\n   `head -5 path\u002Fto\u002Ffile` to confirm the content was written correctly.\n3. **Directory creation** — `write_file` auto-creates parent directories;\n   the heredoc approach does not. Pre-create directories with\n   `mkdir -p path\u002Fto\u002Fdir` if needed.\n4. **Large files** — heredocs work well for files of any practical size;\n   there is no meaningful shell limit.\n5. **Escaping backslashes** — inside a single-quoted heredoc, backslashes\n   are treated literally (no escaping needed), which is usually desirable.",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","showcase\u002Fskills\u002Funicode-safe-file-writing","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":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add AG064\u002FOpenSpace --skill unicode-safe-file-writing",{"tool":53,"command":54},"bunx","bunx skills add AG064\u002FOpenSpace --skill unicode-safe-file-writing",{"tool":56,"command":57},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill unicode-safe-file-writing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Funicode-safe-file-writing\u002FSKILL.md",true,[61],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},".skill_id","OTHER","其他",39,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Funicode-safe-file-writing\u002F.skill_id",[68,89,105,113,138,154],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":35},"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",[],[75,76,25,77,78,79,80,81,82,83,84,26,85,86,21,87,88],"write special chars ts check","check","filters","Existing","type-checking","for","errors","script","output","type","only","template","python","typescript",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":35},"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",[],[96,97,25,86,98,99,21,87,100,101,102,103,104,80,82,33],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper",{"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":35},"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",[],[25,112,87,80,102,86,23,21,82],"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":119,"publishedAt":35},"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",[],[120,121,122,123,88,124,125,126,127,128,80,129,130,131,132,133,134,135,136,137],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":35},"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",[],[145,146,147,148,80,149,33,150,151,152,153],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":35},"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",[],[161,162,163,164,165,166,21,167,168,169],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]