揭示 Claude Code 中 ultrathink 关键字如何激发更深层次的推理能力,直接提升 AI 编程的有效性和准确度。
2025年4月19日 - 链接日志
Claude Code:Agent 式编码的最佳实践(via)Anthropic 发布了关于如何充分利用其 Claude Code CLI 编码 Agent 工具的详尽新文档,其中包含这个有趣的提示:
我们建议使用"think"这个词来触发扩展思考模式,这会给 Claude 额外的计算时间来更彻底地评估各种选择。这些特定的短语直接映射到系统中不同级别的思考预算:「think」< 「think hard」< 「think harder」< 「ultrathink」。每个级别为 Claude 分配逐渐增加的思考预算。
看起来 ultrathink 真的是一个魔法词!
我很好奇这是 Claude 模型本身的功能还是 Claude Code 特有的。Claude Code 不是开源的,但你可以查看它的混淆 JavaScript 代码,并通过运行 Prettier 把它变得稍微不那么混淆。在 Claude 的帮助下,我使用了这个方法:
mkdir -p /tmp/claude-code-examine
cd /tmp/claude-code-examine
npm init -y
npm install @anthropic-ai/claude-code
cd node_modules/@anthropic-ai/claude-code
npx prettier --write cli.js
然后用 ripgrep 搜索"ultrathink":
rg ultrathink -C 30
找到了这段代码:
let B = W.message.content.toLowerCase();
if (
B.includes("think harder") ||
B.includes("think intensely") ||
B.includes("think longer") ||
B.includes("think really hard") ||
B.includes("think super hard") ||
B.includes("think very hard") ||
B.includes("ultrathink")
)
return (
l1("tengu_thinking", { tokenCount: 31999, messageId: Z, provider: G }),
31999
);
if (
B.includes("think about it") ||
B.includes("think a lot") ||
B.includes("think deeply") ||
B.includes("think hard") ||
B.includes("think more") ||
B.includes("megathink")
)
return (
l1("tengu_thinking", { tokenCount: 1e4, messageId: Z, provider: G }), 1e4
);
if (B.includes("think"))
return (
l1("tengu_thinking", { tokenCount: 4000, messageId: Z, provider: G }),
4000
);
所以是的,看起来"ultrathink"确实是一个 Claude Code 功能——特别是那个 31999 数字看起来会影响 token 思考预算,特别是因为"megathink"映射到 1e4 tokens(10,000),而单纯的"think"映射到 4,000。
OpenAI 对 Hugging Face 的无意中的网络攻击是发生过的科幻小说——2026年7月22日
与 Claude Code 团队的 Cat 和 Thariq 进行炉边谈话——2026年7月21日
Kimi K3 以及我们仍然可以从鹈鹕基准学到的东西——2026年7月16日
这是 Simon Willison 发布的链接文章,发布于 2025年4月19日。
每月 10 美元赞助我,获得本月最重要 LLM 发展的精选电邮摘要。
花钱让我发送更少内容!