--- name: claude-cli description: Run Anthropic's Claude Code CLI headlessly (claude -p) as a second opinion, reviewer, or delegated agent. Use when the user says "use claude", "ask claude", "second opinion", "let claude review this", or wants Claude Code invoked from this session. --- # Claude Code CLI (headless) One-shot subprocess: prints the response and exits. No interactive session. ## The command ```bash claude -p "" --dangerously-skip-permissions ``` - `-p` (`--print`) — non-interactive mode: print response, exit. - `--dangerously-skip-permissions` — bypass ALL permission checks. Without it, headless Claude silently stalls on permission prompts. (Equivalent: `--permission-mode bypassPermissions`.) ## Useful variants ```bash claude -p "..." --dangerously-skip-permissions --model sonnet # pick model alias claude -p "..." --dangerously-skip-permissions --max-turns 10 # bound agentic loops cat file.ts | claude -p "review this" --dangerously-skip-permissions # stdin = context claude -p "..." --dangerously-skip-permissions --output-format json # machine-readable ``` ## Rules - **Run it inside the repo directory** the task concerns — that's the context it sees. - **It cannot see this conversation.** Write a self-contained prompt: goal, relevant paths, constraints, what output you expect back. - **Quote safely**: use a single-quoted string or a heredoc; prompts with quotes/backticks/`$` break naive double-quoting. - **Timeout it** (e.g. `timeout 600 ...`) — it's a full agentic session, can run long and costs tokens. - No secrets in the prompt; the bypass flag means it executes without asking. - If run from *inside* Claude Code itself, unset `CLAUDECODE` first or the call is refused as nested.