逆向工程Claude Code • Kir Shatrov

I’ve been curious about what happens inside Claude Code so I’ve spent a couple hours digging through prompts that it sends back to Anthropic.

我一直对Claude Code内部发生的事情感到好奇,因此我花了几个小时挖掘它发送回Anthropic的提示。

As I’ve been going through that, I’ve gathered some insights why Claude Code is often slower and more expensive than other tools like Cursor.

在我经历这一过程时,我收集了一些见解,为什么 Claude Code 通常比其他工具如 Cursor 更慢且更昂贵。

Capturing prompts

捕获提示

It turned out a lot easier than I thought, thanks to mitmproxy:

结果比我想象的要简单得多,这要感谢 mitmproxy

$ brew install mitmproxy
$ mitmweb --mode reverse:https://api.anthropic.com --listen-port 8000
$ ANTHROPIC_BASE_URL=http://localhost:8000/ claude

Getting started

开始使用

I opened a repo with my personal blog and entered “describe what’s in this project”.

我打开了一个repo,并输入了“描述这个项目的内容”。

The very first thing you see is that Claude Code tries to figure out whether what you have entered is a continuation of the previous conversation or a new topic.

你首先看到的是 Claude Code 尝试判断你输入的内容是之前对话的延续还是一个新话题。

Analyze if this message indicates a new conversation topic.
If it does, extract a 2-3 word title that captures the new topic.
Format your response as a JSON object with two fields: 'isNewTopic' (boolean) and 'title' (string, or null if isNewTopic is false). Only include these fields, no other text.

Once it determines that, it wraps all your inputs into this system prompt:

一旦确定,它会将你的所有输入包装成这个系统提示:

You are an agent for Claude Code, Anthropic's official CLI for Claude. Given the user's prompt, you should use the tools available to you to answer the user's question.

Notes:
1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...
开通本站会员,查看完整译文。

Главная - Вики-сайт
Copyright © 2011-2025 iteam. Current version is 2.144.0. UTC+08:00, 2025-06-16 02:27
浙ICP备14020137号-1 $Гость$