alibaba00  

痛点

1. 在windows下,vscode 中使用 基于windows安装的claude code插件。在写文件的时候,经常使用大量的bash的命令,来来回回的操作失败,最后,采用了python写入文件。浪费时间和token.

2. 在win下,plan模式下,仍然没有请示,就直接修改代码。

解决方法:

vs code 创建Snippet,来对claude code 进行约束。

{
  "Claude Code Windows Strict Write Guard": {
    "prefix": "cc-win-guard",
    "body": [
      "Environment:",
      "- Windows OS.",
      "- Shell / command-line tools are unreliable.",
      "",
      "Global Rules (Strict):",
      "1. Do NOT use any shell commands.",
      "2. Do NOT modify, create, or delete any file",
      "   unless I explicitly grant permission.",
      "3. Any file write without permission is a violation.",
      "",
      "Two-Phase Protocol:",
      "",
      "Phase 1 (Default — Read Only):",
      "- Read files only.",
      "- Analyze and propose changes.",
      "- Output a clear plan including:",
      "  * Target files (exact list)",
      "  * Exact modifications",
      "  * Risk or edge cases",
      "- Do NOT write any file.",
      "- Do NOT scan the repository unless explicitly asked.",
      "",
      "Phase 2 (Write Allowed):",
      "- Proceed ONLY after I explicitly say:",
      "  \"Approved. You may apply the changes.\"",
      "- Modify ONLY the approved files.",
      "- Apply changes in a single deterministic pass.",
      "- Write each file exactly once.",
      "- No extra or opportunistic changes.",
      "",
      "If permission is not granted, STOP after Phase 1."
    ],
    "description": "Claude Code Windows strict write-guard (cc-win + approval protocol)"
  }
}
posted on 2026-01-04 16:09  不老天神  阅读(35)  评论(0)    收藏  举报