docs(claude): 加 Shell 语法规约 — 别把 PowerShell here-string 喂给 Bash 工具

踩过:`@'...'@` 用 Bash 工具跑,首尾 `@` 被当字面量塞进 commit message,
只能 amend + force-push 收拾。立规矩:多行文本优先写临时文件 + `-F`;
必须内联时按工具选语法(Bash 用 `$'...'`/heredoc,PowerShell 才用 `@'...'@`)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
caoqianming 2026-06-02 12:28:23 +08:00
parent 33bea27d85
commit 198e95cd84
1 changed files with 7 additions and 0 deletions

View File

@ -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 <file>` / 重定向喂命令**,绕开两种 shell 的引号差异 —— 最稳。
- 必须内联多行时:Bash 工具用 `$'...\n...'` 或 heredoc `<<'EOF'`;PowerShell 工具才用 `@'...'@`。别混。
- 一句话:**先看自己在用哪个工具(Bash vs PowerShell),再选对应语法**。
## 实施前先对方案
非平凡改动(改 >1 个文件 / 涉及行为变化 / 多个候选方案有取舍)动手前**先用自然语言把方案讲给用户确认,认可后再写代码**。一次性 bug 修复 / 改字面量 / 样式微调 / 加日志这类无歧义动作可以直接动手。