Skip to content

Claude Code Configuration ​

1. Install Claude Code ​

1.1. macOS / Linux / WSL Installation ​

  • macOS: Press ⌘ Command + Space, type Terminal and press Enter

  • Linux: Click the application menu in the bottom-left corner, search for Terminal and press Enter

Run the following command in Terminal to install Claude Code:

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

Verify Claude Code Installation

After installation is complete, enter the following command to check if the installation was successful:

1.2. Windows Installation ​

Click the "Start" button, type "powershell" in the search box, and open the terminal with administrator privileges:

Run:

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

Tip

It is recommended to use PowerShell instead of CMD, as it has more features

If you encounter permission issues, run PowerShell as administrator

Verify Claude Code Installation

After installation is complete, enter the following command to check if the installation was successful:

2. Set Environment Variables ​

2.1. macOS / Linux / WSL Configuration ​

Refer to Section 1.1, open Terminal, and edit your shell configuration file (based on the shell you use):

For zsh (default):

shell
# Add Claude Code environment variables to ~/.zshrc file:
echo 'export ANTHROPIC_BASE_URL={{apiUrl}}' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="■■API■■"' >> ~/.zshrc
echo 'export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1' >> ~/.zshrc
# Apply the configuration:
source ~/.zshrc

For bash:

bash
# Add Claude Code environment variables to ~/.bash_profile
echo 'export ANTHROPIC_BASE_URL={{apiUrl}}' >> ~/.bash_profile
echo 'export ANTHROPIC_AUTH_TOKEN="your_API_key"' >> ~/.bash_profile
echo 'export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1' >> ~/.bash_profile
# Apply the configuration:
source ~/.bash_profile

2.2. Windows Configuration ​

Run the following commands in PowerShell to set user-level environment variables:

markdown
```powershell
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", {{apiUrl}}, [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "■■API■■", [System.EnvironmentVariableTarget]::User)
[System.Environment]::SetEnvironmentVariable("CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS", "1", [System.EnvironmentVariableTarget]::User)
```

Or set system environment variables directly:

3. Getting Started ​

After installation is complete, enter claude in the project root directory:

You can interact with it directly through conversation:

  • Explore codebase: claude "Explain how the permission validation logic is implemented in this project"

  • Fix Bug: claude "Fix the 500 error during user login, refer to the error messages in logs/error.log"

  • Write tests: claude "Write unit tests for auth.service.ts and run them until all tests pass"

  • Automate tasks: claude "Update all outdated API calls in the project to v2 and run lint to fix formatting"

3.1. Essential Commands ​

In the claude interactive interface, you can use slash commands for interaction:

Common commands are described below:

3.2. VS Code Usage ​

In VS Code, press Cmd+Shift+X (Mac) or Ctrl+Shift+X (Windows/Linux) to open the Extensions view, search for "Claude Code", and click Install.

Open Claude Code Panel

After successful installation, the fastest way to open Claude is to click the Claude Code icon in the editor toolbar (top-right corner of the editor). This icon appears only when a file is open.

Other ways to open Claude Code:

  • Command Palette: Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux), type "Claude Code", then select an option such as "Open in New Tab"

  • Status Bar: Click ✱ Claude Code in the bottom-right corner of the window. This works even without a file open.

Send Prompts

Ask Claude for help with code or files, whether it's explaining how something works, debugging issues, or making changes. Claude automatically sees text selected by the cursor. Press Option+K (Mac) / Alt+K (Windows/Linux) to also insert into the prompt.

Here is an example of asking about a specific line in a file:

Review Changes

When Claude wants to edit a file, it displays a side-by-side comparison of the original content and suggested changes, then requests permission. You can accept, reject, or tell Claude what to do instead.

4. Usage Tips ​

4.1. Use /clear Promptly ​

Don't chat too long in one session. When a task (like fixing a bug) is complete, immediately enter /clear. Outdated context will be resent with every new message, incurring unnecessary costs.

4.2. Use the CLAUDE.md File ​

Create a CLAUDE.md in the project root directory. Write your project specifications here (e.g., always use TypeScript, testing framework is Vitest, indent with 2 spaces).

  • Benefit: This way you don't need to repeat these requirements in every conversation, reducing input tokens.

4.3. Control "Thinking" Budget ​

For simple tasks (like writing a Regex), you can lower MAX_THINKING_TOKENS or disable the thinking feature in /config to reduce output tokens.

4.4. Use Plan Mode Effectively ​

Before asking Claude to make large-scale changes, press Shift + Tab to enter Plan Mode.

Let it state the plan first, then you confirm before execution. This prevents it from misunderstanding and making wild code changes, resulting in both high costs and manual rollbacks.

4.5. Using 1M Context Claude Model ​

  1. If not the latest installation, you need to run the upgrade command to upgrade Claude Code to the latest version
json
claude update
  1. If the following environment variable is not set, add it
json
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
  1. In Claude, enter /model to switch models: