1 What is Claude Code?

1.1 Overview

Claude Code is Anthropic’s official agentic command-line tool for software development. Unlike traditional code completion tools, Claude Code operates as an autonomous agent that can:

  • Read and understand your entire codebase
  • Edit multiple files simultaneously
  • Run shell commands and interpret their output
  • Interact with Git, GitHub, and external APIs
  • Plan and execute complex multi-step tasks

It runs directly in your terminal (or IDE) and has full access to your local development environment.

1.2 Key Capabilities

Capability Description
Agentic Coding Understands context, reasons about code, and takes multi-step actions
Multi-file Editing Edits files across the codebase with cross-file reasoning
Plan Mode Explores the codebase and presents a plan before making changes
Git Integration Creates commits, branches, pull requests via git and gh CLI
MCP Servers Extensible via Model Context Protocol for tools, databases, and APIs
Hooks Custom shell commands triggered on events (pre/post tool calls)
IDE Integration Works in VS Code and JetBrains via official extensions
Memory System Persists context across conversations via file-based memory

1.3 Comparison with Other Tools

Feature Claude Code GitHub Copilot Cursor
Agentic (multi-step) Yes Limited Partial
Full codebase context Yes No Yes
Runs shell commands Yes No Limited
Open-source core Yes No No
Custom model support Yes No Partial

2 Installation

2.1 Prerequisites

  • Node.js 18.0.0 or higher
  • Git (for version control features)
  • GitHub CLI (gh, optional, for PR/issue integration)

Verify Node.js is installed:

node --version
# Should show v18.x.x or higher

If Node.js is not installed, download it from https://nodejs.org or use a package manager:

# macOS (Homebrew)
brew install node

# Ubuntu/Debian
sudo apt install nodejs npm

2.2 Install Claude Code

Install globally via npm:

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

Verify installation:

claude --version

2.3 Update Claude Code

To update to the latest version:

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

3 Getting Started

3.1 Launching Claude Code

Navigate to your project directory and launch:

cd /path/to/your/project
claude

This opens an interactive REPL (Read-Eval-Print Loop) where you can chat with Claude Code in natural language.

3.2 First Steps

When you first launch Claude Code:

  1. It reads your project structure and any CLAUDE.md configuration files
  2. You can ask questions or give instructions in natural language
  3. Claude Code proposes actions and waits for your approval (permission mode)

Example prompts to try:

> What does this project do?
> Find all TODO comments in the codebase
> Help me fix the bug in src/main.py
> Refactor the database connection module
> Write unit tests for the authentication service

3.3 Useful Slash Commands

Claude Code provides built-in slash commands for common tasks:

Command Description
/help Display help and available commands
/config Open settings configuration
/clear Clear conversation history
/compact Compact the conversation to free context window
/plan Enter plan mode (explore before editing)
/review-pr <url> Review a GitHub pull request
/commit Create a git commit with AI-generated message
/fast Toggle fast mode (same model, faster output)
/loop Set up a recurring task
/tasks List background tasks

3.4 Permission Modes

Claude Code operates under user-controlled permission settings:

  • Auto-accept: Automatically allows pre-approved tool patterns
  • Ask: Prompts before each action (default for risky operations)
  • Deny: Blocks the action entirely

You can configure permissions in .claude/settings.json or via the /config command.

4 Configuration

4.1 CLAUDE.md Files

CLAUDE.md is a special markdown file that provides project-specific context and instructions to Claude Code. It acts as a persistent “system prompt” for your project.

4.1.1 Where to Place CLAUDE.md

Location Scope Purpose
./CLAUDE.md Current project Project-specific instructions
./src/CLAUDE.md Subdirectory Component-specific instructions
~/.claude/CLAUDE.md Global Personal preferences across all projects

4.1.2 Example CLAUDE.md

# Project: Volatility-Managed Portfolio Analysis

## Tech Stack
- R 4.x with tidyverse
- LaTeX for paper preparation

## Conventions
- Use snake_case for R variable names
- All figures should use the ggplot2 theme_minimal()
- Data files are in CSV format under the Data/ directory

## Testing
- Run scripts with `Rscript` before committing

4.2 Settings (settings.json)

Claude Code settings can be configured at multiple levels:

4.2.1 User-level Settings

File: ~/.claude/settings.json

{
  "env": {
    "ANTHROPIC_API_KEY": "sk-ant-xxxxx"
  },
  "permissions": {
    "allow": [
      "Bash(git log*)",
      "Bash(git diff*)",
      "Bash(git status*)",
      "Read",
      "Glob",
      "Grep"
    ],
    "deny": [
      "Bash(rm -rf*)",
      "Bash(git push --force*)"
    ]
  }
}

4.2.2 Project-level Settings

File: .claude/settings.json (in your project root)

{
  "permissions": {
    "allow": [
      "Bash(Rscript*)",
      "Bash(R CMD*)"
    ]
  }
}

4.3 Environment Variables

Key environment variables for Claude Code:

Variable Description Example
ANTHROPIC_API_KEY Anthropic API key sk-ant-xxxxx
ANTHROPIC_BASE_URL Override API endpoint https://api.anthropic.com
ANTHROPIC_MODEL Default model claude-sonnet-4-6
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC Disable telemetry 1

4.4 Hooks

Hooks allow you to run shell commands before or after Claude Code events:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "echo 'File modified at $(date)' >> ~/.claude/edit_log.txt"
      }
    ],
    "PreToolUse": [
      {
        "matcher": "Bash",
        "command": "echo 'About to run: $TOOL_INPUT'"
      }
    ]
  }
}

4.5 MCP Servers

Model Context Protocol (MCP) servers extend Claude Code with external tools and data sources. Configure in .claude/settings.json:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/data"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "ghp_xxxxx"
      }
    }
  }
}

5 Key Features in Depth

5.1 Plan Mode

Plan Mode allows Claude Code to explore the codebase and design an approach before making any changes. This is useful for:

  • Large refactoring tasks
  • Unfamiliar codebases
  • Architectural decisions
  • Multi-file changes

Activate with /plan or when Claude Code detects a complex task.

5.2 Agentic Workflow

Claude Code follows an agentic loop:

  1. Understand – Reads your request and relevant code
  2. Plan – Determines the steps needed (in plan mode, presents for approval)
  3. Act – Executes actions (file edits, shell commands, searches)
  4. Evaluate – Checks results and adapts if needed
  5. Iterate – Repeats until the task is complete

5.3 Git Integration

Claude Code can handle the full Git workflow:

# Ask Claude Code to:
# - Stage and commit changes with meaningful messages
# - Create branches and pull requests
# - Review PRs and provide feedback
# - Resolve merge conflicts
# - Interpret git log and git diff output

5.4 IDE Integrations

5.4.1 VS Code

Install the Claude Code extension from the VS Code marketplace. Features:

  • Inline chat within the editor
  • File-aware context
  • Integrated terminal access

5.4.2 JetBrains (PyCharm, IntelliJ, etc.)

Install the Claude Code plugin from the JetBrains marketplace for similar functionality.

6 Using GLM 5.1 in Claude Code

6.1 Background

GLM 5.1 is the latest large language model from Zhipu AI (智谱AI). It offers strong coding capabilities and is available through the Zhipu AI platform at https://open.bigmodel.cn.

Claude Code supports using GLM 5.1 through Zhipu AI’s Anthropic-compatible API endpoint, which allows Claude Code to communicate with GLM models using the same protocol it uses with Anthropic’s models.

6.2 Prerequisites

  1. Zhipu AI Account: Register at https://open.bigmodel.cn
  2. GLM Coding Plan: Subscribe to a GLM Coding Plan (Lite, Pro, or Max)
  3. API Key: Obtain your API key from the Zhipu AI console

6.3 Configuration Steps

6.3.1 Step 1: Obtain Your API Key

Log in to the Zhipu AI open platform and navigate to the API key management page. Create a new API key and copy it.

6.3.2 Step 2: Configure settings.json

Edit ~/.claude/settings.json (create it if it does not exist):

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_zhipu_api_key_here",
    "ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.1"
  }
}

The key configuration variables are:

Variable Value Purpose
ANTHROPIC_AUTH_TOKEN Your Zhipu API key Authentication
ANTHROPIC_BASE_URL https://open.bigmodel.cn/api/anthropic Redirect API calls to Zhipu
ANTHROPIC_DEFAULT_OPUS_MODEL glm-5.1 Specify the GLM model

6.3.3 Step 3: Restart Claude Code

After updating the configuration, restart Claude Code for the changes to take effect:

# Exit Claude Code if running, then relaunch
claude

6.3.4 Step 4: Verify the Configuration

Launch Claude Code and check that the model indicator shows GLM 5.1. You can verify by asking:

> What model are you?

The response should indicate that it is running on GLM 5.1.

6.4 How It Works

┌──────────────┐       Anthropic-compatible API       ┌──────────────────┐
│              │  ─────────────────────────────────>  │                  │
│  Claude Code │                                      │  Zhipu AI Cloud  │
│  (CLI Tool)  │  <─────────────────────────────────  │    (GLM 5.1)     │
│              │       Response with GLM output       │                  │
└──────────────┘                                      └──────────────────┘

Claude Code sends requests to the Anthropic-compatible endpoint at Zhipu AI, which processes them using GLM 5.1 and returns results in the same format that Claude Code expects.

6.5 Alternative GLM Models

You can also configure other GLM model variants by changing the model name:

Model Name Description
glm-5.1 Latest GLM model (recommended)
glm-5-turbo Faster, more cost-effective
glm-5 Base GLM 5 model
glm-4v Vision-capable model

6.6 Alternative Setup: Via Environment Variables

Instead of settings.json, you can set environment variables directly:

# Add to ~/.zshrc or ~/.bashrc
export ANTHROPIC_AUTH_TOKEN="your_zhipu_api_key_here"
export ANTHROPIC_BASE_URL="https://open.bigmodel.cn/api/anthropic"
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-5.1"

Then reload your shell:

source ~/.zshrc   # or source ~/.bashrc

7 Troubleshooting

7.1 Common Issues and Solutions

Issue Possible Cause Solution
“Model not recognized” Wrong model name Use exactly glm-5.1
Authentication error Invalid API key Verify key in Zhipu AI console
Connection timeout Network/firewall issue Check connectivity to open.bigmodel.cn
Slow responses Model load or plan tier Consider upgrading Coding Plan
“Permission denied” File access issue Check settings.json permissions
Commands not found Node.js not installed Install Node.js 18+ and reinstall

7.2 Useful Debug Commands

# Check Claude Code version
claude --version

# Check Node.js version
node --version

# Test API connectivity
curl -s https://open.bigmodel.cn/api/anthropic -o /dev/null -w "%{http_code}"

7.3 Getting Help

8 References

  1. Anthropic. “Claude Code Documentation.” https://docs.anthropic.com/en/docs/claude-code

  2. Anthropic. “Claude Code GitHub Repository.” https://github.com/anthropics/claude-code

  3. Zhipu AI. “GLM Open Platform Documentation.” https://docs.bigmodel.cn

  4. Zhipu AI. “GLM Coding Plan Guide.” https://docs.bigmodel.cn/cn/coding-plan/using5-1

  5. Anthropic. “Model Context Protocol.” https://modelcontextprotocol.io