CLI · @spfunctions/cli
The local CLI for live prediction markets.
sf queries Kalshi and Polymarket as one stream, exports structured JSON, and hands real market state to Claude Code, Codex, cron jobs, and shell agents.
read
sf world --jsondiscover
sf discover --quality --jsoninvestigate
sf investigate "Fed rate cuts" --json --include query,econ,markets,toolshandoff
sf describe --all --jsonnpm install -g @spfunctions/cliRead state
sf world --jsonCurrent regime, salient markets, live freshness, and next objects as JSON — about 800 tokens, no auth.
Investigate
sf investigate "Fed rate cuts" --json --include query,econ,markets,toolsA topic packet with prediction-market evidence, FRED rate series, traditional anchors, and next commands.
Agent handoff
sf describe --all --jsonRecursive command manifest with auth, policy tags, JSON support, and side-effect metadata.
Commands.
Full reference →Start here
sf status --jsonsf world --jsonsf discover --quality --jsonsf investigate "topic" --jsonsf inspect <ticker> --jsonAgent bootstrap
Ground the model in the installed surface before it starts guessing commands.
sf status --jsonHealth, API, auth, exchange, runtime, and portfolio readiness.
sf doctor --agent --deep --jsonSelf-diagnosis for JSON contract, manifest truth, auth, and workflow readiness.
sf describe --all --jsonRecursive command catalog with auth, policy tags, and side-effect metadata.
sf tools plan "task" --jsonPlan an ordered command sequence from the live local catalog.
Market state
Read live world, topic, market, and orderbook context before touching user state.
sf world --jsonSalience-ranked world state for agents, about 800 tokens, no auth.
sf discover --quality --jsonRanked ideas, world, cross-venue, new-market, and contagion feed.
sf investigate "topic" --jsonRead-only packet that fuses world, query, econ, gov, traditional markets, and next commands.
sf inspect <ticker> --jsonComplete ticker dossier with regime, indicators, edges, suggestion, and next actions.
Operator state
Authenticated user context stays explicit: portfolio, thesis, watchlist, alerts, and traces.
sf me --jsonBounded boot context: status, portfolio, Kalshi, and Polymarket.
sf brief --agent --jsonCompact user, workflow, and world brief for an agent loop.
sf watchlist add --ticker <ticker> --jsonSave a watched market object for Plate, alerts, webhooks, and agents.
sf trace receipt trace.ndjson --jsonSummarize recorded agent calls, risk classes, and receipt metadata.
Execution & runtime
Side-effecting surfaces are explicit, policy-tagged, and start in paper or intent mode.
sf intent buy <ticker> <qty> --jsonCreate a buy intent through the declarative execution gateway.
sf runtime start --smartStart the execution runtime with trigger evaluation and LLM soft conditions.
sf quote create <ticker> --paperCreate a market-making quote in paper mode before live venue mutation.
sf workflow demo monitor --dry-run --jsonDry-run watchlist, alert, webhook, and Plate workflow setup without mutating server state.
Read-only market state never asks for venue trading credentials. Authenticated and side-effecting commands stay explicit, policy-tagged, and inspectable.
Hand market state to your agent.
Discover the surface, read state, plan from the manifest, and keep side effects blocked until explicitly allowed. The most useful path for agent-native prediction market work.
sf status --json
sf doctor --agent --deep --json
sf describe --all --json > sf-tools.json
sf world --json > sf-world.json
sf investigate "Fed rate cuts" --json --include query,econ,markets,toolssf agent --plain --allow read,user_data --once "Use sf-world.json and sf-tools.json to identify risks"
sf agent --headless --deny trade,runtimeIntegration surfaces.
CLI is canonical. HTTP/Data API serves remote services and dashboards. SDK and Agent SDK are wrappers, not a second truth. MCP is compatibility for hosts that need it.
CLI
PrimaryLocal control plane for humans, scripts, coding agents, cron, policy-gated workflows, and every command that benefits from shell composition.
HTTP / Data API
Network surfaceFor services, notebooks, dashboards, remote workers, and clients that cannot shell out to sf.
SDK
In developmentTyped clients over stable HTTP/Data API objects. The SDK wraps existing contracts; it is not a second truth.
Agent SDK / runtime
In developmentPackages command selection, permission policy, traces, budgets, wake checks, and loop mechanics.
MCP adapter
CompatibilityFor MCP-only hosts. Useful when a host requires MCP, but not the canonical product center.
Workflows.
Recognize the job, run the chain. Read-only research first, monitoring next, execution behind explicit gates.
Research loop
world → discover → investigate → inspect → thesisRead-heavy, no venue credentials required.
Agent loop
status → doctor → describe → tools plan → agent --plainGround the model in the installed surface before tool use.
Monitoring loop
watchlist → alerts → webhooks → workflow demo monitorReactive objects instead of polling every market manually.
Execution loop
intent → runtime → fills → reconcile → trace receiptSide effects stay declarative, inspectable, and replayable.
Market making
book → quote create --paper → quoteengine start → quote listPaper first, live only after venue credentials and risk gates.
224
CLI commands
96
Agent tools
86
Data endpoints
102
MCP adapters
Questions.
What package do I install?
Install @spfunctions/cli from npm with npm install -g @spfunctions/cli. The executable is sf.
What should I run first?
Run sf world --json to fetch the current world state, then use sf discover --quality --json, sf investigate "topic" --json, and sf inspect <ticker> --json for more specific market workflows.
Is this just a wrapper around Kalshi and Polymarket?
No. Venue aggregation is only the base layer. sf adds normalized market state, topic discovery, event dossiers, JSON contracts, workflow planning, traces, and agent-safe command surfaces.
Do I need venue credentials?
Read-only market state commands such as world, discover, investigate, inspect, book, and cross-venue do not require trading credentials. Portfolio, execution, user-data, runtime, alerts, webhooks, and live venue operations require auth or configured credentials.
Why CLI first?
Agents, scripts, and operators need a local, inspectable, composable surface before remote automation. The CLI is the fastest way to expose product truth to humans and coding agents.
Is MCP required?
No. MCP is a compatibility adapter for MCP-only hosts. CLI and HTTP/Data API remain the canonical surfaces.
Can commands place live trades?
Some direct trading commands can place live orders when trading is enabled and venue credentials are configured. For automation, prefer declarative intents, paper quote workflows, runtime gates, traces, and explicit allow or deny policy.
Continue exploring.
Documentation index for agents →Agentic CLI
cliHow Claude Code, Codex, and shell agents use sf through JSON, plain mode, headless mode, and policy gates.
Kalshi CLI
cliOperator-focused command-line workflows for Kalshi and cross-venue prediction markets.
Prediction Market API
apiThe HTTP/Data API surface behind CLI reads and service integrations.
Real-Time Data API
apiStreaming and REST data surfaces behind live market workflows.
AI Agents
guideAgent integration surfaces ordered as CLI, API, then MCP compatibility.
CLI reference
docsExact commands, options, JSON output shape, auth requirements, and side-effect metadata.