Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI How-Tos

Claude Code Complete Hands-On Guide: One-Stop Solution for Installation, Domestic Model Configuration and Advanced Practice

2025-09-25 83

AI programming tools are evolving from passive code "patchers" to active "development partners". They are able to understand complex requirements, plan tasks, and participate directly in the entire development process. In this article, we'll take an in-depth look at one command-line AI programming tool that represents this trend - a tool we'll call Claude Codeand provides a detailed and complete guide to its use.

Ideas for a new generation of AI programming assistants

Unlike the familiar IDE plugins, theClaude Code Such tools choose an interface that is closer to the developer's core workflow - the command line (CLI).

Claude Code 命令行界面
The command line interface is simple and efficient

This design is no accident. For developers, the command line is lightweight, scriptable, and integrates seamlessly with tools like Git. Injecting AI capabilities into this heartland makes it part of the workflow rather than an isolated feature. Tools in the same category include Ali's Qwen Code and Google's Gemini CLIThe

Qwen Code Screenshot   Gemini CLI Screenshot
Similar CLI AI Programming Tool Interfaces

Powerful modeling and API ecosystem

Claude Code 的能力源于背后顶尖的大语言模型,例如由 Anthropic Company developed Claude 3 Opus,Claude 3.5 Sonnet Anthropic was founded by former OpenAI core member Dario Amodei, and its models are perennial industry leaders in programming and reasoning.

even though Claude Code The official Anthropic model is used by default, but its high cost limits its use by individual developers. Fortunately, with configuration, we can plug it into more cost-effective homegrown models such as Wisdom Spectrum's GLM-4.5 Or the Dark Side of the Moon. Kimi K2The

A key technical detail is the API format. While most big models are compatible with the OpenAI call format, Anthropic has its own set of specifications.Claude Code The Anthropic format is used, so model service providers that also support this format are natively supported. For models that only support the OpenAI format, you will need to bridge them with a conversion tool.

In addition.Claude Code It is a well-designed intelligence with built-in System Prompts that are deeply optimized for Anthropic's own model features. When replacing it with a third-party model, there may be about 5% until 20% The loss of effect. However, for the vast majority of development scenarios, this impact is within acceptable limits as long as the requirements are clearly described.

From "assistant" to "partner"

Traditional AI programming plug-ins, such as the early Tongyi Linguistic Code, are limited by model capabilities and context length, and mainly serve as "clipboards" and one-shot dialog tools.Claude Code This new generation of tools is able to understand the entire project folder, with autonomous planning and multitasking capabilities for complex tasks.

Instead of just generating code snippets, it can directly edit files, run tests, execute build commands, and even handle Git commits. The role of the developer shifts from being the "doer" of tasks to being the "delegator" of complex projects, entering a so-called "world of work". VibeCoding(Ambient Programming) state - define requirements, design architecture, and then oversee the AI through specific coding tasks.

Complete Guide to Installation and Configuration

This tutorial uses macOS as an example, the procedure is similar for Windows.

Step 1: Quick Installation

Ensure that Node.js is installed on your system (version >= 18), and then run the following command to install it globally:

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

After the installation is complete, execute in any project directory claude command to start it.

# 进入你的项目目录
cd your-awesome-project
# 启动 Claude Code
claude
# 首次使用时,可能会提示登录

Step 2: Handling regional constraints and configuring domestic models

If you encounter a message that a region is not available on your first run, you can configure environment variables to proxy the request to a domestic modeling service provider that is compatible with the Anthropic API format.

地区限制提示
Problems with regional restrictions that may be encountered during the initial run

Open the terminal's configuration file (macOS defaults to .zshrc), add the following two lines:

# 使用 vi 编辑配置文件。新手提示:打开后按 i 进入插入模式,
# 粘贴内容后按 ESC,然后输入 :wq 回车即可保存退出。
vi ~/.zshrc

Add the following to the file:

export ANTHROPIC_BASE_URL=你的模型调用地址
export ANTHROPIC_API_KEY=你的API密钥

After saving and exiting, be sure to execute the source ~/.zshrc command to make the configuration take effect immediately.

Configuration example 1: Smart Spectrum GLM-4.5 model

  1. Registering and Obtaining an API Key: AccessSmart Spectrum AI Open PlatformRegister withAPI Key Management PageCreate a new Key.
    创建智谱API Key
  2. Optional Packages (Optional): Smart Spectrum provides developers with cost-effectiveProgramming Packages, about $20 for the first month, with plenty of calls.
    智谱AI编程套餐
  3. Configuring Environment VariablesAnthropic-compatible address of Smart Spectrum is https://open.bigmodel.cn/api/anthropicThe
    export ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
    export ANTHROPIC_API_KEY=粘贴你的智谱API密钥
    
  4. Configuration in effect and reboot: Implementation source ~/.zshrc After that, re-run the claude Command.

Configuration example 2: Dark Side of the Moon Kimi K2 model

  1. Register & Recharge: AccessDark Side of the Moon Developer PlatformRegistration. To ensure the call rate, it is recommended to recharge $50 or more.
    Kimi充值速率等级
  2. Get API Key: Create a new API Key in the backend management system.
    创建Kimi API Key
  3. Configuring Environment Variables: Kimi's Anthropic-compatible address is https://api.moonshot.cn/anthropic/The
    export ANTHROPIC_BASE_URL=https://api.moonshot.cn/anthropic/
    export ANTHROPIC_API_KEY=粘贴你的KimiAPI密钥
    
  4. Configuration in effect and reboot: Implementation source ~/.zshrc After that, re-run the claude Command.

Step 3: Route to any OpenAI format model

To use a model that only supports the OpenAI format (e.g., Tongyi Qianqian), use the ClaudeCodeRouter middleware to perform the conversion.

  1. Installing the Router::
    npm install -g @musistudio/claude-code-router
    

    Its main features include model routing, multi-provider support, and request/response transformation.

  2. Launching the configuration interface::
    ccr ui
    

    In the web page that opens, add the model provider, select the template and fill in the API Key and model name.
    Claude Code Router 配置界面
    添加模型供应商

  3. Configuring Routing::
    In the routing section on the right, point different tasks (e.g. thinking, long context) to the model you just added, then save and restart.
    配置模型路由
  4. activate (a plan) Claude Code::
    utilization ccr code command is started, the configured model can be used through this route.
    通过Router启动

Step 4: Integration into the IDE

Claude Code Enhanced plug-ins for VS Code and JetBrains family of IDEs (IntelliJ IDEA, WebStorm, etc.) are provided, which can be launched with one click from within the IDE for smoother interaction.

在IDE插件市场搜索 Claude Code
Installing plug-ins in the IDE

通过IDE右上角按钮启动
One-touch start, seamless integration

Core Usage Tips Explained

Basic Interaction

  • @ notation: Reference a file or directory to add to the context.
  • # notation: Define memories or rules that the AI will follow in subsequent interactions.
  • ! notation: Temporarily switch to bash mode to execute shell commands.
  • ESC linchpin: Interrupts the currently executing task.
  • multi-line input: Use Shift+Enter maybe Option+Enter (macOS) Enter multi-line text. You can run /terminal-setup mounting Shift+Enter Shortcuts.

List of all commands

importation / The command menu can be called up, and the following is a complete list of commands:

/add-dir                  添加一个新的工作目录
/agents                   管理代理配置
/bashes                   列出和管理后台任务
/clear (reset, new)       清除对话历史并释放上下文
/compact                  清除对话历史,但在上下文中保留摘要。可选:/compact [摘要说明]
/config (theme)           打开配置面板
/context                  将当前上下文使用情况可视化为彩色网格
/cost                     显示当前会话的总成本和持续时间
/doctor                   诊断并验证您的 Claude Code 安装和设置
/exit (quit)              退出 REPL
/export                   导出当前对话到文件或剪贴板
/feedback (bug)           提交关于 Claude Code 的反馈
/help                     显示帮助和可用命令
/hooks                    管理工具事件的钩子配置
/ide                      管理 IDE 集成并显示状态
/init                     使用代码库文档初始化一个新的 CLAUDE.md 文件
/install-github-app       为代码仓库设置 Claude GitHub Actions
/login                    使用您的 Anthropic 帐户登录
/logout                   从您的 Anthropic 帐户注销
/mcp                      管理 MCP 服务器
/memory                   编辑 Claude 内存文件
/migrate-installer        从全局 npm 安装迁移到本地安装
/model                    设置 Claude Code 的 AI 模型
/output-style             直接或从选择菜单设置输出样式
/output-style:new         创建一个自定义输出样式
/permissions              管理允许和拒绝工具的权限规则
/pr-comments              从 GitHub 拉取请求中获取评论
/release-notes            查看发行说明
/resume                   继续一个对话
/review                   审查一个拉取请求
/security-review          完成对当前分支上待定更改的安全审查
/status                   显示 Claude Code 状态
/statusline               设置 Claude Code 的状态行用户界面
/terminal-setup           安装 Shift+Enter 换行快捷键
/todos                    列出当前的待办事项
/upgrade                  升级到 Max 以获得更高的速率限制
/vim                      在 Vim 和普通编辑模式之间切换

In-depth analysis of common commands

  • /init:: Scanning project generation CLAUDE.md, contains summaries of the technology stack, architecture, etc. to help AI quickly understand the project.
  • /compact: Summarize long conversation histories to preserve key information, conserve Token and keep AI focused.
  • /clear: Empty the current conversation completely and open a new one.
  • /resume:: Restore recent dialog history and continue previous tasks.
  • /memory: Edit a series of Markdown files to define long-term behavioral preferences (e.g., coding style, personality) for the AI. These files are located in the ~/.claude directory, divided into global and project level. For example.rules.md The file can contain the following programming principles:
    你的任务是:**审查、理解并迭代式地改进/推进一个[项目类型,例如:现有代码库 / 软件项目 / 技术流程]。**
    在整个工作流程中,你必须内化并严格遵循以下核心编程原则,确保你的每次输出和建议都体现这些理念:
    - **简单至上 (KISS):** 追求代码和设计的极致简洁与直观,避免不必要的复杂性。
    - **精益求精 (YAGNI):** 仅实现当前明确所需的功能,抵制过度设计和不必要的未来特性预留。
    - **坚实基础 (SOLID):**
    - **S (单一职责):** 各组件、类、函数只承担一项明确职责。
    - **O (开放/封闭):** 功能扩展无需修改现有代码。
    - **L (里氏替换):** 子类型可无缝替换其基类型。
    - **I (接口隔离):** 接口应专一,避免"胖接口"。
    - **D (依赖倒置):** 依赖抽象而非具体实现。
    - **杜绝重复 (DRY):** 识别并消除代码或逻辑中的重复模式,提升复用性。
    - **文档同步 (Doc Sync):** 代码变更必须同步更新相关文档,保持一致性。
    **请严格遵循以下工作流程和输出要求:**
    1.  **深入理解与初步分析(理解阶段):**
        - 详细审阅提供的[资料/代码/项目描述],全面掌握其当前架构、核心组件、业务逻辑及痛点。
        - 在理解的基础上,初步识别项目中潜在的**KISS, YAGNI, DRY, SOLID**原则应用点或违背现象。
    2.  **明确目标与迭代规划(规划阶段):**
        - 基于用户需求和对现有项目的理解,清晰定义本次迭代的具体任务范围和可衡量的预期成果。
        - 在规划解决方案时,优先考虑如何通过应用上述原则,实现更简洁、高效和可扩展的改进,而非盲目增加功能。
    

Advanced Features: Customization and Automation

customizable command

Encapsulate common complex tasks into custom commands. Simply write a Markdown file containing the prompt (the filename is the name of the command, e.g. add-changelog.md), put in the ~/.claude/commands/ directory, reboot to pass the /add-changelog Call. Community Sites https://www.buildwithclaude.com/ A large number of preset commands are provided for download.

Subagents system

Create multiple dedicated "sub-intelligences" (e.g., front-end specialists, UX designers), and the main intelligence can automatically break down and assign tasks based on complex requirements, realizing parallel collaboration across multiple roles.

pass (a bill or inspection etc) /agents Command management with the option to have AI assist create new agents or import presets from the community.

创建UX设计师子代理
AI-assisted creation of subagents

When dealing with a task that includes UI design, the main intelligent body will call the UX designer first, and then code after the design is confirmed.The AI will generate a TodoList when executing the task and complete it item by item, with a highly transparent workflow.

UX设计师子代理的产出

Hooks system

Automatically triggers a command when a specific event occurs (e.g., after a file has been edited). The commands are automatically triggered by the /hooks Instruction management for automated processes such as automatic formatting and permission control.

Example: Automatic formatting with Prettier after editing a TS file

{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|MultiEdit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -q '\\.ts$'; then npx prettier --write \"$file_path\"; fi; }"
}
]
}
]
}
}

Community tools claudecode-rule2hook Support for generating hook configurations in natural language.

Configuring MCP Server

MCP (Machine-to-Claude Protocol) is a protocol that allows external tools and services to communicate with the Claude Code protocols for communication, which can be extended with capabilities such as connecting to Jira, Notion, and so on.

  • Adding a local Stdio MCP Server:
    claude mcp add airtable --env AIRTABLE_API_KEY=YOUR_KEY -- npx -y airtable-mcp-server
    
  • Add SSE MCP Server:
    claude mcp add --transport sse linear https://mcp.linear.app/sse
    
  • Managing MCP Server:
    # 列出所有服务器
    claude mcp list
    # 删除服务器
    claude mcp remove github
    

Cue Words and Work Patterns Tips

XML tag structuring tips

Using XML tags to wrap instructions, context, and examples helps Claude understand your intent more precisely.

<instruction>
你希望 Claude 执行的主要任务或目标
</instruction>
<context>
任务的背景信息,比如涉及的框架、业务逻辑、团队规范等
</context>
<code_example>
可以参考的代码片段、接口规范或已有实现
</code_example>

Three operating modes switching

utilization Shift+Tab Cycle switching:

  1. normal mode: Default mode, user approval is required before performing operations such as file editing.
  2. Auto acceptance mode: All operations are approved by default and the AI has full control.
  3. planned model: The AI only plans and generates a list of tasks without performing any actual operations.

三种工作模式

Other useful tools and resources

  • regression history: double-click ESC Dialog nodes can be rolled back. For code change rollbacks, use the community tool ccundo (npm install -g ccundo).
  • Visual Configuration Tool opcode:: Website https://opcode.sh/ Provides a powerful web interface for visualization management Claude Code of all configurations, including custom commands, hooks, permissions, etc.
    opcode.sh 可视化配置界面
    opcode.sh 功能展示
  • Claude Official Chinese Guideofficial document Provides the most comprehensive and authoritative introduction to the functions and instructions for use.
    Claude 官方中文指南

A new generation of AI programming tools is reshaping development workflows, freeing developers from tedious coding execution to focus more on architectural design and business innovation. To master them is to embrace the development paradigm of the future.

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish