Complete reference for the sd command-line interface.
# Using uv (recommended)
uv tool install git+https://github.com/benwhalley/struckdown/
# Or install in current environment
uv pip install git+https://github.com/benwhalley/struckdown/
Environment Setup:
export LLM_API_KEY="your-api-key" # e.g., from openai.com
export LLM_API_BASE="https://api.openai.com/v1"
export DEFAULT_LLM="litellm/gpt-4.1-mini"
sd chatRun a single prompt interactively. Best for testing prompts and quick experiments.
Syntax:
sd chat [OPTIONS] PROMPT...
Options:
--model-name TEXT - Override default LLM model--show-context - Print the resolved prompt context after execution--verbose - Enable debug loggingExamples:
# Simple completion
sd chat "Tell me a joke: [[joke]]"
# Multiple slots
sd chat "Name a color: [[pick:color|red,blue,green]] Describe it: [[description]]"
# With context display
sd chat "Pick a number: [[int:number]]" --show-context
sd batchProcess multiple inputs in batch mode. Supports files, globs, stdin, and chaining.
Syntax:
sd batch [OPTIONS] [INPUTS...] [PROMPT]
Arguments:
INPUTS - Input files or glob patterns (e.g., *.txt, data/*.json)PROMPT - Inline prompt with extraction slotsInput Sources:
sd batch file1.txt file2.txt "[[summary]]"sd batch inputs/*.txt "[[summary]]"cat data.txt | sd batch "[[summary]]"echo '{"name":"Alice"}' | sd batch "Hello [[greeting]]"Output Formats:
.json) - Default, structured data.csv) - Flattened tabular format.xlsx) - Spreadsheet format.md, .txt) - Markdown tables-o specified--helpShow help for any command.
sd --help
sd chat --help
sd batch --help
Output: stdout Exit code: 0
-o / --output PATHOutput file path. Format auto-detected from extension.
sd batch *.txt "[[name]]" -o results.json # JSON output
sd batch *.txt "[[name]]" -o results.csv # CSV output
sd batch *.txt "[[name]]" -o results.xlsx # Excel output
sd batch *.txt "[[name]]" -o results.md # Markdown table
Default: Outputs JSON to stdout if omitted.
-p / --prompt PATHLoad prompt from file instead of inline.
# prompt.sd contains: "Extract name: [[name]]"
sd batch *.txt -p prompt.sd -o results.json
Cannot be combined with inline prompt.
-k / --keep-inputsInclude input fields in output (filename, content, basename).
sd batch *.txt "[[summary]]" -k -o results.json
Output includes:
{
"filename": "input.txt",
"input": "original text...",
"content": "original text...",
"basename": "input",
"summary": "extracted summary"
}
Default: Only extracted fields + filename for traceability.
-q / --quietSuppress progress output to stderr.
sd batch *.txt "[[name]]" -o results.json --quiet
Behavior:
--verbose also specified)Use case: Scripting, cron jobs, CI/CD pipelines.
--verboseEnable debug logging to stderr.
sd batch *.txt "[[name]]" --verbose 2> debug.log
Output includes:
Destination: stderr
--model-name TEXTOverride default LLM model for this run.
sd batch *.txt "[[summary]]" --model-name "litellm/gpt-4"
Default: $DEFAULT_LLM environment variable.
sd batch shows a progress bar by default during processing:
Processing ⠋ ━━━━━━━━━━━━━━━━━━━━━━ 47/100 47% 0:00:23
Display includes:
Shown when:
--quiet modeHidden when:
sd batch ... 2> errors.logsd batch ... | jq .--quiet flag is used# Force show (default in terminal)
sd batch *.txt "[[name]]" -o out.json
# Force hide
sd batch *.txt "[[name]]" -o out.json --quiet
# Redirect to ignore progress
sd batch *.txt "[[name]]" -o out.json 2>/dev/null
Struckdown follows CLI best practices for output streams:
Primary output - machine-readable results, intended for piping/capture.
Contains:
--version output--help outputExample:
sd batch *.txt "[[name]]" > results.json # Only results captured
Diagnostics - human-readable status, errors, warnings.
Contains:
Example:
sd batch *.txt "[[name]]" 2> errors.log # Only diagnostics captured
| Code | Meaning | Examples |
|---|---|---|
| 0 | Success | Command completed without errors |
| 1 | Error | LLM failure, file not found, processing error |
| 2 | Usage error | Invalid arguments, missing required options |
Example:
sd batch --invalid-flag
# Exit code: 2 (usage error)
sd batch missing-file.txt "[[x]]"
# Exit code: 1 (file not found error)
sd batch *.txt "[[x]]" -o out.json
# Exit code: 0 (success)
Extract names from text files:
sd batch documents/*.txt "Extract person's name: [[name]]" -o names.json
Output:
[
{"filename": "doc1.txt", "name": "Alice"},
{"filename": "doc2.txt", "name": "Bob"}
]
Chain multiple extraction steps:
sd batch *.txt "Purpose: [[purpose]] Name: [[name]]" | \
sd batch ": . Amazon equivalent? [[product]]" -k
Process and filter with jq:
sd batch *.txt "Price: [[number:price]]" | jq '.[] | select(.price > 100)'
Silent execution, log errors:
#!/bin/bash
sd batch data/*.txt "[[summary]]" -o results.json --quiet 2> errors.log
if [ $? -eq 0 ]; then
echo "Processing complete: results.json"
else
echo "Errors occurred, check errors.log"
exit 1
fi
Capture full debug output:
sd batch *.txt "[[name]]" --verbose 2> debug.log
Debug log contains:
Plain text:
echo "Hello world" | sd batch "Translate to Spanish: [[translation]]"
JSON input:
echo '[{"name":"Alice"},{"name":"Bob"}]' | \
sd batch "Hello ! [[greeting]]"
From file:
cat data.txt | sd batch "Summarize: [[summary]]" -o summary.json
CSV for spreadsheet import:
sd batch *.txt "Name: [[name]] Age: [[int:age]]" -o people.csv
Excel for reports:
sd batch *.txt "Product: [[product]] Price: [[number:price]]" -o report.xlsx
Markdown for documentation:
sd batch *.txt "Feature: [[feature]] Status: [[pick:status|done,wip,todo]]" -o status.md
Separate successful results and errors:
sd batch *.txt "[[summary]]" -o results.json 2> errors.log
# Check exit code
if [ $? -ne 0 ]; then
echo "Some items failed, check errors.log"
fi
Verbose mode for debugging failures:
sd batch failing-input.txt "[[x]]" --verbose
$STRUCKDOWN_CACHE)sd batch ... | sd batch ... for multi-stage extractionjq for filtering/transformationsd chat before batch processing$? in scripts to detect failures$? after sd batchchatterThe legacy chatter CLI has been removed in v0.1.6.
Old command:
chatter run "Tell me a joke: [[joke]]"
New command:
sd chat "Tell me a joke: [[joke]]"
Functionality is identical. All flags and options work the same way.