claude-code-invoke-once
/claude-code-invoke-once
Programmatically invoke Claude Code via the `claude` CLI (headless `-p`, `--output-format json|stream-json`, `--resume`/`--continue`) to automate tasks like producing code review reports for specific files/dirs, investigating an issue, or drafting an implementation plan. Use when you need scriptable, machine-readable output and/or session-persistent multi-turn workflows with Claude Code.
- Author
- igamenovoer ↗
- Repository
- magic-context ↗
- Licence
- MIT
- Last repository change
- 11.05.2026
Assessment and security
- Files in this package
- 3
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 11.05.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Programmatically invoke Claude Code via the `claude` CLI (headless `-p`, `--output-format json|stream-json`, `--resume`/`--continue`) to automate tasks like producing code review reports for specific files/dirs, investigating an issue, or drafting an implementation plan. Use when you need scriptable, machine-readable output and/or session-persistent multi-turn workflows with Claude Code.
Original author description
Programmatically invoke Claude Code via the `claude` CLI (headless `-p`, `--output-format json|stream-json`, `--resume`/`--continue`) to automate tasks like producing code review reports for specific files/dirs, investigating an issue, or drafting an implementation plan. Use when you need scriptable, machine-readable output and/or session-persistent multi-turn workflows with Claude Code.
How it works
- Quick start (shell)
- Heartbeats and deadlines
- Workflow decision
- Session handling (must follow)
- Example prompts (to trigger this skill)
- Integration rules (don’t skip)
- Credentials (optional)
- Resources
SKILL.md preview
--- name: claude-code-invoke-once description: Programmatically invoke Claude Code via the `claude` CLI (headless `-p`, `--output-format json|stream-json`, `--resume`/`--continue`) to automate tasks like producing code review reports for specific files/dirs, investigating an issue, or drafting an implementation plan. Use when you need scriptable, machine-readable output and/or session-persistent multi-turn workflows with Claude Code. --- # Claude Code Invoke Once ## Quick start (shell) One-shot (machine-readable JSON): ```bash claude -p "Summarize this repo" --output-format json ``` If you use a Claude wrapper (executable, `.sh`, or shell alias), substitute it for `claude` (example: `claude-wrapper -p ...`). Streaming progress/events (JSONL): ```bash claude -p "Explain recursion" --output-format stream-json --verbose --include-partial-messages ``` Persist multi-turn state and resume later (deterministic automation): ```bash session_id="$(claude -p "Start a review" --output-format json | jq -r '.session_id')" claude -p "Continue that review" --resume "$session_id" --output-format json ``` ## Heartbeats and deadlines - For long-running work, prefer streaming (`--output-format stream-json`, optionally with `--include-partial-messages`) so stdout emits a steady heartbeat (one JSON object per line). - Do not add timeouts or terminate the Claude process while it is still working unless one of these applies: (1) the user explicitly requested a deadline (for example: "up to 5 minutes"), (2) the process is clearly stalled, or (3) the process is in an error state (for example: lost connection, timeout, invalid API key, non-zero exit failure). - Do not interrupt simply because intermediate output appears to drift from the prompt; let Claude run to normal completion and evaluate the final result afterward. ## Workflow decision 1. Need a single final answer: use `--output-format json` and parse `.result`. 2. Need realtime progress: use `--output-format stream-json` and parse one JSON object per stdout line. 3. Need multi-turn state: persist `.session_id` and call `--resume <session_id>` for subsequent turns (prefer over `--continue` in automation). ## Session handling (must follow) - If the user provides a `session_id`, always use `--resume <session_id>` for the next Claude Code call. - If the user says “continue latest chat”, “continue last chat”, or similar, use the most recently captured `session_id` from this conversation. - If the user does not provide a `session_id` and does not explicitly request a continuation, determine from context whether they want to persist the previous Claude session. If unclear, start a new session. ## Example prompts (to trigger this skill) - “Use Claude Code to make a review report of `src/` and `tests/`.” - “Use Claude Code to look into the issue of: <paste error/log>.” - “Use Claude Code to make an implementation plan for: <feature/PRD>.” ## Integration rules (don’t skip) - Treat `stdout` as the machine channel; treat `stderr` as diagnostics. - Assume output schemas can evolve; parse defensively and avoid hard-coding event keys. - Store the returned `session_id` if you will send follow-up prompts in a later process/run. ## Credentials (optional) Ensure your chosen Claude command can authenticate in your environment (for example by exporting env vars or sourcing an env file before running the command). ## Resources - Full guide: `references/howto-control-claude-code-programmatically.md`
Files in this package (3)
- SKILL.md 3 KB
- agents/openai.yaml 1 KB
- references/howto-control-claude-code-programmatically.md 4 KB
Versions
The database has no other skills named claude-code-invoke-once.
Database snapshot: 13.11.2026 · package version 1bd02dd850c3 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100copilot-invoke-once
Programmatically invoke GitHub Copilot CLI via the `copilot` command (headless `-p`, `--silent`, `--stream on|off`, `--resume`/`--continue`) to automate tasks like producing code review notes for specific files/dirs, investigating an issue, or drafting an implementation plan.… - 100agent-builder
Build AI agents and automate Claude Code programmatically via the Claude Agent SDK and headless CLI mode. Covers Python SDK, claude -p, SDK MCP servers, hooks, sessions. Triggers on: "build an agent", "agent SDK", "headless mode", "automate Claude", "programmatic agent". - 100codex-cli-invoke-once
Programmatically invoke Codex via the `codex` CLI for headless, non-interactive runs using `codex exec`, machine-readable JSONL via `--json`, final-message capture via `-o/--output-last-message`, and multi-turn continuation via `codex exec resume`. Use when you need scriptable… - 100claude-code
Use when the user asks to run Claude Code CLI (`claude`, `claude resume`) for review, analysis, implementation, refactoring, debugging, or follow-up specifically through Claude Code. - 86resume-claude
Continue work from a local Claude Code session in Muse Code. Use when the user asks to resume, continue, or recover unfinished Claude Code work, with or without a session ID or log path; call read_skill for bundled:resume-claude before reading its transcript. Explicit /import requests use import. - 100headless-runner
Run Claude Code in headless/programmatic mode for automation, CI/CD, and agent workflows. Use when user asks about headless mode, programmatic execution, scripting Claude, or automating Claude workflows.