My old AI-assisted programming routine involved pasting code and errors into a chat window, reading suggestions, editing and running the code myself, then pasting in the next error. Claude Code connects these steps: give it a concrete task and it can find files, edit code, run tests and adjust based on the results.
What interested me was how something that looks like a terminal chat box can keep working through a task. To understand it, look at both how developers assign work and how a program turns model output into actions.
Filed under July 15, 2025, using the official repository changelog through 1.0.51 as the feature baseline. Commands, shortcuts and extension mechanisms refer to that period.1
What are Claude Code and autonomous agents?
Claude Code is Anthropic’s command-line programming assistant. It can read project files, edit code and run commands, then continue from execution results. Claude is the model that interprets and generates content. Claude Code connects it to the development environment so it can act on a project. It launched in research preview in February 2025 and became generally available in May. The subject here is distinct from the Claude 3.5 model released in 2024.23
“Autonomous” here means the assistant can choose the next action toward a user-specified goal. Asked to fix a bug, for example, it can search for related code, read the implementation and tests, edit files, run tests and adjust after failures. The user need not prescribe every read or command, but should still define the goal, operating scope and acceptance criteria.
Ask “who decides the next step?” A fixed script follows predefined steps. A workflow can call models at fixed nodes. An autonomous agent lets the model choose the next action dynamically from the task and feedback. Anthropic distinguishes workflows and agents along these lines.4 They can be combined: CI can always trigger a check and delegate diagnosis of a specific failure to an agent.
Claude Code works on more than source code. Any task expressible with files and command-line tools is a potential fit, such as organizing documents, analyzing logs or generating batch scripts. Being able to call tools and reliably finishing a task are separate matters. The latter requires checkable results.
Installation and startup
During this period installation used npm and required Node.js 18 or later. The example pins the version under discussion. Replace your-project with the actual project directory.5
node --version
npm --version
npm install -g @anthropic-ai/claude-code@1.0.51
cd your-project
claude --version
claude
Follow the login prompts on first launch. By this date Claude Code supported Pro and Max subscription login as well as API-based access. Subscription allowances and API billing were distinct arrangements, so a subscription did not imply unlimited calls. Version 1.0.51 added native Windows support with Git for Windows required. WSL was another option.1
Once in a project, a narrowly scoped first task makes it easier to judge fit than asking it to finish the entire project:
Read the README, dependency configuration and test directory. Explain how to start and test this project.
Analyze only, without editing files. Identify conclusions supported by files and those still requiring execution.
Then run /init to generate the project guidance file CLAUDE.md and verify it yourself. Use it for test commands, coding conventions and easily misunderstood business rules. It is textual context read by later sessions, rather than knowledge trained into model parameters. Houmann’s account also puts maintaining project context near the top.6
For example, a Python project’s CLAUDE.md might look like this. Adjust commands to the actual project:
# Project conventions
- Business code lives in src/ and tests in tests/.
- Run tests with python -m pytest.
- Check callers before changing a public interface.
- Preserve existing behavior when fixing bugs, and add a test reproducing the problem.
- Do not edit generated files. Change their source instead.
Common commands and verbose mode
Distinguish shell input from commands inside Claude Code. claude -p starts a noninteractive task from the shell. Slash commands such as /compact are entered within a Claude Code session. Common entry points by purpose:16
| Entry | Purpose | What to remember |
|---|---|---|
/help | Show available commands | Follow the help in the installed version. |
/init | Generate project context | Check CLAUDE.md for inaccurate summaries. |
/clear | Clear current conversation context | Existing file changes remain. |
/compact | Compress conversation history | Summaries can lose details. Retain constraints and unfinished work. |
/model | View or switch model | Availability depends on account and access method. |
/permissions | Manage tool permissions | Permission to edit files does not authorize arbitrary commands. |
/mcp | Inspect MCP connections and tools | Test that the tool actually accomplishes the task after connecting. |
/resume | Select and restore previous conversations | Recheck files after restoration. |
/export | Export a session | Added in 1.0.44, useful for retaining discussion and investigation records. |
@file-path | Reference a specific file | More precise than “look at that module.” |
!command | Run a shell command directly and add its output to the session | This executes the command. |
For complex changes, switch to Plan mode to investigate and propose a plan before editing. Shift+Tab cycles interactive permission modes. Available choices and terminal behavior depend on this version’s UI. Automatically accepting edits principally reduces file-edit confirmations. It does not establish that no other operation needs authorization.
Ctrl+R expands the execution record
An older reference article described Verbose mode as viewing all the context Claude sees. That is too broad. In this version Ctrl+R expands the detailed transcript and tool output, especially long tool results collapsed by default. The official changelog explicitly recorded long-output expansion in 0.2.54 and timestamps for this view in 1.0.30.1
If the interface only shows that a test command failed, expand the record to see what actually ran, what errors came back or whether a file read returned the expected content. That helps explain where the agent took a wrong turn.
The displayed transcript is not the complete input to every model request. This view cannot reconstruct all system instructions, tool definitions, summaries or client-side truncation and organization. Nor does it expose all the model’s internal reasoning. A better description is expand execution details to inspect what the assistant did and what the tools returned.
Give the task a verifiable finish line
Compared with “fix login,” the following request is easier to execute and verify:
The login endpoint returns 500 for an empty password. It should return 400.
Find the cause first, then make a minimal change and add the corresponding test.
Preserve the normal login flow and existing response fields.
List changed files, tests run and anything unverified.
Do not commit or push code.
For one-off analysis, the terminal also supports noninteractive use:
claude -p "阅读 README,概括项目用途和本地启动步骤;只读取,不修改文件。"
-p controls interaction style, not read-only permission. Match the example’s scope constraint with appropriate tool permissions.
Connect external tools through MCP
MCP, the Model Context Protocol, connects model applications to external tools and data sources through a common protocol. For a tool call, the server publishes its name, purpose and argument schema. The client discovers tools and supplies appropriate descriptions to the model. When the model requests a call, the client sends it to the server, then passes the result back. The June 2025 specification defines interfaces including tools/list and tools/call.7
MCP standardizes integration, without guaranteeing the tools’ quality. A documentation service lets the agent retrieve docs. A database tool lets it query authorized data. Completeness, account permissions and query cost still depend on the service.
The following template connects a local stdio MCP service. The path must point to a prepared server program. An ordinary Python script is not automatically an MCP service:
claude mcp add local-docs -- python3 /absolute/path/docs_mcp_server.py
claude mcp list
Enter Claude Code, use /mcp to inspect the connection, and try a specific task such as “Find the pagination parameter conventions in the project documentation and cite their location.” A tool appearing in a list does not verify the entire integration.
Claude Code’s built-in read, search and Bash tools do not inherently use MCP. Built-in tools and MCP-connected tools can coexist. Seeing an assistant read a file or execute a command does not mean all its tool capabilities are MCP.
Custom commands
Save repeated work as project-level slash commands. This version used Markdown files in .claude/commands/. For example, .claude/commands/review-change.md corresponds to /review-change. The 1.0.30 changelog already included file references and Bash output in custom commands.1
A minimal template needs little configuration:
Read the current Git diff and check whether these changes meet the requirements and project conventions.
Focus on interface compatibility, error handling and test coverage of behavior changes.
Only report issues with file locations and reasons. Do not modify files.
Finish by describing the review scope and anything still unverified.
After saving it, call it in the session:
/review-change
This stores instructions you would otherwise type repeatedly. It neither guarantees an identical execution path every time nor inherently creates an independent agent. State the input, scope, checks and deliverable in the prompt so the command keeps clear boundaries across tasks.
Use hooks for deterministic actions
Users invoke custom commands. Hooks respond to execution events, such as checking a pending Bash command or running an agreed check after a file edit. The client runs hooks according to configuration, without asking the model each time whether to perform the check.
Hooks shipped in 1.0.38. By this version the changelog also recorded the split between Stop and SubagentStop and the addition of PreCompact. Hooks therefore belonged to the feature set at the time.1
Configure command hooks in .claude/settings.json. This example connects the Bash command validation script supplied by the official repository at the time. Obtain that script and replace the path with its actual location. If settings already exist, merge the hooks field.8
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 /absolute/path/bash_command_validator_example.py"
}
]
}
]
}
}
The official example reads JSON from standard input and checks tool_name and tool_input.command. For certain matching grep and find uses it recommends rg and exits with code 2, blocking that call and allowing Claude to revise and retry.8
The model decides what to search. The hook checks whether the pending action follows project conventions. Similar mechanisms can run formatting checks or record operations. Limit trigger scope: a full test suite on every tiny edit noticeably slows work. A string or regex check alone is also not a complete shell sandbox.
Subagents and task delegation
For large searches or multiple analytical perspectives, a main assistant can delegate bounded subtasks to separate agent executions and combine results. The Task mechanism already existed during this period. Historical logs mention subtask message output, Task file writing and Bash access, and the SubagentStop hook.1
Investigating an endpoint implementation and its test coverage separately is one suitable example:
Use separate subtasks to investigate login endpoint validation and existing test coverage.
Keep investigation read-only. Each subtask should return relevant file locations,
confirmed behavior and open questions. Have the main session combine them before proposing changes.
This keeps lengthy investigation in the subtasks while the main session focuses on goals and conclusions. Subtasks still need enough background and must return critical evidence. If a summary only says “no problems,” the main assistant cannot tell what was checked.
Parallel work has coordination costs. Tasks editing the same file may overwrite each other. A task dependent on another’s unfinished interface is also a poor candidate for immediate parallel execution. First delegate independent investigations and consolidate edits in the main session. For parallel development, isolate work by module or Git worktree.
This describes the delegation available at the time, without using custom-agent configuration interfaces that the version had yet to provide.
GitHub integration
There are two layers. Locally, Git and an authenticated GitHub CLI can handle repository work such as reading issues, inspecting diffs and preparing commits or PRs. Alternatively, run Claude Code in GitHub Actions with repository events starting tasks. Anthropic’s May 2025 announcement already described GitHub Actions integration.3
Claude Code’s /install-github-app can guide installation. This requires appropriate repository administration permissions, app authorization, model credentials and workflow configuration. Typing @claude in an issue alone creates no automation.1
A historical workflow in the official repository illustrates the process. Listen for issue and PR comments, check for @claude, check out the repository on a runner and run anthropics/claude-code-action@beta with an API key from GitHub Secrets.9
Request in an issue or PR
↓
GitHub Actions triggers a workflow
↓
Runner checks out code and runs Claude Code
↓
Investigation, edits and tests produce a reviewable result
A concrete request might be “Analyze this issue’s reproduction steps, locate the cause and add a test, then put the changes in a separate PR.” Generated commits should still pass CI and code review. Repository comments, checked-out files and external pages are task inputs and should not receive extra authority to modify workflows or read other secrets.
Conversation history and context management
Closing the terminal does not force you to explain the entire task again. The old release already supported continuing and resuming sessions:1
# 继续当前目录最近一次会话
claude --continue
# 选择历史会话
claude --resume
Inside a session you can also use /resume. Use /export to retain a discussion, /clear to start an unrelated task or /compact when a conversation about one task becomes too long.
These operations solve different problems. Resuming preserves discussion continuity, compaction reduces history carried forward, CLAUDE.md stores project conventions across sessions, and Git records file changes. Restoring chat does not restore code. Clearing chat does not undo edits.
Compact at a suitable handoff point. First ask the assistant to organize the goal, completed edits, test results, unresolved issues and next steps, then compact. Write critical business constraints into task documents or project guidance instead of relying on a sentence early in chat.
When resuming an old task, have the assistant check Git status and relevant files again. You or colleagues may have changed them since the conversation, and stale assumptions can overwrite correct work.
IDE integration and visualization
A CLI does not require staring only at text output. Claude Code already integrated with VS Code and JetBrains IDEs during this period, letting users inspect diffs in the editor and work with the current file. The official May 2025 announcement covered these integrations.3
Start claude in the IDE’s project terminal and follow the connection prompts. Keep two views: the terminal for tasks and execution history, the editor for files and diffs. During review check which behavior changed, beyond the assistant’s final claim of completion.
Screenshots are another input. The old version already supported dragging or pasting images into a prompt to explain layout, reproduce a UI problem or compare a design.1 Seeing an image and operating a browser are different capabilities. Clicking pages and checking interactions automatically require browser tools and a runnable test environment.
Three visual aids serve different purposes. IDE diffs inspect changes, screenshots express the target and Ctrl+R exposes the execution record. Together they reduce dependence on the assistant’s own report, though running the page and verifying business behavior are still necessary.
How an autonomous agent works
From an application developer’s perspective, a basic agent comprises a model, tools, context and an execution loop. The model generates an answer or a tool call using available information. The application runs the tool, puts the result back in context and asks the model for the next step. Anthropic’s explanation emphasizes dynamic process and tool choices by the model.4
flowchart TD
A[用户目标与约束] --> B[组织消息与工具定义]
B --> C[调用模型]
C --> D{是否请求工具}
D -->|是| E[校验参数和权限]
E --> F[执行或拒绝工具调用]
F --> G[记录输出与错误]
G --> B
D -->|否| H[给出结果或说明阻碍]
How a tool call becomes an actual operation
Tools typically have a name, purpose and argument structure. A file reader requires a path, and a test tool accepts a test scope. Given these descriptions the model generates a structured request. The program outside the model opens files, creates processes and accesses APIs.
Preserve the association between calls and results. When the model asks to read file A, return the result or error for that request, without mixing in output from another parallel operation. Claude Code’s changelog recorded a fix for mismatched tool_use and tool_result, illustrating how much this detail matters.1
This pseudocode illustrates control flow. It is neither official Claude Code source nor a complete runnable program:
Message history ← user task
Repeat until a turn, time or cost limit is reached:
Response ← model(system instructions, message history, tool definitions)
Append complete response to message history
If truncated or the request failed:
Enter recovery without treating it as completion
Else if no tools were requested:
Return answer and completion status or blocker
Else:
For each tool call:
Validate name, arguments, permissions and timeout
Execute tool or generate an explicit rejection result
Associate the result by call ID and retain output and error status
Append this round of tool results to message history
Stop at the limit and report completed and outstanding work
Suppose the user reports “empty password causes a 500.” The model might first request a search for the login entry point, then inspect validation, propose an edit after finding a missing check, and investigate adjacent logic if tests fail. The program need not predefine every filename and operation order, but must expose the interfaces that make those actions possible.
Context determines what the model knows now
A model does not inherently see the entire disk. It reasons from its current request: the user goal, project guidance, file excerpts already read, tool results and historical summaries. Understanding a repository usually takes gradual searching and reading to form a working context.
This explains several familiar outcomes. A convention never read can be missed. Truncated output may leave a critical error line out of the next round. Compaction may lose earlier details. Improve how information is organized by giving entry points, retaining source locations and recording decisions promptly. Repeatedly asking the model to “be more careful” does little by itself.
What separates a loop from a reliable assistant?
The loop allows ongoing action. Reliability also depends on surrounding implementation: argument validation, file and command permissions, timeouts, retries, output truncation, cost limits and user interruption.
Distinguish two failure types. A failed file read can usually be retried with another path. A message send or external write that times out may already have succeeded, so blindly retrying can duplicate the operation. Tool interfaces should express success, failure and uncertainty instead of reducing all outcomes to ordinary text.
A model ceasing to call tools means only that it finished this round. It does not prove correctness. For a code fix, check that tests actually ran, assertions exercise the problem and interface behavior matches requirements. A green suite achieved by deleting failing tests or bypassing the target logic does not establish a fix.
How to read projects such as learn-claude-code
I read learn-claude-code as a learning resource for black-box analysis and reconstructing mechanisms. Start from externally observable Claude Code capabilities, consider what mechanisms could support them and build a similar agent in your own code. The repository emphasizes understanding the core design and then building independently. This makes it an educational reconstruction, rather than a line-by-line account of official source.10
Black-box analysis helps answer “how could similar behavior be implemented?” Behavioral similarity alone cannot prove how the official product works. Different structures and scheduling can produce the same file search, delegation or compaction experience. Teaching implementations also tend to simplify error handling and runtime environments for clarity.
The flowchart and pseudocode therefore explain a general agent structure. For what the product supported, consult contemporary official records. For how a similar system could be implemented, study these reconstructions. Together they illuminate the principles, without establishing third-party code as Claude Code’s actual internal architecture.
Trade-offs in use
In Reflections on AI Programming Tools, 小盒子 describes Claude Code’s appeal as the completeness of task handling. It keeps adjusting based on context, logs and execution results. The trade-offs are more calls, longer waits and continued human judgment. The author explicitly ranked tools by personal preference, which should not be treated as a product capability ranking.11
I prefer choosing by task. Changing a known setting is often faster to do directly. Cross-file debugging, adding tests and repeatedly organizing material benefit more from successive tool calls. “Autonomy” need not turn every simple action into a broad investigation.
Cost also extends beyond one request’s tokens. A task may reread context, run tools and analyze errors repeatedly. Subtasks each generate their own calls. Compare time, spending and review burden for the same completed work, rather than how clever a single reply sounds.
In an existing project, a sensible sequence is to understand first, make a bounded change and check the result. Describe the input, what may change and what counts as done. Provide tests or a runtime that can return real feedback and retain reviewable Git changes. Autonomy can then reduce repeated manual work without adding more troubleshooting afterward.
Source notes and references
This article retains the supplied reference trail and uses official historical snapshots to bound the features. No verifiable word-for-word subtitles were available for the video. Its supplied chapter list establishes coverage of installation, commands, MCP, custom commands, hooks, subagents, GitHub, conversation history and visualization, without serving as evidence for specific statements in the video.12 The Zhihu page returned 403, so the author’s views were cited from the supplied text.
The Juejin tutorial appeared August 18, 2025, after this article’s archival date. It remains a reference, but its model integration settings are not presented as part of a July 15 tutorial.13 Claude Code’s documentation entry point changes over time. Historical features are grounded in the pinned commits cited here.14
Footnotes
-
Anthropic. (2025, July 11). Changelog [Software release notes, repository snapshot through version 1.0.51]. GitHub. https://github.com/anthropics/claude-code/blob/d45bce242d8ac7ff13a2bab2e619558ab5f47dec/CHANGELOG.md Pinned to the latest commit found through the end of July 15 Beijing time, committed July 11 UTC. Used to verify hooks, subtasks, MCP, session management, permission commands, Windows and historical Ctrl+R behavior. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10 ↩11
-
Anthropic. (2025, February 24). Claude 3.7 Sonnet and Claude Code. https://www.anthropic.com/news/claude-3-7-sonnet Claude Code research preview announcement. ↩
-
Anthropic. (2025, May 22). Introducing Claude 4. https://www.anthropic.com/news/claude-4 Covers general availability, VS Code and JetBrains integration and GitHub Actions. ↩ ↩2 ↩3
-
Anthropic. (2024, December 19). Building effective agents. https://www.anthropic.com/research/building-effective-agents Cited for the workflow/agent distinction and tool-feedback loop. Later product lists on the evolving page are not used as historical evidence. ↩ ↩2
-
Anthropic. (2025, June 25). Claude Code [README, repository snapshot]. GitHub. https://github.com/anthropics/claude-code/blob/5f9dcdb410e77a6ec5e94bbfbeaceaf093e76c18/README.md Historical README documenting Node.js 18+, the npm package and startup from a project directory. The example installation separately pins the feature baseline. ↩
-
Houmann, C. B. B. (2025, June 22). How I use Claude Code. https://bagerbach.com/blog/how-i-use-claude-code/ Consulted for project context, work organization and interactive use. Ctrl+R was cross-checked against the historical official changelog rather than broadly described as seeing the full context. ↩ ↩2
-
Model Context Protocol. (2025, June 18). Tools [Protocol specification]. https://modelcontextprotocol.io/specification/2025-06-18/server/tools Cited for discovery, calls, argument schemas and interaction boundaries in this version. ↩
-
Anthropic. (2025). Bash command validator example [Python source code, July 11 repository snapshot]. GitHub. https://github.com/anthropics/claude-code/blob/d45bce242d8ac7ff13a2bab2e619558ab5f47dec/examples/hooks/bash_command_validator_example.py Includes PreToolUse configuration, JSON on standard input and blocking a tool call with exit code 2. ↩ ↩2
-
Anthropic. (2025). Claude Code [GitHub Actions workflow, July 11 repository snapshot]. GitHub. https://github.com/anthropics/claude-code/blob/d45bce242d8ac7ff13a2bab2e619558ab5f47dec/.github/workflows/claude.yml Documents the contemporary event trigger, runner, Action and secrets integration. ↩
-
shareAI-lab. (n.d.). Learn Claude Code [Educational source code repository]. GitHub. Retrieved November 13, 2026, from https://github.com/shareAI-lab/learn-claude-code Chinese README describes understanding the design and building independently. “Black-box analysis and reconstruction” is my reading perspective, without claiming it covers all of the authors’ methods or represents official internals. No verifiable code snapshot for the archival date was available, so current contents are not projected backward. ↩
-
小盒子. (2025, June 26). Reflections on AI Programming Tools. Zhihu. https://zhuanlan.zhihu.com/p/1921602525104170558 Based on the supplied full text and displayed publication date. Cited for personal experience of completeness, cost, time and review. Subjective tiers, unverified acquisition details and “unlimited” claims are not adopted as facts. ↩
-
[Claude Code tutorial video, video ID e5O8A5pcVgg]. (n.d.). YouTube. https://www.youtube.com/watch?v=e5O8A5pcVgg The original page did not verify title or author, so a content description is used. Supplied timeline: 00:20 installation/startup, 01:02 important commands, 05:12 MCP, 09:52 custom commands, 11:28 hooks, 13:09 subagents, 15:25 GitHub, 16:41 conversation history and 17:47–21:13 visualization. ↩
-
阿坡RPA. (2025, August 18). Deploying Claude Code on Windows in Three Minutes: Integrating Qwen-Coder and GLM-4.5 as a Cursor Alternative Without a VPN Juejin. https://juejin.cn/post/7539199217945821236#heading-2 Article text was accessible. Because it postdates this article, the link is retained without adding later models or configurations. ↩
-
Anthropic. (n.d.). Claude Code overview [Documentation]. Retrieved November 13, 2026, from https://code.claude.com/docs/en/overview Retains the supplied official documentation entry point. Historical features were checked against the pinned commits in references 1, 5, 8 and 9. ↩