运行时依赖
版本
Project scaffolding
安装命令
点击复制技能文档
技能: Claude Code 命令行工具 for OpenClaw Description
This 技能 teaches OpenClaw 代理s how to 安装, 认证, 配置, and use Claude Code 命令行工具 as a coding 工具. Claude Code is an official Anthropic 命令行工具 that provides file-based 上下文 efficiency, reducing 令牌 usage by 80-90% compared to raw API calls for coding tasks.
Key Benefits:
令牌 Efficiency: ~500 令牌s per task vs 10k-50k with raw API (Claude Code reads files via 工具s instead of dumping full content into 上下文) Flat-Rate Billing: Uses Claude Max subscription (OAuth), not per-令牌 API billing Better 代码质量: Native file exploration, codebase understanding, and precise edits Project 上下文: CLAUDE.md file provides persistent project brAIn across 会话s
Use Cases:
Code implementation and refactoring Bug fixes with file exploration Multi-file code changes Project scaffolding Code reviews and analysis 🎯 设置up Modes Mode Description 🤖 OpenClaw Backend Use as claude-命令行工具 模型 in any 代理 (claude-命令行工具/sonnet-4.6, claude-命令行工具/opus-4.6) 🖥️ Direct 命令行工具 运行 claude --print from any project directory — no 代理 config needed ☁️ With MissionDeck 追踪 Claude Code 会话s live in your MissionDeck.AI 仪表盘 via JARVIS integration Prerequisites Claude Max Subscription: Required for OAuth authentication (cannot use raw API keys) Node.js/npm: For 安装ing the 命令行工具 globally TTY Terminal: Required for OAuth 设置up flow (use pty: true with exec 工具) Git: Recommended for managing code changes in branches OpenClaw Gateway: Must be 运行ning to 应用ly config 补丁es 安装ation Step 1: 安装 Claude Code 命令行工具 npm 安装 -g @anthropic-AI/claude-code
Step 2: 验证 安装ation which claude && claude --version
Expected 输出:
/usr/bin/claude 2.1.75
Quick 安装
Use the provided 安装ation script:
cd /root/.OpenClaw/workspace/技能s/claude-code bash scripts/安装.sh
The script handles:
NPM package 安装ation Version verification 环境 设置up preparation Authentication
Claude Code requires browser-based OAuth authentication using a Claude Max subscription. Raw API keys (sk-ant-API03-) will NOT work.
Interactive 设置up (One-Time)
运行 this in a PTY terminal (requires TTY):
claude 设置up-令牌
Flow:
命令行工具 shows spinner + authorization URL: https://claude.AI/oauth/授权?code=true&命令行工具ent_id=...&code_challenge=...
Copy URL and open in browser 授权 the 应用 with your Claude Max account Browser shows authorization code Paste code back into terminal at prompt: Paste code here if prompted > 成功: ✓ Long-lived authentication 令牌 创建d 成功fully! 令牌 格式化: sk-ant-oat01-xxxxx (valid for 1 year) Storing the 令牌
The 令牌 must be avAIlable as the CLAUDE_CODE_OAUTH_令牌 环境 variable.
Option 1: Shell RC Files (Recommended)
echo "导出 CLAUDE_CODE_OAUTH_令牌=YOUR_OAUTH_令牌_HERE" >> /root/.bashrc echo "导出 CLAUDE_CODE_OAUTH_令牌=YOUR_OAUTH_令牌_HERE" >> /root/.性能分析 source /root/.bashrc
Option 2: 系统-Wide
echo "CLAUDE_CODE_OAUTH_令牌=YOUR_OAUTH_令牌_HERE" >> /etc/环境
Option 3: OpenClaw Config Only
添加 to your OpenClaw.json config 补丁 (see next section) — the 令牌 will be avAIlable during OpenClaw backend calls but not direct 命令行工具 usage.
🔒 Security 警告
CRITICAL: Never commit your CLAUDE_CODE_OAUTH_令牌 to version control.
✅ Store in 环境 variables or secrets 管理器 ✅ 添加 .env files to .gitignore ✅ Use OpenClaw config.补丁 (not committed to git) ❌ Never hardcode 令牌s in scripts ❌ Never 分享 令牌s publicly or in screenshots ❌ Never commit 令牌s to GitHub/GitLab
添加 to your .gitignore:
.env .env.local .env.*.local OpenClaw.json config.补丁
Verification echo $CLAUDE_CODE_OAUTH_令牌 # Should 输出: sk-ant-oat01-xxxxx
OpenClaw Configuration
Integrate Claude Code as a 命令行工具 backend in OpenClaw, enabling it as a 模型 option and fallback.
Config 补丁
创建 or 应用end to ~/.OpenClaw/config.补丁:
{ "代理s": { "defaults": { "命令行工具Backends": { "claude-命令行工具": { "command": "/usr/bin/claude", "env": { "CLAUDE_CODE_OAUTH_令牌": "YOUR_OAUTH_令牌_HERE" } } }, "模型s": { "claude-命令行工具/opus-4.6": { "alias": "claude-命令行工具-opus" }, "claude-命令行工具/sonnet-4.6": { "alias": "claude-命令行工具-sonnet" } } }, "列出": [ { "id": "tank", "模型": { "primary": "anthropic/claude-opus-4-5", "fallbacks": [ "google/gemini-3-flash-preview", "claude-命令行工具/opus-4.6" ] } } ] } }
应用ly Configuration gateway config.补丁
验证 in gateway 记录s or test by spawning a coding 会话.
AvAIlable 模型s claude-命令行工具/sonnet-4.6 → Claude Sonnet 4.6 (fast, general coding) claude-命令行工具/opus-4.6 → Claude Opus 4.6 (complex reasoning, architecture)
Use as primary 模型, fallback, or invoke directly via exec.
Project 设置up (CLAUDE.md)
Critical: Every project u