API · AI Agents

Most Polymarket bots in 2026 are built by prompting an AI coding agent — Claude Code, Cursor, Copilot. That's fine, if you keep the agent on the current V2 API and on a safety rail. This page shows how: install our rules + read-only tooling so the generated code is correct and starts in paper mode, and follow the checklist before anything touches real money.

Give your agent the rules first. Drop our AGENTS.md into your repo (Claude Code, Cursor, Copilot and others read it). It pins the V2 SDKs, base URLs, pUSD contracts, the gotchas, and a paper-default money rail — so the agent stops writing dead V1 (py-clob-client 0.34 / USDC.e) code.

Set your agent up

  • Rules: add AGENTS.md to your repo root (and a CLAUDE.md symlink / .cursor/rules mirror).
  • Context: point the agent at our llms.txt and the API reference so it grounds answers in current docs, not its training guess.
  • Grounding data: install the read-only MCP so token IDs come from live markets, not hallucinations.

The safe-vibe-coding checklist

Hold every AI-generated trading bot to this before you let it run live:

  1. Start read-only — market data first, no orders.
  2. Paper mode by default; live trading requires an explicit --live flag.
  3. Keys in environment variables only — never hardcoded, logged, or committed.
  4. Pin the official V2 SDK + base URLs so the agent can't invent endpoints.
  5. Ground on the spec / MCP — don't trust an endpoint the agent "remembers".
  6. Fail closed on bad data — never place a trade on a failed or empty fetch.
  7. Human review before the first live run.
  8. Hard position & loss limits + a kill switch.
Why this matters. Vibe-coded trading bots fail in known ways: trading on hallucinated prices, using dead V1 patterns, installing hallucinated packages (slopsquatting), and hardcoding keys. The rules file + read-only MCP + paper-first scaffold close every one of those by default.

A good first prompt

Using the Polymarket V2 API (py-clob-client-v2) and the AGENTS.md rules in this repo,
write a PAPER bot that finds the BTC-above-150k market, reads its order book, and would
buy Yes under 0.40. Do NOT place live orders. Keys from env only. Fail closed on bad data.

The agent should produce paper-mode code, with real token IDs (from the MCP/live data), keys read from the environment, and no live order path unless you add --live yourself.

Give your agent real markets

Hallucinated token IDs are the #1 vibe-coding bug. Search a real market here, copy its IDs, and hand them to the agent (or let the MCP do it):

Next: The AGENTS.md rules · Which SDK to use · Fix an error.

Not financial advice. Automated trading risks real money — test in paper mode and review before going live.