Skill: dhruvarvindsingh/claude-dev-setup (version 1.1.0)

--- name: Claude Dev Setup slug: claude-dev-setup version: 1.1.0 homepage: https://clawhub.ai/DhruvArvindSingh/claude-dev-setup description: Complete Claude Code CLI integration with session management and APEX cognitive framework. One skill to set up coding agents with persistent task tracking. metadata: clawdbot: emoji: "🤖" requires: bins: ["claude"] os: ["linux", "darwin"] --- # 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 2. **AGENTS.md Section** — Workflow documentation for all coding agents 3. **APEX Stack Reference** — How to add cognitive framework to project CLAUDE.md files 4. **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: ``` ~/.claude/.credentials.json ``` ### Token Format ``` sk-ant-oat01-xxxxx... ``` ### How to Get the Token **Option 1: Extract from credentials file (RECOMMENDED)** ```bash # Extract the accessToken from credentials cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4 ``` **Option 2: Authenticate via browser (first-time setup)** ```bash claude setup-token # Opens browser for OAuth flow # Paste authorization code when prompted ``` ### ALWAYS Use the Token When Calling Claude Code Every Claude Code CLI call MUST include the token: ```bash # ✅ 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" ``` ### Automatic Token Extraction Add to your shell profile for automatic token loading: ```bash # Add to ~/.bashrc or ~/.zshrc export CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json 2>/dev/null | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4) ``` ### For Agent Executors When using the `exec` tool, always extract and set the token: ```json 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:** ```json // 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'" }) ``` ## Architecture ``` 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) ``` ## Session Management ### Registry Format Sessions are tracked in `memory/claude-code-sessions.md`: ```markdown | Session ID | Label | Task | Started | Status | |------------|-------|------|---------|--------| | tender-nexus | build-auth | Build auth module | 2026-03-24 08:50 UTC | running | ``` ### Starting a Background Task (CORRECT WAY) ```json // 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:** 1. Note `sessionId` from response 2. Append to `memory/claude-code-sessions.md` 3. Report to user: "Started X (session: label)" ### Checking Status When user asks "what's the status?": ```json process({ action: "log", sessionId: "session-id" }) ``` ### Label Naming Convention - `build-feature-X` — Building a new feature - `refactor-Y-module` — Refactoring code - `fix-bug-Z` — Bug fix - `test-coverage-A` — Adding tests - `cleanup-legacy-B` — Removing old code ### Quick Tasks (< 30 seconds) For simple tasks, use direct exec without tracking: ```json 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 }) ``` ## AGENTS.md Integration After installing this skill, your AGENTS.md gets a new section: ```markdown ## 🤖 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' ``` ### Session Tracking 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 ### When User Asks Status 1. Read sessions file 2. Find session by label 3. Poll for output 4. Summarize progress ``` ## 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 ``` ### 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 ```markdown # Project: [Name] ## Overview [1-2 sentences] ## Tech Stack - Language: ... - Framework: ... [APEX Stack content appended here] ``` ## Complete Workflow ``` 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 ``` ## Installation Checklist Run this after installing the skill: - [ ] Claude Code CLI installed: `which claude` - [ ] Authenticated: check `~/.claude/.credentials.json` exists - [ ] Token extractable: `cat ~/.claude/.credentials.json | grep accessToken` - [ ] Session file created: `memory/claude-code-sessions.md` - [ ] 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 `.gitignore` - Sessions are local to each agent workspace - MEMORIA explicitly forbids storing credentials ## Troubleshooting ### "Authentication failed" or "No token" ```bash # Check if credentials exist ls -la ~/.claude/.credentials.json # If missing, run setup claude setup-token ``` ### "command not found: claude" ```bash # Install Claude Code CLI npm install -g @anthropic-ai/claude-code # Verify installation which claude claude --version ``` ### Token works in terminal but not in exec The token must be exported in the same shell session: ```bash # ✅ 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 ``` ## 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 - `claude-code-cli-openclaw` — CLI integration details - `apex-stack-claude-code` — Cognitive framework ## Files in This Skill ``` claude-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 ``` ## Publishing To publish to ClawHub: ```bash 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" ``` ## Feedback - If useful: `clawhub star claude-dev-setup` - Issues: Open issue on ClawHub - Stay updated: `clawhub sync`

path: agents-section.md
content: ## 🤖 Claude Code CLI Sessions

You have access to Claude Code CLI for coding tasks. Use it for file operations, refactoring, debugging, and code generation.

### OAuth Token (REQUIRED)

**Token location:** `~/.claude/.credentials.json`

**ALWAYS extract and use the token when calling Claude Code:**

```bash
# Extract token and use in one command
CLAUDE_CODE_OAUTH_TOKEN=$(cat ~/.claude/.credentials.json | grep -o '"accessToken":"[^"]*"' | cut -d'"' -f4) claude --print --dangerously-skip-permissions 'task'
```

**For exec tool:**
```json
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
})
```

**If token not found**, user needs to run: `claude setup-token`

### Session Tracking

All background Claude Code sessions are tracked in `memory/claude-code-sessions.md`.

**Before starting a task:**
1. Read `memory/claude-code-sessions.md` to check for running sessions
2. If a similar task is running, report status instead of starting duplicate

**Starting a session:**
```json
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:**
1. Note the `sessionId` from the response
2. Append to `memory/claude-code-sessions.md`:
   ```
   | session-id | task-label | Description | 2026-03-24 08:50 UTC | running |
   ```

**Checking status:**
```json
process({ action: "log", sessionId: "session-id" })
```

**On completion:**
Update status column to `completed` or `failed`.

**Label naming:** Use descriptive labels like `build-feature-X`, `refactor-Y-module`, `fix-bug-Z`

### Quick Tasks (< 30 seconds)

For simple tasks, use non-background exec:
```json
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
})
```

No session tracking needed for quick tasks.

### When User Asks Status

1. Read `memory/claude-code-sessions.md`
2. Find the relevant session by label
3. Poll for output: `process({ action: "log", sessionId: "..." })`
4. Summarize progress for user

### APEX Stack for Projects

For enhanced cognition, add APEX Stack to your project's CLAUDE.md:
```bash
cd /path/to/project
cat ~/.openclaw/workspace-YOURS/skills/apex-stack-claude-code/SKILL.md >> CLAUDE.md
```

This enables:
- **APEX**: Cognitive modes (precision, execution, architecture, creative)
- **MEMORIA**: Persistent project memory
- **ARCHITECT**: Autonomous execution loop

path: sessions-template.md
content: # Claude Code CLI Sessions

## Purpose
Track background Claude Code CLI sessions for status queries.

## Session Registry

| Session ID | Label | Task | Started | Status |
|------------|-------|------|---------|--------|
| (populated at runtime) | (human-readable name) | (what it's doing) | (timestamp) | (running/completed/failed) |

## How It Works

### Starting a Session
```json
exec({
  command: "claude --print --dangerously-skip-permissions 'Task description'",
  background: true,
  yieldMs: 10000
})
// Returns: sessionId: "tender-nexus" or similar
```

**After starting:** Immediately log the session to this file:
```
| tender-nexus | refactor-auth | Refactor auth module | 2026-03-24 08:50 UTC | running |
```

### Checking Status
When user asks "what's the status?" or "is it done?":
```json
process({
  action: "log",
  sessionId: "tender-nexus"
})
```

### Completing a Session
When done, update the status column:
```
| tender-nexus | refactor-auth | Refactor auth module | 2026-03-24 08:50 UTC | completed |
```

### Cleanup
Remove completed sessions older than 24 hours during heartbeat cleanup.

## Session Label Naming Convention

Use descriptive labels that match the task:
- `build-feature-X` — Building a new feature
- `refactor-Y-module` — Refactoring code
- `fix-bug-Z` — Bug fix
- `test-coverage-A` — Adding tests
- `cleanup-legacy-B` — Removing old code

## Storage Location

This file: `~/memory/claude-code-sessions.md`

Before starting any Claude Code task, read this file to:
1. Check if a similar task is already running
2. Get the session ID for status queries
3. Clean up stale entries

## Example Flow

### User: "Build a login page"
1. Read this file (check for conflicts)
2. Start exec with background: true
3. Note sessionId from response
4. Append new row to registry
5. Report to user: "Started building login page (session: build-login-page)"

### User: "What's the status?"
1. Read this file to find session ID
2. Call process(action: "log", sessionId: "...")
3. Summarize output for user

### User: "Cancel it"
1. Call process(action: "kill", sessionId: "...")
2. Update status to "cancelled"
3. Confirm to user

## Rules

1. **Always log** — Every background session must be recorded here
2. **Use labels** — Never refer to sessions by ID alone, always use the human-readable label
3. **Update status** — Mark completed/failed/cancelled as soon as known
4. **Clean up** — Remove old entries during heartbeat (older than 24h)
5. **One task per session** — Don't queue multiple tasks in one session

path: setup.sh
content: #!/bin/bash
# Claude Dev Setup - Installation Script
# Run this after installing the skill via clawhub

set -e

echo "🤖 Claude Dev Setup"
echo "==================="
echo ""

# Check prerequisites
echo "Checking prerequisites..."

# Check if claude CLI is installed
if ! command -v claude &> /dev/null; then
    echo "⚠️  Claude Code CLI not found. Installing..."
    npm install -g @anthropic-ai/claude-code
else
    echo "✓ Claude Code CLI installed: $(claude --version)"
fi

# Check if authenticated
if [ ! -f "$HOME/.claude/.credentials.json" ]; then
    echo ""
    echo "⚠️  Not authenticated. Run: claude setup-token"
    echo "   You'll need a Claude Pro/Max subscription."
    echo ""
else
    echo "✓ Already authenticated with Claude"
fi

# Determine workspace
WORKSPACE="${WORKSPACE:-$HOME/.openclaw/workspace-gsoc}"
echo ""
echo "Workspace: $WORKSPACE"
echo ""

# Create memory directory if needed
mkdir -p "$WORKSPACE/memory"

# Create sessions file if it doesn't exist
SESSIONS_FILE="$WORKSPACE/memory/claude-code-sessions.md"
if [ ! -f "$SESSIONS_FILE" ]; then
    echo "Creating session tracking file..."
    cat > "$SESSIONS_FILE" << 'EOF'
# Claude Code CLI Sessions

## Purpose
Track background Claude Code CLI sessions for status queries.

## Session Registry

| Session ID | Label | Task | Started | Status |
|------------|-------|------|---------|--------|
| (populated at runtime) | (human-readable name) | (what it's doing) | (timestamp) | (running/completed/failed) |

EOF
    echo "✓ Created $SESSIONS_FILE"
else
    echo "✓ Session file already exists"
fi

# Check if AGENTS.md exists and needs updating
AGENTS_FILE="$WORKSPACE/AGENTS.md"
if [ -f "$AGENTS_FILE" ]; then
    if grep -q "Claude Code CLI Sessions" "$AGENTS_FILE"; then
        echo "✓ AGENTS.md already has session section"
    else
        echo ""
        echo "⚠️  AGENTS.md exists but missing session section."
        echo "   Add the following to AGENTS.md:"
        echo ""
        cat "$(dirname "$0")/agents-section.md"
        echo ""
    fi
else
    echo "⚠️  No AGENTS.md found at $AGENTS_FILE"
fi

# Check for dependent skills
echo ""
echo "Checking dependent skills..."
SKILLS_DIR="$WORKSPACE/skills"

for skill in claude-code-cli-openclaw apex-stack-claude-code; do
    if [ -d "$SKILLS_DIR/$skill" ]; then
        echo "✓ $skill installed"
    else
        echo "⚠️  $skill not found. Install with: clawhub install $skill"
    fi
done

echo ""
echo "=========================="
echo "Setup complete! ✅"
echo ""
echo "Next steps:"
echo "1. Authenticate if not done: claude setup-token"
echo "2. Add APEX Stack to project CLAUDE.md files"
echo "3. Start coding: claude --print 'your task'"
echo ""

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (CRITICAL)