> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simplefunctions.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Common workflows

> Five end-to-end recipes — research a thesis, watch + webhook, autopilot, headless agent, and embed live odds.

These five recipes cover what most users actually do.

## 1. Research a market and build a thesis

```bash theme={null}
# 1. Find candidate markets
sf query "Will the Fed cut rates by July?" --json --limit 5

# 2. Inspect the most interesting one
sf inspect KXFEDRATE-26JUL --json

# 3. Build a thesis
sf create "Fed cuts rates by July driven by jobs softening + CPI ≤ 2.5%"

# 4. Pull thesis context
sf context <thesis-id> --json

# 5. Inject a signal
sf signal <thesis-id> "NFP came in 50K below consensus"

# 6. Trigger evaluation
sf evaluate <thesis-id>
```

See [Thesis lifecycle](/build/thesis-lifecycle) for the full conceptual model.

## 2. Set up watch + webhook delivery

```bash theme={null}
# 1. Add to watchlist
sf watchlist add KXRATECUT-26DEC31

# 2. Register webhook receiver
sf webhooks create --url https://your.app/sf-hook --label ops
# → returns webhook id we_... and secret

# 3. Create alert
sf alerts create \
  --object <watched-object-id> \
  --condition price_above \
  --threshold 65 \
  --channel webhook \
  --endpoint <webhook-endpoint-id>

# 4. Test fire
sf alerts test <alert-id>
```

See [Watchlist + alerts](/build/watchlist-alerts) and [Webhook receiver](/integrations/webhook-receiver).

## 3. Run portfolio autopilot in the cloud (BYOK)

```bash theme={null}
# 1. Configure local Kalshi keys
sf setup    # walks through Kalshi key + Polymarket wallet

# 2. Enable cloud manager
sf portfolio enable
# → walks through encryption + upload + cron + execution mode + strategies

# 3. Set strategies / views (optional)
sf portfolio strategy add "Fed thesis" "Long YES on Fed cut markets when IY > 30%"
sf portfolio view add "Recession 2026" "Soft landing more likely than hard" --conviction 4

# 4. Trigger first tick
sf portfolio trigger

# 5. Watch
sf portfolio status --json
sf portfolio history --json --ticks 10
```

See [Portfolio autopilot](/guides/portfolio-autopilot) and [Risk gates](/concepts/risk-gates).

## 4. Run an agent harness (headless)

```bash theme={null}
# Spawn sf in headless mode and pipe NDJSON in/out
sf agent --headless < your-tool-calls.ndjson > output.ndjson
```

Or wire into your own LLM loop:

```python theme={null}
import subprocess, json

proc = subprocess.Popen(
    ['sf', 'agent', '--headless'],
    stdin=subprocess.PIPE, stdout=subprocess.PIPE
)

# Send a tool call
proc.stdin.write(json.dumps({
    'tool_call_id': 'tc_1',
    'tool_name': 'query',
    'arguments': { 'q': 'Fed rate cut', 'limit': 3 }
}).encode() + b'\n')
proc.stdin.flush()

# Read result
result = json.loads(proc.stdout.readline())
print(result)
```

See [Build agents](/guides/agents).

## 5. Embed live odds in your site

```html theme={null}
<iframe
  src="https://simplefunctions.dev/embed/KXRATECUT-26DEC31"
  width="320" height="220"
  loading="lazy"
  style="border: 0; border-radius: 8px;"
></iframe>
```

Or with the `embed.js` helper:

```html theme={null}
<div data-sf-embed="KXRATECUT-26DEC31"></div>
<script src="https://simplefunctions.dev/embed.js" async></script>
```

See [Embed widget](/integrations/embed-widget).

## See also

<CardGroup cols={2}>
  <Card title="CLI command reference" href="/cli/command-reference">
    Every `sf` command.
  </Card>

  <Card title="API overview" href="/api-reference/overview">
    All HTTP endpoints.
  </Card>

  <Card title="Thesis lifecycle" href="/build/thesis-lifecycle">
    The full thesis conceptual model.
  </Card>
</CardGroup>
