This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Billy Bullshit is a brutally honest AI code reviewer running on Cloudflare Workers. It wraps LLMs (Workers AI, Anthropic, OpenAI) with a harsh but insightful code review persona, exposed as a REST API via the Hono framework.
Runtime: Cloudflare Workers Framework: Hono v3 Language: TypeScript (ESM) State: KV Namespace (conversation history, 7-day TTL) AI: Workers AI (primary) → Anthropic Claude (fallback) → OpenAI (last resort)
npm run dev # wrangler dev (local)
npm run deploy # wrangler deploy
npm run deploy:production # wrangler deploy --env production
npm run typecheck # tsc --noEmit
npm run build # esbuild bundle
npm test # vitestsrc/
├── index.ts # Hono app — routes, middleware, error handling
├── billy-agent.ts # BillyAgent class — persona, LLM calls, review logic
└── conversation-store.ts # ConversationStore — KV-backed session history
| Method | Path | Purpose |
|---|---|---|
| GET | / |
Service info and endpoint list |
| GET | /health |
Health check |
| POST | /review |
PRIMARY — Code review with BS scoring |
| POST | /chat |
Conversation with Billy |
| POST | /roast |
Savage roast mode |
| POST | /analyze |
Brutal analysis of any subject |
| POST | /debate |
Billy argues the opposite position |
| POST | /stream |
SSE streaming responses |
- Cloudflare Workers AI (
@cf/meta/llama-3.1-8b-instruct) — fast, free - Anthropic Claude — requires
ANTHROPIC_API_KEYsecret - OpenAI — requires
OPENAI_API_KEYsecret - Hardcoded fallback — random error quip
BillyAgent (billy-agent.ts)
reviewCode(code, language?, context?)— Primary function. Returns BS score (1-10), categorized issues (CRITICAL/MAJOR/BS/WTAF), and fixes.chat(message, history)— General conversation with personaroast(target, context?)— Maximum savagery modeanalyze(subject, type?)— Honest analysisdebate(position, topic)— Takes opposite positionstream(message)— Workers AI streaming responsegenerateResponse(messages)— Multi-provider fallback chain
ConversationStore (conversation-store.ts)
- KV-backed with
conversation:{sessionId}key pattern - 20 message cap, 7-day TTL auto-expiry
getHistory(),addMessage(),clearHistory(),getAllSessions()
| Binding | Type | Purpose |
|---|---|---|
AI |
Workers AI | Primary LLM provider |
CONVERSATIONS |
KV Namespace | Session history storage |
Set via wrangler secret put:
ANTHROPIC_API_KEY— Anthropic Claude API key (optional fallback)OPENAI_API_KEY— OpenAI API key (optional fallback)
| Variable | Default | Purpose |
|---|---|---|
ENVIRONMENT |
development |
Runtime environment |
MAX_CONVERSATION_LENGTH |
20 |
Max messages per session |
DEFAULT_MODEL |
@cf/meta/llama-3.1-8b-instruct |
Workers AI model |
- TypeScript with ESM (
type: "module") - Hono for routing and middleware
- 2-space indentation
- No external test frameworks beyond vitest
- Cloudflare Workers types for env bindings
Target domain: billy.chitty.cc (configured in wrangler.toml production env)
# Create KV namespace first
wrangler kv:namespace create "CONVERSATIONS"
wrangler kv:namespace create "CONVERSATIONS" --preview
# Set secrets
wrangler secret put ANTHROPIC_API_KEY
# Deploy
npm run deploy:production- KV namespace IDs in
wrangler.tomlare placeholders — must be created and filled in before deploy - No authentication on endpoints — any caller can use the API
- No rate limiting
- Dependencies are stale (hono v3, anthropic SDK v0.18)