Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Claude Code Getting Started Tutorial

Claude Code Getting Started Tutorial

Claude Code is Anthropic's official CLI-level agent tool.

Claude Code is positioned not for chatting, but for executing high-privilege, context-aware engineering tasks in your local code repository.

Claude Code is an Agent, not a Chat.

See the detailed tutorial:https://www.runoob.com/claude-code/claude-code-tutorial.html

Core capabilities:

Installation and Configuration

MacOS/Linux:



curl -fsSL https://claude.ai/install.sh | bash

Homebrew (MacOS):



brew install --cask claude-code

Windows:



irm https://claude.ai/install.ps1 | iex

NPM:

Install with npm. Make sure Node.js is installed on your system, version v18 or higher.



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

Next, enter the project directory you created and start using Claude Code:

cd your-project

claude

Log in to your account

When starting an interactive session with the claude command, you need to log in:

claude

# You will be prompted to log in the first time

/login

# Log in using your account as prompted

If you can use an Anthropic account normally, you can start using it; if not, in China you can use DeepSeek or GLM, etc.


Connecting DeepSeek to Claude Code

After installing Claude Code, set the following environment variables in the terminal:

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic

export ANTHROPIC_AUTH_TOKEN=<你的 DeepSeek API Key>

export ANTHROPIC_MODEL=deepseek-v4-pro[1m]

export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro[1m]

export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro[1m]

export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash

export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash

export CLAUDE_CODE_EFFORT_LEVEL=max

Parameter Description:

Then enter the project directory and run the claude command to start using it.

cd my-project

claude

Reference documentation:https://api-docs.deepseek.com/zh-cn/guides/anthropic_api


Connecting Alibaba Bailian to Claude Code

The Qwen (Tongyi Qianwen) model series of Alibaba Cloud Bailian supports an Anthropic API compatible interface; by modifying the following parameters, you can call the Qwen model series in Claude Code.

macOS/Linux:

Create and open the configuration file ~/.claude/settings.json.

~ represents the user's home directory. If the .claude directory does not exist, create it first by running mkdir -p ~/.claude in the terminal.

Edit the configuration file:



vim ~/.claude/settings.json

Replace YOUR_API_KEY with your dedicated API Key.

{

    "env": {

        "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",

        "ANTHROPIC_BASE_URL": "https://dashscope.aliyuncs.com/apps/anthropic",

        "ANTHROPIC_MODEL": "qwen3-coder-plus"

    }

}

Open a new terminal for the environment variable configuration to take effect.

Windows:

Run the following commands in CMD to set environment variables:



setx ANTHROPIC_AUTH_TOKEN "YOUR_API_KEY"

setx ANTHROPIC_BASE_URL "https://dashscope.aliyuncs.com/apps/anthropic"

setx ANTHROPIC_MODEL "qwen3-coder-plus"

Replace YOUR_API_KEY with your plan's dedicated API Key.

Open a new CMD window and run the following commands to check whether the environment variables took effect.



echo %ANTHROPIC_AUTH_TOKEN%

echo %ANTHROPIC_BASE_URL%

echo %ANTHROPIC_MODEL%

Run the following commands in PowerShell to set environment variables:



# Replace YOUR_API_KEY with the plan-specific API Key

[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "YOUR_API_KEY", [EnvironmentVariableTarget]::User)

[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://dashscope.aliyuncs.com/apps/anthropic", [EnvironmentVariableTarget]::User)

[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "qwen3-coder-plus", [EnvironmentVariableTarget]::User)

Open a new PowerShell window and run the following commands to check whether the environment variables took effect.



echo $env:ANTHROPIC_AUTH_TOKEN

echo $env:ANTHROPIC_BASE_URL

echo $env:ANTHROPIC_MODEL

Connecting the Qwen model series in Claude Code

During a conversation, run /model < command to switch the model.



/model qwen3-coder-plus

You can also create the .claude/settings.json file in the project root directory and write model configuration into it for permanent configuration.

{

  "env": {

    "ANTHROPIC_MODEL": "qwen3-coder-plus",

    "ANTHROPIC_SMALL_FAST_MODEL": "qwen-flash"

  }

}

Start Claude and you can see the configuration information:


Connecting Zhipu Large Models to Claude Code

In this section we use the ~/.claude/settings.json file to configure the large model; before starting, you need to obtain an API key from the official platform:GLM Coding Plan.

Edit or create the Claude Code configuration file ~/.claude/settings.json, and add or modify the env field in it



# Note to replace your_zhipu_api_key with the API Key you obtained in the previous step

{

    "env": {

        "ANTHROPIC_AUTH_TOKEN": "your_zhipu_api_key",

        "ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",

        "API_TIMEOUT_MS": "3000000",

        "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1

    }

}

Run claude to start Claude Code, then enter /status to confirm the model status:

If not, you can enter /config to switch models.

With many large models, configuration gets troublesome; you can use the third-party tool CC Switch to easily manage the API configurations of these popular tools:https://github.com/farion1231/cc-switch/, fully supported on Windows / macOS / Linux.

Download addresses for installation packages on each platform:https://github.com/farion1231/cc-switch/releases.


Installing Claude Code in VS Code

If you do not like using Claude Code's command-line model, you can install Claude Code in the VS Code editor.

Open VS Code, go to the Extensions marketplace, and search for Claude Code Installation:

After installation, click the Claude Code icon in the upper-right corner to enter the Claude Code page:

This way, those with an account can log in using /login:

You can also enter /config in the dialog to open settings, and check the Disable Login Prompt option to close the login page:


Related command reference

Claude Code built-in command list

Command Description
/add-dir Add additional working directories
/agents Manage dedicated AI subagents
/bashes List and manage background tasks
/bug Report a bug (send the conversation to Anthropic)
/clear Clear conversation history
/compact [指令] Compress the conversation, optionally adding key instructions
/config Open the settings interface (configuration tab)
/context Visualize current context usage as a colored grid
/cost Show token usage statistics
/doctor Check Claude Code installation health
/exit Exit the REPL
/export [文件名] Export the current conversation to a file or the clipboard
/help Get usage help, show all available commands
/hooks Manage hook configuration for tool events
/ide Manage IDE integration and show status
/init Initialize a project with the CLAUDE.md guide
/install-github-app Set up Claude GitHub Actions for a repository
/login Switch Anthropic accounts
/logout Log out of the Anthropic account
/mcp Manage MCP server connections and OAuth authentication
/memory Edit the CLAUDE.md memory file
/model Select or change the AI model
/output-style [样式] Set the output style directly or choose from the selection menu
/permissions View or update permissions
/plugin Manage Claude Code plugins
/pr-comments View PR comments
/privacy-settings View and update privacy settings
/release-notes View release notes
/resume Resume a conversation
/review Request a code review
/rewind Rewind the conversation and/or code
/sandbox Enable the sandboxed bash tool, with filesystem and network isolation
/security-review Perform a security review of pending changes on the current branch
/status Open the settings interface (status tab), showing version, model, account, and connection status
/statusline Set the Claude Code status line UI
/terminal-setup Install the Shift+Enter newline key binding (iTerm2 and VSCode only)
/todos List current to-do items
/usage Show plan usage limits and rate limit status (subscription plans only)
/vim Enter vim mode, alternating between insert and command modes

Custom command types

Command type Position Description
Project commands .claude/commands/ Stored in the repository, shared with the team
Personal commands ~/.claude/commands/ Available across all projects
Plugin commands Of the plugin commands/ directory Distributed through the plugin marketplace
MCP commands Provided by MCP servers Format: /mcp__<服务器名>__<提示名>

Shell commands (not in a session)

Command Description
claude Start a Claude Code interactive session
claude -p "查询" Non-interactive mode, print the result and exit
claude --dangerously-skip-permissions Skip all permission checks (dangerous mode)
claude --debug Enable debug mode
claude --mcp-debug MCP debug mode
claude mcp add Add an MCP server
claude mcp list List configured MCP servers
claude mcp remove Remove an MCP server

Special features

Custom commands support:

Command frontmatter metadata (Frontmatter):

For more related information, you can /help view the complete list of available commands (including your custom commands).


Related Resources