Claude Code CLI Skill
Matches Claude Code 2.1.296 (verified on 3410, 2026-11-16). If the installed version moves, update this line.
Delegate coding tasks to Claude Code by spawning it as a hidden background PowerShell process. Output tee'd to a temp file so you can poll for completion and read results. You can tail the file with Get-Content -Wait to watch live.
When to Use
- Complex multi-file refactoring
- Security or architecture review requiring deep reasoning
- Tasks where Claude Opus/Sonnet quality is needed
- User explicitly says "use claude", "delegate to claude", "ask claude"
- Tasks in a specific project directory (use
-Cflag)
Running a Task
1. Choose the model
| Model | Best for | Cost |
|---|---|---|
sonnet (default) |
Standard coding, reviews, refactors | Included in Max plan |
opus |
Hard reasoning, architecture, security | Higher usage |
haiku |
Trivial lookups, formatting, simple edits | Cheapest |
2. Choose the mode
| Mode | Flag | Use case |
|---|---|---|
| One-shot print | -p "prompt" |
Default. Non-interactive, captures output |
| Continue session | --continue -p "follow-up" |
Resume previous context |
| With tool restrictions | --allowedTools "Read,Grep,Glob" -p "prompt" |
Read-only analysis |
| Full auto (edits allowed) | --dangerously-skip-permissions -p "prompt" |
Autonomous edits (ask user first!) |
| Specific directory | -C /path/to/project -p "prompt" |
Work in another project |
| JSON output | -p "prompt" --output-format json |
Structured output for parsing |
3. Spawn as hidden background process
# Standard: sonnet, read + analyze
$out = "$env:TEMP\hermes-claude-out.txt"; Remove-Item $out -EA SilentlyContinue
$proc = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-Command',"claude -p --model sonnet 'YOUR_PROMPT_HERE' 2>&1 | Tee-Object -FilePath '$out'; Add-Content '$out' '=== CLAUDE COMPLETE ==='"
# Opus for hard tasks
$out = "$env:TEMP\hermes-claude-out.txt"; Remove-Item $out -EA SilentlyContinue
$proc = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-Command',"claude -p --model opus 'YOUR_PROMPT_HERE' 2>&1 | Tee-Object -FilePath '$out'; Add-Content '$out' '=== CLAUDE COMPLETE ==='"
# With edits allowed (ask user first!)
$out = "$env:TEMP\hermes-claude-out.txt"; Remove-Item $out -EA SilentlyContinue
$proc = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-Command',"claude --dangerously-skip-permissions -p --model sonnet 'YOUR_PROMPT_HERE' 2>&1 | Tee-Object -FilePath '$out'; Add-Content '$out' '=== CLAUDE COMPLETE ==='"
# In a specific project directory
$out = "$env:TEMP\hermes-claude-out.txt"; Remove-Item $out -EA SilentlyContinue
$proc = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-Command',"claude -C 'C:\path\to\project' -p --model sonnet 'YOUR_PROMPT_HERE' 2>&1 | Tee-Object -FilePath '$out'; Add-Content '$out' '=== CLAUDE COMPLETE ==='"
# Read-only analysis (no edit tools)
$out = "$env:TEMP\hermes-claude-out.txt"; Remove-Item $out -EA SilentlyContinue
$proc = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-Command',"claude --allowedTools 'Read,Grep,Glob,Bash(git *)' -p --model sonnet 'YOUR_PROMPT_HERE' 2>&1 | Tee-Object -FilePath '$out'; Add-Content '$out' '=== CLAUDE COMPLETE ==='"
4. For long prompts (use stdin pipe)
$out = "$env:TEMP\hermes-claude-out.txt"; Remove-Item $out -EA SilentlyContinue
$proc = Start-Process pwsh -WindowStyle Hidden -PassThru -ArgumentList '-NoProfile','-Command',"Get-Content 'C:\path\to\prompt.txt' | claude -p --model sonnet 2>&1 | Tee-Object -FilePath '$out'; Add-Content '$out' '=== CLAUDE COMPLETE ==='"
5. Poll for completion
$outFile = "$env:TEMP\hermes-claude-out.txt"
$timeout = 300; $start = Get-Date
while (((Get-Date) - $start).TotalSeconds -lt $timeout) {
if ((Test-Path $outFile) -and (Get-Content $outFile -Raw) -match "=== CLAUDE COMPLETE ===") { break }
Start-Sleep -Seconds 10
}
$result = Get-Content $outFile -Raw -ErrorAction SilentlyContinue
6. Report results
After reading the output file, summarize the key findings or changes to the user. Include:
- What Claude found or changed
- Any warnings or errors
- Whether follow-up is needed (
--continueflag)
Debian/Linux adaptation
Same flow, with bash instead of PowerShell. Temp file is
/tmp/hermes-claude-out.txt (or $TMPDIR when set); watch live with tail -f.
# Standard: sonnet, read + analyze — detached, output to temp file
out=/tmp/hermes-claude-out.txt; rm -f "$out"
( claude -p --model sonnet 'YOUR_PROMPT_HERE' > "$out" 2>&1; echo '=== CLAUDE COMPLETE ===' >> "$out" ) & disown
# In a specific project directory (POSIX path)
( claude -C /path/to/project -p --model sonnet 'YOUR_PROMPT_HERE' > "$out" 2>&1; echo '=== CLAUDE COMPLETE ===' >> "$out" ) & disown
# Poll for completion (300 s timeout)
out=/tmp/hermes-claude-out.txt; start=$(date +%s)
while [ $(( $(date +%s) - start )) -lt 300 ]; do
grep -q "=== CLAUDE COMPLETE ===" "$out" 2>/dev/null && break
sleep 10
done
result=$(cat "$out" 2>/dev/null)
Long prompts: claude -p --model sonnet < /path/to/prompt.txt (same temp-file
capture). Auth is the same plain command: claude auth login.
Max Turns Control
Limit how many tool-use loops Claude performs:
claude -p --model sonnet --max-turns 5 "YOUR_PROMPT"
Use --max-turns 1 for simple questions. Default is unlimited (will keep working until done).
Critical Rules
- ALWAYS use
--print/-p— bareclaudeopens interactive TUI which hangs in automated contexts - NEVER use
--dangerously-skip-permissionswithout asking the user — equivalent to Codex--full-auto - Default to
sonnet— it's fast, cheap, and included in Max plan. Only useopuswhen the task genuinely needs it - Set
--max-turnsfor tasks that shouldn't run long (prevents runaway tool loops) - Use
-Cflag to target a specific project directory rather than cwd
Authentication
Claude Code must be authenticated on each machine:
claude auth login
Opens browser for Anthropic account login.
Comparison with Other Agents
| Feature | Claude Code | Codex | Gemini |
|---|---|---|---|
| Best at | Multi-file reasoning, refactoring | OpenAI model access | Huge context (1M tokens) |
| Context window | 200K | 400K | 1M |
| Edit capability | Full (with permissions) | Sandbox-based | Approval-based |
| Cost | Max plan included | OpenAI credits | Free (Google account) |
| Speed | Fast (sonnet) / Slow (opus) | Fast | Fast (flash) / Slow (pro) |
Machine-specific values in this document use privacy placeholders.