安全写入大文件与中文内容

SKILL开发

原名 llm-safe-write

开发 未标注权限 许可证不明确
安装这个技能

面对超长文件或含中日韩字符的文件时,改用增量编辑方式写入,避免直接写入出现字符串未闭合或内容截断等失败情况。

一句话选型结论

按资料字段整理

安全写入大文件与中文内容是开发类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_15292d5a/yjkj-llm-safe-write
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_15292d5a仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验2026-11-06上游最后核验时间 · 数据更新 2026-11-06
正文体量12.7 KBSKILL.md 原文大小,越大说明说明书写得越细

能做什么

0 项能力
上游给出的能力概览与适用场景
写入超长代码文件写含中文的文档修复写入截断报错

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
安全写入大文件与中文内容当前 未标注权限 未标注 未标注 未标注 有
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

12.7 KB
模型实际读到的说明书原文,来自技能仓库

When to use me

Use this skill when:
- You need to write a file that is longer than 50 lines
- The file contains CJK characters (Chinese, Japanese, Korean) or special escape sequences
- A previous Write tool call failed with Unterminated string or JSON truncation errors
- You are about to write a Python/JS/TS file with more than a few functions
- You need to embed CJK strings in source code

Do NOT use this skill when:
- The file is short (< 50 lines) and ASCII-only — just use Write directly
- You are making small edits to an existing file — just use Edit directly

Prerequisites: Understanding Write Tool JSON Truncation

The Write tool serializes file content as a JSON string for transport. CJK characters occupy 3-4 bytes each in UTF-8. When a multi-byte character happens to cross an internal buffer boundary, the JSON string gets truncated, causing Unterminated string errors. ASCII-only content avoids this because each character is exactly 1 byte.

Key facts:
- Truncation is probabilistic — short files and pure ASCII rarely trigger it, but long files or CJK content trigger it frequently
- Bash tool also fails when passing multi-line Python code via PowerShell — PowerShell interprets quotes, backticks, curly braces, silently corrupting code
- You may try Write for files under 50 lines, but expect frequent failures above this threshold. For files > 50 lines or containing CJK, go directly to skeleton + Edit. The 50-line threshold is conservative — if your environment reliably handles longer ASCII files (e.g., 80 lines), you may adjust upward, but CJK content remains high-risk at any length.
- Truncation happens at the transport layer; it has nothing to do with whether your file content is syntactically valid

> Scope clarification: The Read and Edit tools are not affected by this issue — Read only reads (never writes), and Edit's oldString/newString are short strings (< 30 lines each) that never trigger truncation. Only the Write tool has this limitation.

Routing Priority (First Principles)

> Evaluate the file first: if any condition below is met, go directly to skeleton + Edit — do NOT try Write first:
>
> - File > 50 lines → skeleton + Edit
> - Content contains CJK / special characters → ASCII skeleton + Edit to fill CJK
> - Write already failed → switch immediately, never retry
>
> Only for files that are short (< 50 lines) and pure ASCII may you try Write directly — but if it fails, switch immediately.
>
> Never retry a failed Write with the same content — this is the hard constraint of this Skill.

Scenario Strategy
< 50 lines + pure ASCII You may try Write directly; for files > 50 lines or with CJK, go directly to skeleton + Edit
> 50 lines / contains CJK / Write failed Skeleton + Edit
Small edit to existing file (< 30 lines change) Edit tool directly
Large rewrite of existing file / CJK content Read file → Edit in small chunks with unique anchors

Strategy

When unsure, try the simpler approach first and fall back to skeleton+Edit if it fails. Never retry a failed Write.

For new files

Trigger condition: Creating a new file expected to be > 50 lines, or containing CJK content.

Steps:
1. Construct an ASCII-only skeleton (< 50 lines), replacing all CJK with PLACEHOLDER_xxx
2. Use Write to create the skeleton
3. Use Edit to replace each PLACEHOLDER with actual content (< 30 lines per Edit)

Example — writing a 200-line Python file:

Step 1 — Write the skeleton:

import argparse
import base64
import json

from paddleocr import PaddleOCR
from openai import OpenAI

API_BASE = &quot;PLACEHOLDER_API_BASE&quot;
API_KEY = &quot;PLACEHOLDER_API_KEY&quot;
PROMPT = &quot;PLACEHOLDER_PROMPT&quot;

def get_ocr():
    pass  # PLACEHOLDER_get_ocr

def detect_texts(image_path):
    pass  # PLACEHOLDER_detect_texts

def extract_json(text):
    pass  # PLACEHOLDER_extract_json

def main():
    pass  # PLACEHOLDER_main

if __name__ == &quot;__main__&quot;:
    main()

Step 2 — Fill each function with Edit (one at a time):

Edit(filePath=&quot;/path/to/file.py&quot;,
     oldString=&quot;pass  # PLACEHOLDER_get_ocr&quot;,
     newString=&quot;ocr = PaddleOCR(use_angle_cls=True, lang=&#x27;ch&#x27;)\n    return ocr&quot;)

Edit(filePath=&quot;/path/to/file.py&quot;,
     oldString=&quot;pass  # PLACEHOLDER_detect_texts&quot;,
     newString=&quot;result = ocr.ocr(image_path, cls=True)\n    return result&quot;)

For existing files

Trigger condition: Modifying an existing file that is already large or contains CJK.

  1. Always use Edit tool for modifications. Never use Write to overwrite an existing large file.
  2. If adding a large block, use Edit to replace a known marker/placeholder with the new content.
  3. Break large edits into multiple smaller Edit calls.

Appending content to existing files

Trigger condition: Need to add content at the end of an existing file.

The Edit tool can only replace, not append. To add content at the end of a file:
1. Use the last line as an anchor — include it in oldString, then repeat it in newString after the new content.
2. Example: to add a new function before if __name__ == &quot;__main__&quot;:, use that line as the anchor and replace it with new_function_code\n\nif __name__ == &quot;__main__&quot;:.
3. Always read the file first to get the exact last-line content for a precise match.
4. When no stable anchor exists at file end, write a temporary marker line (e.g., # END_OF_FILE) via Edit, use it as anchor for subsequent appends, then remove it with a final Edit. ⚠️ Prefer stable anchors (like if __name__ == &quot;__main__&quot;:) whenever available — if the agent is interrupted before the final cleanup Edit, the marker will remain in the file as residue.

For files with CJK content

Trigger condition: File content includes Chinese, Japanese, Korean, or other non-ASCII characters.

  1. Write skeleton with ASCII placeholders for all CJK strings.
  2. Use Edit to insert CJK text into the placeholders. Short CJK strings in Edit oldString/newString pairs work reliably.
  3. Alternative: use Python unicode escape in source (e.g., &quot;\u8bc6\u522b&quot; instead of &quot;识别&quot;) — this keeps the file ASCII-safe but less readable.

Example — Python file with Chinese prompts:

Step 1 — Skeleton with placeholders:

PROMPT_SYSTEM = &quot;PLACEHOLDER_prompt_system&quot;
PROMPT_USER = &quot;PLACEHOLDER_prompt_user&quot;
ERROR_MSG = &quot;PLACEHOLDER_error_msg&quot;

Step 2 — Fill with Edit:

Edit(filePath=&quot;/path/to/file.py&quot;,
     oldString=&#x27;PROMPT_SYSTEM = &quot;PLACEHOLDER_prompt_system&quot;&#x27;,
     newString=&#x27;PROMPT_SYSTEM = &quot;你是一个专业的AI助手,请用中文回答问题&quot;&#x27;)

For non-code files (JSON, YAML, Markdown, etc.)

Trigger condition: Writing config/data files that lack code-style comment placeholders.

These files lack code-style comment placeholders. Strategy:
1. JSON: Write the full structure with ASCII placeholder strings, then Edit to replace them with CJK values. Ensure the skeleton is valid JSON (all keys present, placeholder values) so the file remains parseable between edits. For non-string fields (numbers, booleans, null), use a same-type placeholder (e.g., 0, false, null) rather than a string — a string placeholder like &quot;PLACEHOLDER&quot; would break JSON type validity. Edit the field afterward with a short Edit call to replace the placeholder with the real value, or use a two-step Edit: first replace with a string, then fix the type.
2. YAML: Use # PLACEHOLDER_key_name comments as anchors on the line above the value to replace.
3. Markdown: Write section headers first as skeleton, then Edit to fill body content under each header.

Skeleton structure template

A good skeleton should include:
1. All imports at the top (these rarely change)
2. Constants and config (with ASCII placeholders for CJK values)
3. Function signatures with unique placeholder comments — one line per function, preserving correct indentation. Never use bare pass as multiple pass statements cause Edit tool Found multiple matches errors.
4. A main() or entry point at the bottom

For classes, use # PLACEHOLDER_ClassName_method_name format to ensure uniqueness across methods:

class MyHandler:
    def __init__(self):
        pass  # PLACEHOLDER_MyHandler_init

    def process(self, data):
        pass  # PLACEHOLDER_MyHandler_process

For JS/TS, use // PLACEHOLDER_funcName comments instead.

Edit failure recovery

If an Edit call fails with oldString not found:
1. Read the file again — the content may have changed from a previous edit
2. Check whitespace — tabs vs spaces, trailing newlines, or line endings
3. Use a shorter oldString — pick a smaller, unique substring to match
4. Avoid partial-line matches — include the full line or use exact indentation

If an Edit call fails with Found multiple matches:
1. Add more surrounding context to make the oldString unique
2. Or use replaceAll: true if you genuinely want to replace every occurrence (e.g., renaming a variable)

Common Error Handling

Error Cause Fix
Unterminated string Write content contains CJK or is too long; JSON truncated Switch to skeleton + Edit immediately; do not retry Write
oldString not found File content doesn't match oldString (stale after prior edit, whitespace differences) Re-Read the file; construct oldString from actual content
Found multiple matches oldString appears multiple times (e.g., bare pass) Add more surrounding context to make oldString unique; or use replaceAll: true
File not found Parent directory doesn't exist for new file Create directory first with mkdir -p, then Write
Write succeeds but Read shows incomplete content JSON truncation at end of file — Write didn't error but content was cut off Use Edit to fill in missing parts, or rewrite with skeleton + Edit
PowerShell corrupts multi-line code PowerShell interprets quotes/backticks/curly braces in strings Write code to a .py/.js file first, then execute the file

Hard Rules & Anti-patterns

Hard Rules

  1. Never retry a failed Write — the root cause is length/encoding; retrying wastes tokens and may leave a corrupt file. Switch to skeleton + Edit immediately.
  2. Never pass multi-line code through Bash/PowerShell — PowerShell interprets quotes, backticks, curly braces, silently corrupting code. Write to a .py/.js file first, then execute the file.
  3. Each Edit must change < 30 lines — split larger changes across multiple Edit calls.
  4. Always use unique placeholder comments (e.g., pass # PLACEHOLDER_func_name) — bare pass triggers Found multiple matches on every subsequent Edit.
  5. Always Read the file before Edit on existing files — stale oldString causes oldString not found.

Anti-patterns

  • Embedding CJK in Write content → CJK becomes 3-4 byte UTF-8; crossing buffer boundaries truncates the JSON string, failing the entire Write
  • Using python -c &quot;...&quot; with multi-line code in PowerShell → same string handling issues; code gets mangled before execution
  • Appending via Write to an existing large file → Write sends the full content through JSON again, risking truncation on the entire file
  • Write succeeds but Read shows incomplete content → silent truncation at end of file; always spot-check after Write

Post-write Behavior

After completing all file writes/edits:

  • Spot-check the file — use Read to verify the first 10 lines and last 5 lines; confirm key structure is intact
  • Report concisely — tell the user: "Written to file.py (120 lines, verified)" — no more detail needed
  • Do not output the full file content or large diffs — the user doesn't need to see it
  • Do not expose tool call internals (e.g., "Edit oldString='pass # PLACEHOLDER_parse'") — this is infrastructure, not user-facing information
  • Do not say "edit successful" after every single Edit — confirm once after all edits are complete

常见问题

5 问
答案由本站依据条目字段整理
安全写入大文件与中文内容怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_15292d5a/yjkj-llm-safe-write。安装方式为未标注。装完刷新技能列表或重开客户端。

安全写入大文件与中文内容支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

安全写入大文件与中文内容权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

安全写入大文件与中文内容收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

安全写入大文件与中文内容用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 2026-11-06。