/tradecraft:polymarket-prediction-agentsfrom tradecraft
Builds autonomous AI agents that trade on Polymarket prediction markets. Connects LLMs to Polymarket's DEX via Gamma API with RAG (Chroma DB) and news/web-search data sources.
Ships in tradecraft. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
USE FOR:
Developer framework for building autonomous AI agents that trade on Polymarket — a decentralized prediction market platform on Polygon.
┌──────────────── DATA LAYER ──────────────────┐
│ Gamma API → market metadata & events │
│ News providers → relevant articles │
│ Web search → real-time information │
│ Betting APIs → odds & market sentiment │
└───────────────────────┬──────────────────────┘
↓
┌──────────────── AI LAYER ────────────────────┐
│ LLM (OpenAI / any) → reasoning │
│ RAG (Chroma DB) → vectorized context │
│ Prompt utilities → structured queries │
└───────────────────────┬──────────────────────┘
↓
┌──────────────── EXECUTION LAYER ─────────────┐
│ py-clob-client → CLOB order generation │
│ Polygon wallet → on-chain signing │
│ Polymarket DEX → order execution │
└──────────────────────────────────────────────┘
git clone https://github.com/Polymarket/agents.git
cd agents
virtualenv --python=python3.9 .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
.env Configuration:
POLYGON_WALLET_PRIVATE_KEY="0x..." # Polygon wallet for trading
OPENAI_API_KEY="sk-..." # LLM provider
POLYMARKET_API_KEY="..." # Optional: API key tier
# List markets by volume
python scripts/python/cli.py get-all-markets --limit 5 --sort-by volume
# Get specific event
python scripts/python/cli.py get-market --market-id <id>
# Search markets by keyword
python scripts/python/cli.py get-markets --keyword "election" --limit 10
# Run autonomous trading agent
python agents/application/trade.py
# The agent will:
# 1. Fetch current markets via Gamma API
# 2. Retrieve relevant news + RAG context
# 3. Query LLM for probability assessment
# 4. Compare to market price → find edge
# 5. Sign + submit order via py-clob-client
from agents.utils.chroma import ChromaClient
# Vectorize news articles for retrieval
client = ChromaClient()
client.add_documents(news_articles)
# Query for market-relevant context
results = client.query("US election 2026 polling", n_results=5)
Edge = Estimated_Probability - Market_Price
If Edge > threshold → BUY YES / NO token
If Edge < -threshold → SELL or BUY opposite
LLM assesses probability from news + context; market price is the current token price (0–1).
| Component | Description |
|---|---|
Gamma API | Polymarket's REST API for markets/events data |
py-clob-client | Order book client for CLOB trading |
Chroma DB | Vector store for RAG-based news retrieval |
Prompt utils | LLM prompt engineering helpers |
trade.py | Main agent execution loop |
cli.py | CLI for market exploration |
# Custom analyst agent pattern
class MyPredictionAgent:
def analyze(self, market: dict) -> float:
context = self.rag.query(market["question"])
news = self.news_api.get_recent(market["question"])
prompt = f"""
Question: {market['question']}
Context: {context}
News: {news}
Current market price: {market['price']}
Estimate the true probability (0-1) and justify.
"""
response = self.llm.complete(prompt)
return self.parse_probability(response)
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
polymarket, prediction-markets, ai-agent, trading-bot, rag, chromadb
npx claudepluginhub mahmoud20138/tradecraft --plugin tradecraft169 skills in this plugin
/agent-developmentThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins./agentic-storageAgentic storage architecture — persistent memory for AI agents using MCP, immutable versioning, sandboxing, and intent validation. Covers the stateless problem in LLM agents, RAG limitations (read-only), MCP protocol (JSON-RPC, resources, tools), storage safety layers, and agent file system design. Source: IBM Technology (Martin Keen), March 2026. Use this skill for "agentic storage", "agent memory", "persistent agent state", "MCP storage", "agent file system", "agent hard drive", "stateless agent problem", "agent work product", "immutable versioning", "agent sandboxing", "intent validation", "agent safety layers", "agent context window limits", "storage for AI agents", "agent persistence", "autonomous agent storage", "agent audit trail". Works with mcp-integration, trading-brain, agents, trade-psychology-coach.
Other plugins' skills for the same job