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.
Best use case
claude-code-invoke-once is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using claude-code-invoke-once should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/claude-code-invoke-once/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How claude-code-invoke-once Compares
| Feature / Agent | claude-code-invoke-once | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
SKILL.md Source
# 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`
Related Skills
copilot-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. Use when you need scriptable, non-interactive Copilot runs with optional streaming progress and session continuation.
codex-cli-invoke-persist
Create and resume Codex CLI sessions with a persistent session-name-to-thread_id mapping plus last-used model stored in a workspace-scoped JSON file under system temp. Invoke only when the user explicitly names `$codex-cli-invoke-persist` or otherwise clearly requests this exact skill. Use it for deterministic, session-persistent Codex automation across turns and processes.
codex-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 Codex automation for repo reviews, issue investigation, implementation planning, or structured one-shot outputs.
claude-code-invoke-persist
Create and resume Claude Code CLI sessions with a persistent session-name-to-session_id mapping (plus last-used model and reasoning effort) stored in a workspace-scoped JSON file under system temp. Use when the user wants deterministic, session-persistent Claude Code automation across turns and processes.
claude-code-install
A three-part Claude Code setup skill with subskills for installation, skip-login configuration, and custom API-key launcher setup. Use when the user wants Claude Code installed or configured on the current host, with instructions adapted to the actual operating system and runtime environment.
pixi-make-offline-channel
Use when the user wants to create a self-hosted, offline-installable Conda channel (mirror) containing a specific subset of packages using Pixi.
pixi-make-cu-build-env
Guides the agent to setup a new or existing Pixi environment for compiling C++ and CUDA code. It ensures the correct compilers, toolkits, and CMake configurations are in place for a robust user-space build.
pixi-install-nvidia
Use when the user says "use pixi to install <some nvidia tool>" (or similar) and wants NVIDIA/CUDA/GPU packages installed via Pixi (no sudo/apt), e.g., CUDA toolkit pieces, cuDNN/NCCL, PyTorch CUDA builds, RAPIDS.
pei-docker-usage
Helper for PeiDocker (`pei-docker-cli`). Trigger ONLY when the user explicitly requests PeiDocker usage OR when working within a PeiDocker-generated project (indicated by `user_config.yml`).
conan-basic-usage
Basic operations for the Conan C++ package manager. Use when the user explicitly asks to 'use conan' for tasks like creating projects, installing dependencies, or building packages, or asks for 'how to' guidance on Conan setup.
explore-dnn-model
Manual invocation only; use only when the user explicitly requests `explore-dnn-model` by name. Explore how to run a given DNN model checkpoint in the current Python environment by locating weights + upstream source code, resolving dependencies with user confirmation, running reproducible experiments under `tmp/`, and producing reports about I/O contracts, timing, and profiling.
openspec-ext-revise-by-decision
Manual invocation only; use only when the user explicitly requests `openspec-ext-revise-by-decision` by exact name. Revise OpenSpec change artifacts from a review or decision document that contains questions plus `DECISION` blocks, applying chosen decisions from a review file such as `openspec/changes/<change>/review/review-*.md` back into proposal, design, specs, and tasks.