Skip to main content
Use the headless agent workflow when an external process needs SimpleFunctions market intelligence without opening the interactive terminal UI. This is part of the primary CLI surface: prefer CLI automation first, HTTP/Data APIs for remote services second, and MCP only as a compatibility adapter. There are two modes: If someone says sf --plain, the copy-paste command you want is usually sf agent --plain. The --plain flag belongs to sf agent.

What it can do

The agent has the same market tools as the interactive sf agent session: Use direct --json commands for deterministic parsing. Use sf agent --plain --once when you want the SimpleFunctions agent to reason across those commands and return an analyst-style answer.

First run

Install and verify the local control plane:
For automation, start with read-only policy gates:
--once runs one turn and exits. --plain removes the TUI. --new avoids inheriting a stale local session. The --allow and --deny lists are enforced before tool execution.

Plain mode from cron

This pattern is useful for hourly thesis review or morning portfolio briefs:
Use --record-trace for audit and regression replay:

Headless NDJSON server

Use sf agent --headless when your own LLM loop should decide which SimpleFunctions tool to call while still staying on the CLI-first path. In this mode SimpleFunctions does not run its own LLM loop; it exposes tools over newline-delimited JSON. Start the server:
The first stdout line is a ready frame:
Send tool calls on stdin:
Read result frames from stdout:
Protocol frames:

Minimal Node harness

Keep stderr separate from stdout. Operational warnings and tool progress can appear on stderr; stdout is the protocol stream you parse.

Claude Code with sf agent --plain

Claude Code can run non-interactively with claude -p, the current programmatic CLI mode documented by Anthropic. That makes it a good host for SimpleFunctions CLI calls: Claude Code handles repository context and shell orchestration, while SimpleFunctions handles prediction-market tools and thesis state. Use a narrow Bash-only prompt:
This is the safest default because Claude Code is restricted to Bash, the prompt only allows read-oriented sf command families, and SimpleFunctions still enforces its own --allow / --deny policy before any tool execution.

Claude Code with the NDJSON server

For a tighter integration, have Claude Code write or run a small harness that starts sf agent --headless, reads the ready manifest, and sends only approved call frames. Example prompt:
Claude Code’s -p mode supports structured output with --output-format json and streaming with --output-format stream-json. Use that for the outer automation layer; use sf agent --headless NDJSON for the SimpleFunctions tool layer.

Safety model

Default automation policy:
Use that for research, monitoring, and reporting. Add write only when the automation is allowed to mutate SimpleFunctions state, such as injecting a thesis signal or creating a watchlist item. Do not add trade or runtime to unattended Claude Code, cron, or CI jobs. For execution workflows:
  1. Read first: sf me portfolio --json, sf intent list --json, sf runtime status --json.
  2. Propose the action in text.
  3. Ask a human to approve.
  4. Prefer sf intent buy / sf intent sell over direct sf buy / sf sell.
  5. Record the run with --record-trace.

Agentic CLI

Full CLI control plane, permission categories, trace and replay.

Thesis lifecycle

Create, signal, evaluate, augment, heartbeat, and publish a thesis.

Agent runtime

Long-running execution daemon, intents, and cloud runtime.

Claude Code programmatic mode

Anthropic reference for claude -p, JSON output, and scripted runs.