From 198e95cd8435ff1aa4f959a329cc27f4c61de09f Mon Sep 17 00:00:00 2001 From: caoqianming Date: Tue, 2 Jun 2026 12:28:23 +0800 Subject: [PATCH] =?UTF-8?q?docs(claude):=20=E5=8A=A0=20Shell=20=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E8=A7=84=E7=BA=A6=20=E2=80=94=20=E5=88=AB=E6=8A=8A=20?= =?UTF-8?q?PowerShell=20here-string=20=E5=96=82=E7=BB=99=20Bash=20?= =?UTF-8?q?=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 踩过:`@'...'@` 用 Bash 工具跑,首尾 `@` 被当字面量塞进 commit message, 只能 amend + force-push 收拾。立规矩:多行文本优先写临时文件 + `-F`; 必须内联时按工具选语法(Bash 用 `$'...'`/heredoc,PowerShell 才用 `@'...'@`)。 Co-Authored-By: Claude Opus 4.8 (1M context) --- CLAUDE.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 2fd3508..54665de 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,13 @@ - 跑脚本 / 测试一律用 `.venv/Scripts/python.exe ...`,**不要用全局 `python`**(没装 litellm/python-pptx 等会报 ModuleNotFoundError) - requirements 见 `requirements.txt` +## Shell:别把 PowerShell 语法喂给 Bash 工具 + +PowerShell here-string `@'...'@` **只在 PowerShell 工具里有效**;用 Bash 工具跑会把首尾的 `@` 当字面量塞进字符串(踩过:commit message 首尾混进 `@` 行,只能 amend + force-push 收拾)。规矩: +- **多行文本(commit message / 文件内容)优先写进临时文件,再用 `-F ` / 重定向喂命令**,绕开两种 shell 的引号差异 —— 最稳。 +- 必须内联多行时:Bash 工具用 `$'...\n...'` 或 heredoc `<<'EOF'`;PowerShell 工具才用 `@'...'@`。别混。 +- 一句话:**先看自己在用哪个工具(Bash vs PowerShell),再选对应语法**。 + ## 实施前先对方案 非平凡改动(改 >1 个文件 / 涉及行为变化 / 多个候选方案有取舍)动手前**先用自然语言把方案讲给用户确认,认可后再写代码**。一次性 bug 修复 / 改字面量 / 样式微调 / 加日志这类无歧义动作可以直接动手。