claude-code-wrapper
Claude Code Wrapper
A convenience wrapper that eliminates the friction of calling Claude Code from OpenClaw sessions.
Problem It Solves
When calling Claude Code through exec tools, environment variables from ~/.claude/config.json are not automatically loaded, resulting in "Not logged in" errors. This wrapper:
- Auto-loads credentials from
~/.claude/config.json - Exports required env vars automatically
- Provides seamless execution without manual setup
Usage
Basic Usage
Use the wrapper script directly:
bash pty:true command:"~/.openclaw/skills/claude-code-wrapper/scripts/claude_code.sh 'Your prompt here'"
With Working Directory
bash pty:true workdir:~/myproject command:"~/.openclaw/skills/claude-code-wrapper/scripts/claude_code.sh 'Analyze this codebase'"
Background Mode
bash pty:true workdir:~/myproject background:true command:"~/.openclaw/skills/claude-code-wrapper/scripts/claude_code.sh 'Run tests'"
Required Parameters
pty:true— Claude Code is an interactive TUI application and requires pseudo-terminal mode- Timeout — Recommend
timeout:120or longer for complex tasks
Environment Variables Auto-Loaded
The wrapper reads and exports these from ~/.claude/config.json:
ANTHROPIC_AUTH_TOKENANTHROPIC_BASE_URLAPI_TIMEOUT_MS
Example Workflows
One-shot Code Generation
bash pty:true command:"~/.openclaw/skills/claude-code-wrapper/scripts/claude_code.sh 'Write a Python function to calculate Fibonacci numbers'"
Project Analysis
bash pty:true workdir:~/myproject timeout:180 command:"~/.openclaw/skills/claude-code-wrapper/scripts/claude_code.sh 'Review the architecture of this project and suggest improvements'"
Background Task with Monitoring
# Start background session
bash pty:true workdir:~/myproject background:true command:"~/.openclaw/skills/claude-code-wrapper/scripts/claude_code.sh 'Refactor the auth module'"
# Monitor progress
process action:log sessionId:XXX
# Kill when done
process action:kill sessionId:XXX
Prerequisites
- Claude Code installed (
claudecommand available) - Claude Code configured (
~/.claude/config.jsonexists with valid credentials) - User has previously logged in to Claude Code manually
Error Handling
- Config not found: Script exits with error message if
~/.claude/config.jsonis missing - Claude not installed: Script exits with error message if
claudecommand not found - Invalid token: Claude Code itself will report authentication errors
Notes
- This wrapper does NOT handle the "trust this directory" interactive prompt. For new directories, Claude Code may still ask for confirmation.
- For fully automated workflows, consider running Claude Code once manually in target directories to establish trust.
More from xdrshjr/jr-openclaw-skills
doubao-open-tts
Text-to-Speech using Doubao (Volcano Engine) API. Use when converting text to natural-sounding speech, generating audio files from text, listing available TTS voices, or synthesizing speech with customizable speed/volume parameters.
90volcengine-image-gen
使用火山引擎(豆包)Seedream 系列模型生成高质量图片。支持文生图、多种分辨率、多种比例。
41paper-review
Comprehensive peer review of academic papers for top-tier computer science conferences and journals. Supports PDF and LaTeX inputs, provides detailed reviews with scores, and generates improvement plans. Use when the user asks to review, evaluate, or provide feedback on academic papers.
27session-cleaner
Clean up and manage OpenClaw sessions - kill all sub-agents, clear context, and reset the system to a clean state. Use when user says "close all sessions", "clear context", "kill all agents", "clean up sessions", "reset everything", "关掉所有子agent", "清空上下文", "关闭所有session", or similar cleanup requests.
6project-indexer
Generate and use project index for quick codebase understanding in new Claude Code sessions. Scans project structure, extracts code symbols, and creates a navigable feature map.
2reference-finder
Automatically analyze research text, extract domains and key concepts, then generate comprehensive reference lists with summaries using Gemini AI. Use when users need to (1) Generate literature references from research descriptions, (2) Find relevant academic papers for a research topic, (3) Build bibliography for research proposals, (4) Discover key papers in specific research domains, or (5) Create structured reference documentation from free-form research text.
2