返回播客Claude
Claude Code 101
Claude Code 是如何工作的
We know that Claude code is different from usual chat applications, but how does it work?
我们知道 Claude Code 与普通聊天应用不同,但它是如何工作的?
Claude code is best explained through the agentic loop.
Claude Code 最好通过 agentic 循环来理解。
You enter a prompt into Claude code.
你在 Claude Code 中输入一个提示。
Claude code will then gather contacts required to complete your prompt.
Claude Code 随后会收集完成提示所需的上下文。
It does so by interacting with the model which will return text or a tool call that Claude code can execute.
它通过与模型交互来实现这一点,模型将返回文本或 Claude Code 可以执行的工具调用。
Then it takes action.
然后它采取行动。
For example, editing a file or running a command.
例如,编辑文件或运行命令。
Finally, it verifies those results and determines if they achieve what your prompt set out to do in the first place.
最后,它验证这些结果,并判断它们是否实现了你的提示最初设定的目标。
If they do, then Claude finishes and waits for the next prompt.
如果实现了,Claude 就结束并等待下一个提示。
And if they don't, Claude goes back and runs the loop again until the results are complete and verifiable.
如果没有实现,Claude 会返回并再次运行循环,直到结果完整且可验证。
Throughout this loop, you're able to add contacts, interrupt it, or steer the model to help guide it towards your end goal.
在整个循环中,你可以添加上下文、中断它,或引导模型帮助它朝你的最终目标前进。
Claude has a context window, which determines how much of your conversation, file contents, command outputs, and more it can store and look back on.
Claude 有一个上下文窗口,决定它能存储和回顾多少对话内容、文件内容、命令输出等。
Once you reach that limit, Claude code compacts your conversation, which automatically determines what it can take out of the context window and what it can summarize in order to bring the context window back down.
一旦达到该限制,Claude Code 会压缩你的对话,自动决定哪些内容可以从上下文窗口中移除,哪些可以摘要,以便将上下文窗口缩减回来。
Tools are the backbone of how agents work.
工具是 agent 运作的核心。
Currently, most AI assistants are simply input text and output text.
目前,大多数 AI 助手只是输入文本和输出文本。
Nothing in between.
中间什么都没有。
Tools let Claude code and other agents determine when to execute code to get closer to a task.
工具让 Claude Code 和其他 agent 决定何时执行代码以更接近任务目标。
This could be read file tool or search web tool, for example.
例如,这可以是读取文件工具或搜索网页工具。
Claude code uses semantic searching to determine when to call a tool and get the output of it.
Claude Code 使用语义搜索来判断何时调用工具并获取其输出。
Claude code also has permission modes.
Claude Code 还有权限模式。
Default behavior is that it has to ask explicit permission before editing a file or running a shell command.
默认行为是在编辑文件或运行 shell 命令之前必须明确请求权限。
You can use shift and tab to toggle between different modes.
你可以使用 Shift 和 Tab 键在不同模式之间切换。
Auto accept edits files without asking, but still ask for commands.
自动接受会在不询问的情况下编辑文件,但仍会询问命令。
Plan mode uses read-only tools to help compile a plan of action before starting.
计划模式使用只读工具,在开始前帮助制定行动计划。
It's worth being cautious when skipping permissions.
跳过权限时值得保持谨慎。
Giving Claude code free reign to run commands means a mistake could be harder to catch before even happens.
让 Claude Code 自由运行命令意味着错误可能在发生之前更难被发现。
Claude code works by combining different agentic concepts, an agentic loop, a managed context window, tools, and configurable permissions into your terminal.
Claude Code 通过将不同的 agentic 概念组合到你的终端中来运作:agentic 循环、受管上下文窗口、工具以及可配置权限。
It can read your code base, take action, and verify its own work, and that makes it fundamentally different from a chat window.
它可以读取你的代码库、采取行动并验证自己的工作,这使它从根本上不同于聊天窗口。