SDKExamples

Examples

These patterns use flags the CLI accepts today. Every flag is listed in the CLI reference.

Run a task from a script

#!/bin/sh
set -e
syntic -p "run the test suite and list each failing test name" \
  --permission-mode acceptEdits \
  --max-turns 15 \
  --max-budget-usd 1

Pipe input in

git diff --staged | syntic -p "write a commit message for this diff"

Get machine-readable output

syntic -p "list the exported functions in src/index.ts" --output-format json > result.json

Stream the run as it happens

syntic -p "refactor the logger to use structured fields" \
  --output-format stream-json --verbose

Each line is one JSON message: the initial record, status records, assistant messages and a final result.

Ask for a fixed answer shape

--json-schema checks the final answer against a JSON Schema, given inline or as a file path. A mismatch gets one retry; a run that still does not match exits non-zero. With --output-format json, the checked answer is in structured_output:

syntic -p "extract the package name and version from package.json" \
  --json-schema '{"type":"object","properties":{"name":{"type":"string"},"version":{"type":"string"}},"required":["name","version"]}' \
  --output-format json > result.json

Resume the last session in a script

syntic -p "continue the migration" --continue

Limit tools for a run

Offer only the built-in tools a run needs with --tools, or remove single tools with --disallowed-tools:

syntic -p "explain the build pipeline" --tools "Read,Grep,Glob"
syntic -p "explain the build pipeline" --disallowed-tools "Write,Edit,Bash"

More patterns for CI are in Scripting and CI.