AI Study Online

Complete Practical Tutorial: Master All Core Operations Inside Claude Code

5 min read
📚 AI Tutorials 🕒 10 min read 📅 Jul 7, 2026 🎯 Intermediate

Introduction

Claude Code has become the top AI coding assistant favored by most developers for its powerful file reading, project refactoring, debugging and autonomous running capabilities. This full practical tutorial covers every core operation step by step, helping beginners get started quickly and helping senior developers maximize its productivity. All operations are matched with executable code snippets and command lines for direct replication.

1. Basic Environment Preparation & Project Import

1.1 Install and Launch Claude Code CLI

Open your local terminal and run the installation command:

npm install -g @anthropic-ai/claude-code

After installation, verify successful installation with this command:

claude-code --version

1.2 Import Local Project Folder

Switch to your project root directory in terminal first:

cd /Users/yourname/Desktop/my-project

Start Claude Code workspace binding:

claude-code init

This command generates a hidden .claude/ configuration folder, which stores project rules, conversation records and permission settings automatically.

1.3 Configure API Key

Run the login command to bind your Anthropic API key:

claude-code login

Paste your API key when prompted, and the tool will automatically save credentials locally without repeated input.

2. Core File Reading & Batch Analysis Functions

Claude Code can scan the entire project instead of single files like ordinary chatbots.

2.1 Read Entire Project Codebase

Input this natural language instruction inside Claude Code dialogue box:

Scan all .js and .ts files under src folder, sort out all unused functions and output a formatted list

2.2 Targeted Single File Deep Analysis

Command for analyzing specific files via terminal:

claude-code analyze ./src/utils/request.ts

The output will include code logic explanations, potential bugs, optimization suggestions and redundant code extraction.

3. One-Click Code Refactoring Operation

3.1 Batch Refactor Old Syntax

Enter the prompt inside Claude Code panel:

Refactor all var declarations in this project to const/let, add standardized JSDoc comments for all exported functions, and run format after modification

Claude Code will traverse all target files, modify code automatically and format files with ESLint/Prettier.

3.2 Component Structure Optimization (Frontend Demo)

Sample refactor task prompt for React projects:

Split the monolithic Home page component into PageHeader, ContentList and Footer sub-components, extract repeated styles into separate css module files

4. Automatic Debugging & Error Repair

4.1 Upload Error Logs for Intelligent Fixing

Copy your project crash log and send it with this fixed prompt template:

Check the following error log, locate the root cause in project files, write the complete modified code and explain the repair logic:
[Paste your error log here]

4.2 Run Test Script Automatically to Verify Fixes

After code modification, execute test commands directly inside Claude Code dialogue:

Run npm test and check if all unit tests pass, fix failed test cases automatically

Terminal execution command shortcut:

claude-code run-test

5. Custom Project Rules via claude.md

Create a claude.md file under project root to lock uniform development standards, sample content:

# Global Code Rules for This Project
1. All new functions must carry type annotations
2. Do not use any deprecated npm packages
3. Every code change needs corresponding unit test writing
4. Automatically generate git commit message after each modification

After saving, every subsequent dialogue task will strictly follow rules in this file without repeated manual reminder.

6. Git Linkage & Automated Commit Workflow

6.1 Auto Generate Standard Commit Information

After Claude Code finishes modifying code, input this instruction:

Check all changed files, generate concise standardized commit message, execute git add and git commit automatically

6.2 Terminal Git Operation Command Set

# View all modified files scanned by Claude Code
claude-code git-diff
# Auto commit changes with AI-generated message
claude-code git-commit

7. Multi-Step Complex Task Planning Mode

For large-scale cross-file reconstruction, enable Plan Mode first to avoid chaotic modification:

Enable plan mode, split the task "transform vanilla js project to Vue3 + Vite project" into detailed executable steps, confirm the plan with me before executing any code changes

Claude Code will output a complete step-by-step plan list, waiting for your manual approval before operating project files.

8. Permission Control & Safety Settings

8.1 Adjust File Operation Permission

Enter settings command in terminal:

claude-code config permission

Three optional permission modes:

  1. Prompt before every file write operation (recommended for beginners)
  2. Auto approve safe read/write operations only
  3. Full access mode (only for trusted local private projects)

8.2 Block Sensitive File Access

Add paths to blacklist in .claude/config.json to prevent accidental modification of configuration files:

{
  "fileBlacklist": [".env", "package-lock.json", "database/config.js"]
}

9. Common Practical Tips to Boost Efficiency

  1. Shortcut: Use claude-code chat to quickly open dialogue window without opening full desktop client
  2. Context cleaning command to avoid context overflow: claude-code clear-context
  3. Export conversation records for backup: claude-code export-log chat_record.json
  4. For large projects exceeding token limits: Split tasks by folders, do not scan the whole project at one time

Conclusion

Claude Code's core advantage lies in its deep local project interaction capability, far exceeding ordinary web AI chat tools. Master the above terminal commands, file operation logic and plan/refactor workflow, you can cut 70% repetitive coding, debugging and sorting work. Beginners are suggested to start from basic file analysis and single-file refactoring, then gradually try multi-step complex transformation tasks after getting familiar with permission and rule configuration.

常见问题

Claude Code CLI vs desktop app — which should I use?

The CLI version is more powerful and flexible — it's the one developers use for serious work. The desktop app has a nicer UI but lacks some CLI features like claude-code git-commit and claude-code analyze. If you're comfortable with a terminal, go CLI. If you're a beginner or prefer visual interfaces, start with the desktop app and gradually learn CLI commands as you need more power. The good news: both share the same project configuration (.claude/ folder and claude.md rules), so you can switch between them freely.

How is claude.md different from agent.md (used by Codex)?

They serve the same purpose — project-level instructions that the AI follows in every conversation — but use different filenames. Claude Code reads claude.md (or CLAUDE.md) from the project root. Codex reads agent.md. If you work with both tools, you can create both files with the same content, or create a symlink. The format is identical: plain markdown with rules, conventions, and preferences. Neither tool reads the other's file, so dual-tool users need both.

What's the difference between Plan Mode and just asking Claude Code to do a task?

In normal mode, Claude Code starts executing immediately — it reads files, makes changes, and runs commands as it goes. This works great for small tasks but can go off the rails on complex multi-file refactors. Plan Mode forces Claude Code to think first, act later: it outputs a complete step-by-step plan and waits for your approval before touching any files. This is critical for tasks like "migrate from JavaScript to TypeScript" or "restructure the entire component tree" where a wrong first step cascades into hours of cleanup.

Can I use Claude Code with models other than Claude?

Yes, via CC Switch (a community tool). It lets you route Claude Code's API calls to alternative models including domestic Chinese models. The experience won't be identical — Claude Code's harness engineering is optimized for Claude models — but for basic coding tasks, the difference is often negligible. Many developers use Claude models for complex refactoring and debugging, then switch to cheaper models for routine tasks like adding comments or formatting. This hybrid approach can cut API costs by 50%+ without sacrificing quality on critical work.

📖 Next Steps

Mastered Claude Code operations? Level up your development workflow:

Share this article