Claude Dev Setup
Complete package for coding agents: Claude Code CLI integration, session management, and APEX cognitive framework.
What This Skill Does
Installs and configures:
- 1. Session Tracking —
memory/claude-code-sessions.md for background task management - AGENTS.md Section — Workflow documentation for all coding agents
- APEX Stack Reference — How to add cognitive framework to project CLAUDE.md files
- OAuth Token Handling — Automatic token extraction and usage
Prerequisites
- - Node.js 18+
- Claude Pro/Max subscription (for OAuth token)
- OpenClaw agent workspace
OAuth Token (CRITICAL)
Where the Token Lives
Claude Code stores its OAuth token in:
CODEBLOCK0
Token Format
CODEBLOCK1
How to Get the Token
Option 1: Extract from credentials file (RECOMMENDED)
CODEBLOCK2
Option 2: Authenticate via browser (first-time setup)
CODEBLOCK3
ALWAYS Use the Token When Calling Claude Code
Every Claude Code CLI call MUST include the token:
CODEBLOCK4
Automatic Token Extraction
Add to your shell profile for automatic token loading:
CODEBLOCK5
For Agent Executors
When using the exec tool, always extract and set the token:
CODEBLOCK6
Or pre-extract and use:
CODEBLOCK7
Architecture
CODEBLOCK8
Session Management
Registry Format
Sessions are tracked in memory/claude-code-sessions.md:
CODEBLOCK9
Starting a Background Task (CORRECT WAY)
CODEBLOCK10
After starting, log the session:
- 1. Note
sessionId from response - Append to INLINECODE4
- Report to user: "Started X (session: label)"
Checking Status
When user asks "what's the status?":
CODEBLOCK11
Label Naming Convention
- -
build-feature-X — Building a new feature - INLINECODE6 — Refactoring code
- INLINECODE7 — Bug fix
- INLINECODE8 — Adding tests
- INLINECODE9 — Removing old code
Quick Tasks (< 30 seconds)
For simple tasks, use direct exec without tracking:
CODEBLOCK12
AGENTS.md Integration
After installing this skill, your AGENTS.md gets a new section:
CODEBLOCK13 bash
CLAUDECODEOAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4) claude --print --dangerously-skip-permissions 'task'
CODEBLOCK14
APEX Stack for Projects
The cognitive framework (apex-stack-claude-code) should be added to project CLAUDE.md files, not agent memory.
Adding to a Project
CODEBLOCK15
What APEX Stack Does
| Layer | Purpose |
|---|
| APEX | Cognitive modes (precision, execution, architecture, creative) |
| MEMORIA |
Persistent memory for project context |
| ARCHITECT | Autonomous execution loop |
Project CLAUDE.md Structure
CODEBLOCK16
Complete Workflow
CODEBLOCK17
Installation Checklist
Run this after installing the skill:
- - [ ] Claude Code CLI installed: INLINECODE11
- [ ] Authenticated: check
~/.claude/.credentials.json exists - [ ] Token extractable: INLINECODE13
- [ ] Session file created: INLINECODE14
- [ ] AGENTS.md updated with session section
- [ ] APEX Stack added to project CLAUDE.md (if applicable)
Security Notes
- - OAuth token stored in
~/.claude/.credentials.json (valid 1 year) - NEVER commit
CLAUDE_CODE_OAUTH_TOKEN to git - ALWAYS extract token from credentials file, never hardcode
- Add
.claude/ to INLINECODE18 - Sessions are local to each agent workspace
- MEMORIA explicitly forbids storing credentials
Troubleshooting
"Authentication failed" or "No token"
CODEBLOCK18
"command not found: claude"
CODEBLOCK19
Token works in terminal but not in exec
The token must be exported in the same shell session:
CODEBLOCK20
Token Efficiency
| Method | Tokens/Task | Cost |
|---|
| Raw API (full context) | 10,000-50,000 | Per-token |
| Claude Code (tool-based) |
~500 | Flat-rate (Max sub) |
Savings: 80-90% reduction in token usage.
Related Skills
Install these alongside for full capability:
- -
self-improving — Learn from corrections - INLINECODE20 — CLI integration details
- INLINECODE21 — Cognitive framework
Files in This Skill
CODEBLOCK21
Publishing
To publish to ClawHub:
CODEBLOCK22
Feedback
- - If useful: INLINECODE22
- Issues: Open issue on ClawHub
- Stay updated: INLINECODE23
Claude Dev 设置
面向编码代理的完整包:Claude Code CLI 集成、会话管理和 APEX 认知框架。
此技能的功能
安装并配置:
- 1. 会话追踪 — memory/claude-code-sessions.md 用于后台任务管理
- AGENTS.md 章节 — 所有编码代理的工作流文档
- APEX 栈参考 — 如何将认知框架添加到项目 CLAUDE.md 文件中
- OAuth 令牌处理 — 自动提取和使用令牌
前置条件
- - Node.js 18+
- Claude Pro/Max 订阅(用于 OAuth 令牌)
- OpenClaw 代理工作区
OAuth 令牌(关键)
令牌存放位置
Claude Code 将其 OAuth 令牌存储在:
~/.claude/.credentials.json
令牌格式
sk-ant-oat01-xxxxx...
如何获取令牌
选项 1:从凭据文件中提取(推荐)
bash
从凭据中提取 accessToken
cat ~/.claude/.credentials.json | grep -o accessToken:[^]* | cut -d -f4
选项 2:通过浏览器进行身份验证(首次设置)
bash
claude setup-token
打开浏览器进行 OAuth 流程
在提示时粘贴授权码
调用 Claude Code 时始终使用令牌
每次 Claude Code CLI 调用必须包含令牌:
bash
✅ 正确 - 明确设置令牌
export CLAUDE
CODEOAUTH_TOKEN=sk-ant-oat01-xxxxx...
claude --print --dangerously-skip-permissions 你的任务
❌ 错误 - 未设置令牌,在非交互模式下会失败
claude --print 你的任务
自动提取令牌
添加到你的 shell 配置文件以实现自动加载令牌:
bash
添加到 ~/.bashrc 或 ~/.zshrc
export CLAUDE
CODEOAUTH_TOKEN=$(cat ~/.claude/.credentials.json 2>/dev/null | grep -o accessToken:[^]* | cut -d -f4)
对于代理执行器
使用 exec 工具时,始终提取并设置令牌:
json
exec({
command: export CLAUDECODEOAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o \accessToken\:\[^\]*\ | cut -d\ -f4) && claude --print --dangerously-skip-permissions 任务描述,
background: true,
yieldMs: 10000
})
或预先提取并使用:
json
// 首先,提取令牌
exec({
command: cat ~/.claude/.credentials.json | grep -o \accessToken\:\[^\]*\ | cut -d\ -f4
})
// 然后在所有后续调用中使用
exec({
command: CLAUDECODEOAUTH_TOKEN=sk-ant-oat01-xxx claude --print --dangerously-skip-permissions 任务
})
架构
代理工作区
├── AGENTS.md # + 会话管理章节
├── memory/
│ └── claude-code-sessions.md # 新增:会话注册表
└── skills/
├── claude-code-cli-openclaw/ # CLI 集成
├── apex-stack-claude-code/ # 认知框架
└── claude-dev-setup/ # 本技能
系统级别
└── ~/.claude/.credentials.json # OAuth 令牌(请勿提交)
会话管理
注册表格式
会话在 memory/claude-code-sessions.md 中追踪:
markdown
| 会话 ID | 标签 | 任务 | 开始时间 | 状态 |
|---|
| tender-nexus | build-auth | 构建认证模块 | 2026-03-24 08:50 UTC | 运行中 |
启动后台任务(正确方式)
json
// 步骤 1:从凭据中提取令牌
// 步骤 2:在 Claude Code 调用中使用
exec({
command: CLAUDECODEOAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o \accessToken\:\[^\]*\ | cut -d\ -f4) claude --print --dangerously-skip-permissions 任务描述,
background: true,
yieldMs: 10000
})
启动后,记录会话:
- 1. 从响应中记录 sessionId
- 追加到 memory/claude-code-sessions.md
- 向用户报告:已启动 X(会话:标签)
检查状态
当用户询问状态如何?时:
json
process({ action: log, sessionId: session-id })
标签命名约定
- - build-feature-X — 构建新功能
- refactor-Y-module — 重构代码
- fix-bug-Z — 修复错误
- test-coverage-A — 添加测试
- cleanup-legacy-B — 移除旧代码
快速任务(< 30 秒)
对于简单任务,使用直接 exec 而不追踪:
json
exec({
command: CLAUDECODEOAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o \accessToken\:\[^\]*\ | cut -d\ -f4) claude --print --dangerously-skip-permissions 快速修复,
timeout: 60
})
AGENTS.md 集成
安装此技能后,你的 AGENTS.md 将获得一个新章节:
markdown
🤖 Claude Code CLI 会话
你可以使用 Claude Code CLI 执行编码任务。
OAuth 令牌(必需)
令牌位置: ~/.claude/.credentials.json
始终提取并使用令牌:
bash
CLAUDECODEOAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o accessToken:[^]* | cut -d -f4) claude --print --dangerously-skip-permissions 任务
会话追踪
所有后台会话在 memory/claude-code-sessions.md 中追踪。
开始前: 检查是否有正在运行的会话
开始后: 记录会话 ID + 标签
完成后: 更新状态列
当用户询问状态时
- 1. 读取会话文件
- 按标签查找会话
- 轮询输出
- 总结进度
项目的 APEX 栈
认知框架(apex-stack-claude-code)应添加到项目 CLAUDE.md 文件中,而不是代理内存中。
添加到项目
bash
cd /path/to/your/project
如果 CLAUDE.md 不存在:
cat ~/.openclaw/workspace-YOURS/skills/apex-stack-claude-code/SKILL.md > CLAUDE.md
如果 CLAUDE.md 存在,追加:
cat ~/.openclaw/workspace-YOURS/skills/apex-stack-claude-code/SKILL.md >> CLAUDE.md
APEX 栈的功能
| 层 | 用途 |
|---|
| APEX | 认知模式(精确、执行、架构、创意) |
| MEMORIA |
项目上下文的持久记忆 |
| ARCHITECT | 自主执行循环 |
项目 CLAUDE.md 结构
markdown
项目:[名称]
概述
[1-2 句话]
技术栈
[APEX 栈内容在此追加]
完整工作流
用户给出任务
↓
代理读取 memory/claude-code-sessions.md(检查冲突)
↓
代理提取令牌:cat ~/.claude/.credentials.json | grep accessToken
↓
代理启动:exec({ command: CLAUDECODEOAUTH_TOKEN=xxx claude ..., background: true })
↓
代理将会话记录到 claude-code-sessions.md
↓
代理报告:已启动 X(会话:build-feature-X)
↓
用户:状态如何?
↓
代理读取会话文件 → 轮询进程 → 总结
安装检查清单
安装此技能后运行:
- - [ ] Claude Code CLI 已安装:which claude
- [ ] 已验证身份:检查 ~/.claude/.credentials.json 是否存在
- [ ] 令牌可提取:cat ~/.claude/.credentials.json | grep accessToken
- [ ] 会话文件已创建:memory/claude-code-sessions.md
- [ ] AGENTS.md 已更新会话章节
- [ ] APEX