将Claude Code的会话标题总结改为中文
- 内容介绍
- 文章标签
- 相关推荐
最近从ghostty换成了cmux,侧边栏显示每个会话的标题切换起来很方便,但是默认总结的都是英文,看起来不是很方便,于是查了下实际是有内置系统提示词的默认输出几个英文单词,可以通过patch将他改成输出中文
直接命令行执行即可,仅支持npm安装方式
f="$(npm root -g)/@anthropic-ai/claude-code/cli.js"; cp -n "$f" "$f.bak"; python3 - "$f" <<'PY'
from pathlib import Path
import re, sys
p = Path(sys.argv[1])
s = p.read_text()
pat = re.compile(r'''Generate a concise, sentence-case title \(3-7 words\) that captures the main topic or goal of this coding session\. The title should be clear enough that the user recognizes the session in a list\. Use sentence case: capitalize only the first word and proper nouns\.
Return JSON with a single "title" field\.
Good examples:
\{"title": "Fix login button on mobile"\}
\{"title": "Add OAuth authentication"\}
\{"title": "Debug failing CI tests"\}
\{"title": "Refactor API client error handling"\}
Bad \(too vague\): \{"title": "Code changes"\}
Bad \(too long\): \{"title": "Investigate and fix the issue
最近从ghostty换成了cmux,侧边栏显示每个会话的标题切换起来很方便,但是默认总结的都是英文,看起来不是很方便,于是查了下实际是有内置系统提示词的默认输出几个英文单词,可以通过patch将他改成输出中文
直接命令行执行即可,仅支持npm安装方式
f="$(npm root -g)/@anthropic-ai/claude-code/cli.js"; cp -n "$f" "$f.bak"; python3 - "$f" <<'PY'
from pathlib import Path
import re, sys
p = Path(sys.argv[1])
s = p.read_text()
pat = re.compile(r'''Generate a concise, sentence-case title \(3-7 words\) that captures the main topic or goal of this coding session\. The title should be clear enough that the user recognizes the session in a list\. Use sentence case: capitalize only the first word and proper nouns\.
Return JSON with a single "title" field\.
Good examples:
\{"title": "Fix login button on mobile"\}
\{"title": "Add OAuth authentication"\}
\{"title": "Debug failing CI tests"\}
\{"title": "Refactor API client error handling"\}
Bad \(too vague\): \{"title": "Code changes"\}
Bad \(too long\): \{"title": "Investigate and fix the issue

