Skip to content

claude

claude - execute non-interactive Claude prompts via the Claude CLI

state-name:
tool: claude
arguments:
prompt: <prompt-text>
model: <model-name> # optional
timeout: <duration> # optional
resume: <session-id> # optional
append-system-prompt: <text> # optional
allowed-tools: <tools> # optional
output-format: <format> # optional
json-output-schema: <schema> # optional

The claude tool invokes Claude via the CLI’s non-interactive mode (-p flag). It sends a prompt, waits for the response, and returns the output. Unlike claude-code, this tool does not provide an interactive terminal session.

The tool runs in the project root directory, giving Claude access to the full project context for code-aware responses.

ArgumentRequiredDefaultDescription
promptYes-The prompt to send to Claude
modelNoDefault modelModel to use (e.g., sonnet, opus)
timeoutNo5mMaximum execution time
resumeNo-Session ID to resume
append-system-promptNo-Additional system prompt text
allowed-toolsNo-Comma-separated list of allowed tools
output-formatNo-Output format (e.g., json, stream-json)
json-output-schemaNo-JSON Schema for structured output validation
  • 30s - 30 seconds
  • 5m - 5 minutes
  • 1h - 1 hour
CodeMeaning
0Success
1Claude CLI error or invalid arguments
124Timeout exceeded

Both stdout and stderr from Claude are merged and available for capture:

get-analysis:
tool: claude
arguments:
prompt: "Analyze this code for bugs"
output: var(analysis)
summarize:
tool: claude
arguments:
prompt: "Summarize the README.md in this project"
complex-analysis:
tool: claude
arguments:
prompt: "{{ file(./prompts/analysis.md) }}"
model: opus
long-task:
tool: claude
arguments:
prompt: "Review all TypeScript files in src/"
timeout: 10m
on-error:
124: handle-timeout
review-code:
tool: claude
arguments:
prompt: |
Review this code:
{{ file(./src/main.ts) }}
get-suggestion:
tool: claude
arguments:
prompt: "Suggest a commit message for the staged changes"
output: var(commit_message)
next: show-message
show-message:
tool: bash
arguments:
command: 'echo "Suggested: {{ commit_message }}"'
code-task:
tool: claude
arguments:
prompt: "Fix the failing tests in this project"
allowed-tools: Read,Glob,Grep,Edit
structured-response:
tool: claude
arguments:
prompt: "List all TODOs in the codebase as JSON"
output-format: json
output: var(todos_json)

Use json-output-schema to enforce a specific JSON structure. The schema ensures Claude’s response matches your expected format. When used, output-format is automatically set to json.

get-analysis:
tool: claude
arguments:
prompt: "Analyze this codebase and provide a summary"
json-output-schema: |
{
"type": "object",
"properties": {
"summary": { "type": "string" },
"file_count": { "type": "integer" },
"languages": {
"type": "array",
"items": { "type": "string" }
},
"recommendations": {
"type": "array",
"items": { "type": "string" }
}
},
"required": ["summary", "file_count", "languages"]
}
output: var(analysis)

The captured output contains only the validated JSON object (extracted from Claude’s structured_output response field), making it easy to use in subsequent states.

extract-data:
tool: claude
arguments:
prompt: "Extract contact information from: {{ file(./input.txt) }}"
json-output-schema: "{{ file(./schemas/contact.json) }}"
output: var(contact_data)
continue-conversation:
tool: claude
arguments:
prompt: "Now implement the changes we discussed"
resume: "{{ session_id }}"

The tool runs in the project root (directory containing .flowstate/), not the instance directory. This gives Claude access to the full project context.