Install
openclaw skills install claude-dev-setupComplete Claude Code CLI integration with session management and APEX cognitive framework. One skill to set up coding agents with persistent task tracking.
openclaw skills install claude-dev-setupComplete package for coding agents: Claude Code CLI integration, session management, and APEX cognitive framework.
Installs and configures:
memory/claude-code-sessions.md for background task managementClaude Code stores its OAuth token in:
~/.claude/.credentials.json
sk-ant-oat01-xxxxx...
Option 1: Extract from credentials file (RECOMMENDED)
# Extract the accessToken from credentials
cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4
Option 2: Authenticate via browser (first-time setup)
claude setup-token
# Opens browser for OAuth flow
# Paste authorization code when prompted
Every Claude Code CLI call MUST include the token:
# ✅ CORRECT - Token set explicitly
export CLAUDE_CODE_OAUTH_TOKEN="sk-ant-oat01-xxxxx..."
claude --print --dangerously-skip-permissions "your task"
# ❌ WRONG - Token not set, will fail in non-interactive mode
claude --print "your task"
Add to your shell profile for automatic token loading:
# Add to ~/.bashrc or ~/.zshrc
export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json 2>/dev/null | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4)
When using the exec tool, always extract and set the token:
exec({
command: "export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) && claude --print --dangerously-skip-permissions 'Task description'",
background: true,
yieldMs: 10000
})
Or pre-extract and use:
// First, extract token
exec({
command: "cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4"
})
// Then use in all subsequent calls
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=sk-ant-oat01-xxx claude --print --dangerously-skip-permissions 'Task'"
})
Agent Workspace
├── AGENTS.md # + Session management section
├── memory/
│ └── claude-code-sessions.md # NEW: Session registry
└── skills/
├── claude-code-cli-openclaw/ # CLI integration
├── apex-stack-claude-code/ # Cognitive framework
└── claude-dev-setup/ # THIS SKILL
System Level
└── ~/.claude/.credentials.json # OAuth token (DO NOT COMMIT)
Sessions are tracked in memory/claude-code-sessions.md:
| Session ID | Label | Task | Started | Status |
|------------|-------|------|---------|--------|
| tender-nexus | build-auth | Build auth module | 2026-03-24 08:50 UTC | running |
// Step 1: Extract token from credentials
// Step 2: Use in Claude Code call
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) claude --print --dangerously-skip-permissions 'Task description'",
background: true,
yieldMs: 10000
})
After starting, log the session:
sessionId from responsememory/claude-code-sessions.mdWhen user asks "what's the status?":
process({ action: "log", sessionId: "session-id" })
build-feature-X — Building a new featurerefactor-Y-module — Refactoring codefix-bug-Z — Bug fixtest-coverage-A — Adding testscleanup-legacy-B — Removing old codeFor simple tasks, use direct exec without tracking:
exec({
command: "CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '\"accessToken\":\"[^\"]*\"' | cut -d'\"' -f4) claude --print --dangerously-skip-permissions 'Quick fix'",
timeout: 60
})
After installing this skill, your AGENTS.md gets a new section:
## 🤖 Claude Code CLI Sessions
You have access to Claude Code CLI for coding tasks.
### OAuth Token (Required)
**Token location:** `~/.claude/.credentials.json`
**ALWAYS extract and use the token:**
```bash
CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4) claude --print --dangerously-skip-permissions 'task'
All background sessions tracked in memory/claude-code-sessions.md.
Before starting: Check for running sessions After starting: Log session ID + label On completion: Update status column
## 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
```bash
cd /path/to/your/project
# If CLAUDE.md doesn't exist:
cat ~/.openclaw/workspace-YOURS/skills/apex-stack-claude-code/SKILL.md > CLAUDE.md
# If CLAUDE.md exists, append:
cat ~/.openclaw/workspace-YOURS/skills/apex-stack-claude-code/SKILL.md >> CLAUDE.md
| Layer | Purpose |
|---|---|
| APEX | Cognitive modes (precision, execution, architecture, creative) |
| MEMORIA | Persistent memory for project context |
| ARCHITECT | Autonomous execution loop |
# Project: [Name]
## Overview
[1-2 sentences]
## Tech Stack
- Language: ...
- Framework: ...
[APEX Stack content appended here]
User gives task
↓
Agent reads memory/claude-code-sessions.md (check for conflicts)
↓
Agent extracts token: cat ~/.claude/.credentials.json | grep accessToken
↓
Agent starts: exec({ command: "CLAUDE_CODE_OAUTH_TOKEN=xxx claude ...", background: true })
↓
Agent logs session to claude-code-sessions.md
↓
Agent reports: "Started X (session: build-feature-X)"
↓
User: "What's the status?"
↓
Agent reads sessions file → polls process → summarizes
Run this after installing the skill:
which claude~/.claude/.credentials.json existscat ~/.claude/.credentials.json | grep accessTokenmemory/claude-code-sessions.md~/.claude/.credentials.json (valid 1 year)CLAUDE_CODE_OAUTH_TOKEN to git.claude/ to .gitignore# Check if credentials exist
ls -la ~/.claude/.credentials.json
# If missing, run setup
claude setup-token
# Install Claude Code CLI
npm install -g @anthropic-ai/claude-code
# Verify installation
which claude
claude --version
The token must be exported in the same shell session:
# ✅ CORRECT - Same session
CLAUDE_CODE_OAUTH_TOKEN=xxx claude --print "task"
# ❌ WRONG - Separate commands
export CLAUDE_CODE_OAUTH_TOKEN=xxx
claude --print "task" # Token not available
| 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.
Install these alongside for full capability:
self-improving — Learn from correctionsclaude-code-cli-openclaw — CLI integration detailsapex-stack-claude-code — Cognitive frameworkclaude-dev-setup/
├── SKILL.md # This file
├── sessions-template.md # Template for claude-code-sessions.md
├── agents-section.md # AGENTS.md section template
└── setup.sh # Installation script
To publish to ClawHub:
clawhub publish ./skills/claude-dev-setup \
--slug claude-dev-setup \
--name "Claude Dev Setup" \
--version 1.1.0 \
--changelog "Added explicit OAuth token extraction guide"
clawhub star claude-dev-setupclawhub sync