這是本文件的舊版!
安裝 Claude Code (Ubuntu 24.04)
安裝程序
# Update package lists sudo apt update # Install Node.js 20 curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt-get install -y nodejs node --version sudo npm uninstall -g @anthropic-ai/claude-code sudo npm install -g @anthropic-ai/claude-code 看安裝過程的 log tail -f .npm/_logs/YYYY-MM-DDTHH_mm_ss_tssZ-debug-0.log
- 之後如果要更新
sudo npm update -g @anthropic-ai/claude-code
使用方式
claude
安裝與選用 MCP
- Context7 (動態文檔)
claude mcp add context7 -s user -- npx -y @upstash/context7-mcp - Fetch
claude mcp add fetch -s user -- npx -y @kazuph/mcp-fetch mkdir -p ~/Downloads/mcp-fetch
- Chrome DevTools
claude mcp add chrome-devtools -s user -- npx chrome-devtools-mcp@latest- 針對 WSL 環境的 Linux 沒有安裝 Chrome 的環境下, 可以透過啟用外部 chrome 服務方式來運作, 可參考 Chrome DevTools MCP (Linux/WSL) 使用方法
- ESLint 代碼檢查
claude mcp add eslint -s user -- npx -y @eslint/mcp - Serena Codebase 搜尋 Exp. repo 路徑 ~/ichiayi-238/wbs-tools/
# 安裝 uv/uvx curl -LsSf https://astral.sh/uv/install.sh | sh cat ~/.local/bin/env >> ~/.bashrc source ~/.bashrc # 安裝 Serena MCP cd ~/ichiayi-238/wbs-tools/ claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd)
- 安裝後的檢查
claude mcp list
自訂命令
- 建立命令目錄
mkdir -p ~/.claude/commands - Context Engineering 命令
cd ~/.claude/commands https://raw.githubusercontent.com/tryweb/context-engineering-intro/refs/heads/main/.claude/commands/execute-prp.md https://raw.githubusercontent.com/tryweb/context-engineering-intro/refs/heads/main/.claude/commands/generate-prp.md
- git commit & push 命令
vi ~/.claude/commands/gen-commit-msg.mdYour task is to help the user to generate a commit message and commit the changes using git. ## Guidelines - DO NOT add any ads such as "Generated with [Claude Code](https://claude.ai/code)" - Only generate the message for staged files/changes - Don't add any files using `git add`. The user will decide what to add. - Follow the rules below for the commit message. ## Format ``` <type>:<space><message title> <bullet points summarizing what was updated> ``` ## Example Titles ``` feat(auth): add JWT login flow fix(ui): handle null pointer in sidebar refactor(api): split user controller logic docs(readme): add usage section ``` ## Example with Title and Body ``` feat(auth): add JWT login flow - Implemented JWT token validation logic - Added documentation for the validation component ``` ## Rules * title is lowercase, no period at the end. * Title should be a clear summary, max 50 characters. * Use the body (optional) to explain *why*, not just *what*. * Bullet points should be concise and high-level. Avoid * Vague titles like: "update", "fix stuff" * Overly long or unfocused titles * Excessive detail in bullet points ## Allowed Types | Type | Description | | -------- | ------------------------------------- | | feat | New feature | | fix | Bug fix | | chore | Maintenance (e.g., tooling, deps) | | docs | Documentation changes | | refactor | Code restructure (no behavior change) | | test | Adding or refactoring tests | | style | Code formatting (no logic change) | | perf | Performance improvements |
安裝 BMad-Method 命令
- 安裝語法
git clone https://github.com/bmad-code-org/BMAD-METHOD.git temp-bmad cd temp-bmad npm install npm run install:bmad
- 安裝過程會詢問安裝目錄, 就指定專案 repo 目錄路徑 Exp. /home/jonathan/ichiayi-238/team-attendance
- 更版方式
cd temp-bmad git checkout HEAD -- package-lock.json git pull npm install npm run install:bmad
選擇之前指定的目錄 Exp. /home/jonathan/ichiayi-238/team-attendance 之後就會看到升級的訊息
使用其他模型方式
- 安裝 llmoxy
curl -sSL https://raw.githubusercontent.com/Firsh/llmoxy/main/install.sh | bash source ~/.bashrc
- 設定 API key
cd ~/llmoxy vi .env
Exp.
# OpenRouter and Moonshot API Keys for LiteLLM Proxy OPENROUTER_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxae0" MOONSHOT_API_KEY="sk-cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxBO"
- 檢視或修改 LLM 模型
vi config.yamlExp. 將 qwen3-coder 改成 qwen3-coder:free, 將 allow_fallbacks 改成 true
: # Qwen3 Coder - model_name: qwen litellm_params: model: openrouter/qwen/qwen3-coder:free api_key: os.environ/OPENROUTER_API_KEY : extra_body: provider: order: ["deepinfra", "gmicloud", "alibaba-opensource"] allow_fallbacks: true - 啟動與查看 llmoxy 運作狀態
llmoxy --start llmoxy --status llmoxy --logs llmoxy-stop llmoxy-restart
- 進入 claude code 的方式
$ llmoxy --status 🔍 Checking proxy status... ✅ LiteLLM proxy is running on localhost:4000 📋 Available models (from LiteLLM): - kimi-or (openrouter/moonshotai/kimi-k2) - dsr1 (openrouter/deepseek/deepseek-r1-0528) - qwen (openrouter/qwen/qwen3-coder:free)
表示
- kimi-or 使用 kimi-k2 模型
- dsr1 使用 deepseek-r1-0528 模型
- qwen 使用 qwen3-coder:free 模型