Claude Code Terminal Programming Assistant: Double development efficiency from installation to mastery
At two o'clock in the morning, you stare at the dense number of wrong messages on the screen, and your third cup of coffee has already reached the bottom. A colleague's code warehouse hides an ancestral module that no one dares to touch. The document has long disappeared, and Git history has been turned into a mess by squash. You know this problem is not difficult to solve, but it just takes a lot of time to sort through it line by line-until you type a line of command in the terminal. Three minutes later, the problem is found and the method is changed.
This is no longer imagination. Claude Code-Anthropic's official terminal programming assistant-is redefining what "programming in natural language" means. It is not a simple code completion tool, nor is it an AI toy that only generates templates. It truly understands your code base, can execute commands, read and write files, handle Git workflows, and even help you debug and refactor. This article will teach you hands-on how to use Claude Code from scratch, covering installation configuration, daily use, advanced skills and key points to avoid traps. Whether you are a developer who has just taken over a new project or a veteran tortured by legacy code, you can find a usage that suits you.
1. What is a Claude Code and why you need it
Claude Code is the official CLI tool launched by Anthropic at the end of 2024. It is essentially an AI programming agent running in the terminal. You don't need to open a browser or switch to a web interface. Talk to it directly on the command line, and it can help you complete your coding tasks.
Its core capabilities can be divided into three levels. The first level is code understanding-Claude Code will actively scan the code structure of your current project to understand the dependencies between files, function call chains, and variable scopes. This means that when you ask it,"What does this module do?" it won't talk generically, but will really answer based on the actual situation of your project. The second layer is task execution-it can read and write files, execute Shell commands, call Git operations, and even run test suites. You ask it to "change this interface from REST to GraphQL," and it will really change the code and run the tests through. The third level is workflow orchestration-it can understand multi-step tasks, automatically disassemble, implement them step by step, and stop to ask for confirmation if necessary.
According to official data disclosed by Anthropic (a public blog published in early 2025), Claude Code helped engineers complete an average of 40% of daily coding tasks in internal testing, with the most significant improvement in the efficiency of code review and bug location. This number may be a bit idealistic, but combined with a large number of community feedback, Claude Code's performance is indeed eye-catching when dealing with highly repetitive and logically clear programming tasks.
2. Installation and configuration: Three minutes to run
system requirements
Claude Code currently supports macOS, Linux and Windows (via WSL or PowerShell). There are requirements for Node.js version-Node 18.17.0 or higher is required. If your system does not have Node installed yet, you can use nvm to manage multiple versions, which is much more flexible than installing global Node directly.
installation steps
-
Install Claude CLI: Claude Code relies on Claude CLI, install this first. Open the terminal and run:
npm install -g @anthropic-ai/claude-codeIf you use Homebrew (macOS/Linux), you can also:
brew install claude -
Authentication login: You will be prompted to log in to your Anthropic account for the first time you run it. Claude Code supports API Key authentication. You need to generate an API Key in the Anthropic console and fill in the prompt box. The entire process took less than a minute.
claude #The terminal will output: # Please paste your API key: sk-ant-xxxx... -
Specify the project directory: After the installation is complete, enter the project directory you want Claude Code to understand, and run claude directly. It automatically analyzes the project structure.
cd ~/projects/my-web-app claudeAfter entering interactive mode, the current working directory and project language will be displayed at the bottom of the terminal. Enter natural language to describe your needs, press Enter to send, and Claude Code will start working.
basic configuration
Claude Code has a configuration file ~/.claude/settings.json, which allows you to customize behaviors. The following are a few commonly used configuration items:
model: Specifies the model used. The default is Claude 3.5 Sonnet, which can be changed to Opus or a newer model.maxTokens: The maximum number of tokens per reply. When processing large documents, it is recommended to adjust the size to avoid replies being truncated.permissionMode: Controls the behavior of Claude Code when executing dangerous commands (such as deleting files, executingrm -rf). The default is 'ask', which means it will be confirmed every time. You can change it to 'accept-all' to improve efficiency, but at your own risk.
A typical configuration file looks like this:
{
"model": "claude-opus-4-5",
"maxTokens": 8192,
"permissionMode": "ask",
"includeHiddenFiles": false
}
3. Get started quickly: the five most commonly used basic commands
When you first come into contact with Claude Code, you don't need to remember complex parameters. Simply describe your needs in natural language. The following are the five most frequently used scenarios:
1. Interpreting unfamiliar code
When you take over a module you don't understand at all, ask it directly:
/explain What does this auth/middleware.ts file do? Focus on how it handles token verification
Claude Code will read the contents of the file, explain it in conjunction with the code context, and point out noteworthy details, such as how to handle certain boundary conditions.
2. Find and fix bugs
Post the error message directly to it:
/fix this error: TypeError: Cannot read properties of undefined (reading 'map')
It will locate the error location, analyze the cause, and then provide a repair plan. If you confirm that the plan is feasible, ask it to change directly:
/fix --apply
3. Write test cases
/test writes a unit test for the login function in userServices.ts, covering both normal login and password error situations
Claude Code will generate test files and place them in the corresponding __tests__ directory. It identifies the test framework you use (Jest, Vitest, Pytest, etc.) and generates test code that conforms to the project specifications.
4. Git operation
/git Help me compress the last three commits into one and write a clear commit message
It will perform the interaction process of git rebase -i, generate appropriate commit messages, and even help you handle conflicts.
5. generated code
/write Write a Python script, connect to PostgreSQL, read the users table, and return the first 100 records in reverse order according to registration time
Claude Code will judge the language and style based on your project's technology stack. If your project is TypeScript + Prisma, it will generate TypeScript code; if it is a Django project, it will generate Python code.
4. Advanced Usage: Make it truly your programming partner
Basic commands can solve a single point problem, but the real power of Claude Code lies in task orchestration and context management. Mastering the following skills can take your efficiency to a higher level.
4.1 Smart use of context windows
Claude Code's context window is not unlimited. When a project is large, you need to help focus it. The method is simple: clearly specify the scope when asking questions.
# Let Claude Code only see this file
/read src/controllers/orderController.ts
Then tell me where the performance bottleneck of this controller is
# Or use the @ symbol to reference specific files
Help me optimize database queries, refer to @src/db/querys.ts and @tests/db.test.ts
When you need to switch to a completely different module, use the '/clear' command to clear the context to prevent previous information from interfering with new tasks.
4.2 Automated multi-step task execution
Claude Code supports the use of slash commands to trigger complex automated processes. You can let it complete a complete workflow, such as "refactor a module and update related tests":
Refactor the payment module in the src/payment/directory, extract the common logic to utils/payment.ts, then update all places where it is called, and finally run tests to ensure there is no regression
Claude Code breaks this task into multiple steps: reading the file → analyzing the structure → extracting public code → modifying the caller → running the test. It displays the plan before each step is executed, and you can choose to skip a step or adjust the order.
4.3 Pattern and rule configuration
If your project has special coding specifications, you can place a .claude configuration file in the project root directory to tell Claude Code to follow these rules:
{
"rules": [
"All API responses must be wrapped in the { success, data, error } format",
"Forbidden to use var, only use const and let",
"Database connections must use connection pooling"
]
}
This way, every time Claude Code generates code, it will automatically follow these rules, reducing the amount of work you need to modify.
4.4 Integrate with existing tool chains
Claude Code is not an isolated tool; it works seamlessly with your existing development environment.
Cooperation with VS Code: Claude Code itself is a terminal tool, but you can place the terminal panel on the side of VS Code and operate both sides at the same time. The experience of copying and pasting code snippets is smooth.
Cooperate with Git workflows: Claude Code understands Git status. When you work on a feature branch, it automatically determines which files have been changed, how commit information should be written, and whether branch names meet specifications.
Working with Docker: If your project is running in a Docker container, let Claude Code execute commands inside the container:
/run Run Run the project's test suite in the Docker container and report coverage
5. Scenario solutions
Scenario 1: Dealing with Legacy Code
Legacy code is one of the most troublesome scenarios-no testing, no documentation, and confusing logic. Traditional practice is to spend a few days reading line by line and then carefully changing it.
The way to use Claude Code is:
-
Let it scan the entire module first and create a code map:
/analyze src/legacy/payment-module/It will output the module structure, function call graph, and data flow graph.
-
Ask it key questions:
What is the entry function for this module? What are the main business processes? -
Let it help you write test cases (first cover the status quo to prevent subsequent refactorings from damaging functions):
Generate integration tests for payment-module, covering major business processes -
Start refactoring, changing only one small piece at a time:
Extract the validatePayment function from payment.ts to src/utils/payment-validator.ts
Scenario 2: Code Review speeds up
Code reviews are often time-consuming, especially for large PRs. Claude Code can help you with your first round of review:
/review review this PR: github.com/xxx/repo/pull/123
Focus on: Whether there are security vulnerabilities, whether they comply with project specifications, and whether test coverage is sufficient
It will list specific problem points, severity and modification suggestions. You just need to review its conclusions, saving time reading line by line.
Scenario 3: Quickly build new functions
When you need to implement a new feature but are not sure where to start:
Implement an image upload function: support drag-and-drop upload, limit to 5MB, return to CDN links
Project technology stack: Next.js + Prisma + AWS S3
Claude Code generates a complete implementation based on the technology stack-including front-end components, back-end interfaces, file storage logic, and error handling. You then adjust the details based on the actual situation, rather than writing from scratch.
6. Practical cases
Case 1: API migration from three days to three hours
Xiao Li is a back-end engineer for an e-commerce company. The company decided to migrate its user authentication system from JWT to OAuth 2.0, involving changes to 12 microservices and more than 200 interfaces. The team estimated that the task would take three people for three weeks.
Xiao Li first used Claude Code to scan all code files involving certification:
/scan Scan all files involved in JWT token generation and verification in the src/directory, and list the change points for each file
Claude Code outputs a complete list of files and changes in 30 seconds. Xiao Li made a migration plan based on this list, and then used Claude Code to process each service one by one:
Migrate the JWT implementation of auth-service to OAuth 2.0, retaining the original user role permission logic
Claude Code is responsible for changing code, writing tests, and updating document comments. Xiao Li's role became a "reviewer"-every time a service is changed, he checks the output of Claude Code to make sure the logic is correct, and then merges it.
In the end, the migration mission completed the transformation of core services within 3 days, and the test coverage rate remained above 95%. Li said: "The biggest gain is not speed, but Claude Code helped me find some implicit dependencies that I didn't notice myself. For example, a log module directly reads the userId field in token, which needs special handling when JWT is changed to OAuth. "
Case 2: Newcomers take over unfamiliar projects independently
Xiao Wang is a recent graduate and is assigned to maintain a Node.js back-office management system. This project was written three years ago on the technology stack, using Express + Sequelize, and the code style is completely different from what was taught in school.
Her first task was to "fix a bug where user list pagination didn't work." Traditional practice is to look at the code for half a day and try the parameters for half a day.
She asked Claude Code directly:
The paging function of the user list does not work. The URL parameters page and limit are passed but have no effect.
After Claude Code read the routing file, controller, and model definitions, it located the problem: the controller received paging parameters but did not pass it to Sequize's query method. It also points out another hidden danger-there is no type verification for page and limit, and if a non-number is passed, an error will be reported directly.
Xiao Wang asked Claude Code to fix the problem and then asked a broader question:
Help me understand the overall architecture of this project, focusing on modules related to user management
Claude Code draws a module dependency diagram that explains data flow and key business logic. Xiao Wang said: "I figured out how the system worked that afternoon, much faster than I expected. After that, I began to dare to change things myself. "
7. Performance comparison: How fast can Claude Code be
The following is a comparison table showing the efficiency of Claude Code on several typical development tasks. The data comes from public feedback from community users and Anthropic's internal test report (2025 Q1) for reference only. The actual results vary depending on the complexity of the project.
| task type | Traditional methods take time | Claude Code auxiliary time consuming | efficiency improvement | remarks |
|---|---|---|---|---|
| Understand unfamiliar module code | 2-4 hours | 15-30 minutes | About 80% | Depending on module size |
| Locate and fix common bugs | 30-90 minutes | 5-15 minutes | About 70% | No complex logic bugs |
| write unit tests | 1-2 Hours/module | 10-20 minutes/module | About 85% | The quality of the test depends on the quality of the prompt |
| Code refactoring (safe operations) | Hours to days | 30 minutes to 2 hours | Approximately 60 - 80% | Only to the extent that Claude Code can be safely executed |
| Generating new function code skeleton | 2-4 hours | 20-40 minutes | About 85% | Requires manual review and adjustment |
One point needs to be emphasized: The prerequisite for improving efficiency is that you clearly know what you are doing. Claude Code is an accelerator, not a replacement. If you don't understand the requirements themselves, the code generated by Claude Code will deviate from direction and may even introduce errors that you can't easily detect.
8. Guide to Avoiding Pit
Claude Code is strong, but it is not everything. The following are some of the most common "pits" in community feedback. Knowing them in advance can help you avoid detours.
Pit 1: But my brain will be modified
Claude Code generates code quickly, but that doesn't mean that every change is correct. There was user feedback that asked it to "change all console.logs to logger." As a result, it also changed the temporary logs used for debugging, resulting in a surge in production environment logs.
The correct way to do this: Before making batch modifications, use the '--dry-run' mode to preview the changes, and then apply them after confirming that they are correct. Develop the habit of reviewing first and then implementing it.
Pit 2: Too long context leads to degradation of the quality of the answer
When you frequently switch topics in a large project, the context window accumulates a lot of historical information. Claude Code may begin to "forget" details mentioned earlier or confuse code from different modules.
The right way to do this: Use '/clear' to clear the context before starting each independent task, or use '/compact' to compress historical information. If the project is too large, use the '--path' parameter to restrict it to analyzing only specific directories.
Pit 3: Dangerous orders are executed without confirmation
Claude Code intercepts dangerous operations (such as deleting files and executing system commands) by default, but if you set permissionMode to accept-all, it will execute any command without hesitation. Some user accidentally asked it to delete the entire node_modules directory-although it could be npm installed again, it wasted a lot of time.
The right way to do it: Unless you are very sure that the command is safe, keep 'permissionMode: "ask". For delete operations, it is recommended to let Claude Code output only commands first, and you confirm it yourself before executing it.
Pit 4: Security advice generated by relying on AI
Claude Code can identify common security vulnerabilities during code review, but this does not mean that it can discover all issues. It has limited ability to identify security vulnerabilities at the business logic level (such as unauthorized access) because these vulnerabilities need to be judged in conjunction with business scenarios.
Correct practice: Safety-related changes must be reviewed manually. Claude Code's safety advice is a supplement to, not a substitute for, professional safety audits.
Pit 5: The generated code does not meet the project specifications
Claude Code sometimes generates code with inconsistent styles-for example, if you use ESLint strict mode, it generates code that ignores lint rules. Or if you use the TypeScript strict mode, the code it generates lacks type annotations.
Correct approach: Clarify the project specifications in . claude/rules.json, or add constraints every time code is generated, such as "ESLint must be passed" and "TypeScript strict mode must be used."
9. Advanced optimization skills
Tip 1: Carefully design prompt words
The output quality of Claude Code is highly dependent on your prompt words. A good reminder should contain three elements: context (which project and what scenario are you working on), goals (what to accomplish), and constraints (what are the limitations).
# Common prompt words
Write a sorting function
# Optimized prompt words
Add a new function Priority for the sorting module in the src/utils/directory,
Receives an array of objects, each with two fields, id and priority,
Sort them in descending order of priority, and ascending order of id.
Use TypeScript to add complete type annotations.
The latter generates significantly higher quality code and the format is more in line with project specifications.
Tip 2: Use Slash Commands to improve efficiency
Claude Code provides a series of slash commands that can quickly trigger specific functions without having to write a complete natural language description every time:
/test-Generate test cases/review-Code review/explain-Explain the code/refactor-Refactor code/search-Search for code in the project
Proficiency in using these commands can more than double the interaction speed.
Tip 3: Let Claude Code maintain a change log
Each time you complete a task, let it update CHANGELOG:
/update-changelog Record today's changes: Fixed paging bug and added image upload function
If you persist for a long time, you will have a complete record of project changes, which is much easier than manual maintenance.
Tip 4: Combine MCP (Model Context Protocol)
Claude Code supports the MCP protocol and can connect to external tools and data sources. For example, after connecting to the database, you can ask it directly:
Check the number of new users registered in the past week, grouped by city
It generates SQL, executes queries, returns results, and even helps you draw charts. If you have multiple data sources (databases, APIs, logging systems), MCP can concatenate them to give Claude Code the ability to reason across tools.
Tip 5: Build a personal knowledge base
Store your commonly used project architecture documents, coding specifications, and team agreements in a fixed location. Ask Claude Code to read these documents before starting a new task:
/load .claude/project-knowledge.md
Then tell me the deployment process of this project
In this way, Claude Code's answer will be more consistent with the actual situation of the team, rather than general remarks.
10. Daily maintenance suggestions
Integrating Claude Code into your daily workflow
Don't just use it when you have a problem. Think of it as a programming partner on call. For example, spend five minutes every morning asking it to report on the health status of the project:
Run test suite and report results
Check recent Git submissions to see if they introduce obvious issues
Update completed tasks at TODO.md
This lightweight daily interaction allows you to remain sensitive to the status of your project and allows Claude Code to better understand your project.
Regularly clean up context and cache
Claude Code caches project analysis results to improve response speed, but this cache may expire after major code changes. It is recommended to run at regular intervals:
/refresh
Have it re-scan the project structure to ensure that the analysis results are up to date.
Maintain critical thinking about AI output
This is the most important point. Claude Code can help you write code, but it cannot think about business logic for you. Before accepting its advice each time, ask yourself three questions: Does this change meet your needs? Will it destroy existing functions? Does the code style meet team specifications? If the answer is yes, then implement it.
Record your experience
Everyone's project characteristics are different, and the performance of Claude Code in different scenarios is also very different. It is recommended to develop the habit of recording experience-which prompts work well, which pits it has stepped on, and which scenes it is particularly good at. By settling down these experiences, your use of Claude Code will become more and more efficient.
XI. Summary
Claude Code is not a silver bullet, but it is indeed one of the most practical terminal programming assistants available today. There are three scenarios where it is best at: understanding unfamiliar code, dealing with repetitive coding tasks, and accelerating code review and refactoring. In these three scenarios, it can save you a lot of time and allow you to focus on the parts that really need to be thought about.
The core principle of using it is simple: You make decisions, they implement them. Don't give it the power of "what to do", but you can give it the details of "how to do". Think of Claude Code as an efficiency tool, not an intern-it can be executed, but your judgment needs to be controlled.
Now, open the terminal, install Claude Code, and choose a small project to try. You may find that things that used to take half an hour can now be done in ten minutes.