Run Claude Code CLI tasks from Clawdbot with safe defaults, PTY protection for non-interactive environments, and OpenSpec-oriented workflows. Use when the user asks to execute Claude Code (`claude -p`), run headless coding tasks, or call Claude specifically for planning/implementation.
Execute Claude Code via the local claude CLI with reliability and safety defaults.
command -v claudeclaude auth status --textIf claude is missing or unauthenticated, stop and report exactly what is missing.
claude -p.--permission-mode plan unless user explicitly requests execution rights.--dangerously-skip-permissions unless explicitly requested by user.--allowedTools for least privilege when execution is required.--output-format json when results need machine parsing.--max-turns <n>--max-budget-usd <amount>In headless/automation contexts, run through the bundled wrapper to allocate a PTY and avoid claude -p hangs.
Use:
./.agent/skills/claude-code-runner/scripts/claude_code_run.sh \
--prompt "<task>" \
--permission-mode plan
For spec-driven flows, keep prompts explicit and artifact-oriented.
Examples:
./.agent/skills/claude-code-runner/scripts/claude_code_run.sh \
--prompt "Create or refine OpenSpec proposal/specs/design/tasks for change <name>. Follow project rules in openspec/config.yaml." \
--permission-mode plan
./.agent/skills/claude-code-runner/scripts/claude_code_run.sh \
--prompt "Implement OpenSpec tasks for change <name>, then run tests and summarize results." \
--permission-mode acceptEdits \
--allowed-tools "Read,Edit,Write,Bash(npm run *),Bash(pnpm *),Bash(git status),Bash(git diff *)"
When returning results from Claude Code runs, always include:
scripts/claude_code_run.sh: PTY-safe wrapper for claude -p.references/claude-code-cheatsheet.md: concise command/flag patterns distilled from official docs.