BM / Brian's AI Marketing Team
Hermes Harness Opus 4.7 GPT-5.5 Pi Agent Cloudflare 40 Skills
// OVERVIEW

Your AI Marketing Team

Hermes acts as your AI CMO — you describe a marketing task in plain English, and it automatically routes to the right specialist agent running on the right model. Built on 40 battle-tested marketing skills, three CLI runtimes, and Cloudflare infrastructure that learns and improves every week.

40
Marketing Skills
6
Specialist Agents
3
CLI Runtimes
Self-Improving
┌──────────────────────────────────────────────────────────────────┐
│                    HERMES  (Your CMO)                          │
│          You talk to Hermes. Hermes runs the team.              │
└──────────────┬───────────────────────────────────────────────────┘
               │  reads CF KV routing weights
     ┌─────────┼──────────┐
     ▼         ▼          ▼
CLAUDE CODE   CODEX CLI   PI AGENT
Opus 4.7      GPT-5.5     Local / Any
High-craft     Volume       Zero-cost
Strategy       Social       Safety layer
CRO / Copy     Cold email   Parallel runs
               Ad variants

     └─────────┬──────────┘
               ▼
   .agents/skills/  (40 skills · single source)Cloudflare D1 · KV · R2 · Queue · AI Gateway
  
// ARCHITECTURE

How It Works

Hermes is a harness — a process manager that sits above all three CLIs. It doesn't live inside Claude Code. It decides which CLI to spin up, passes it the right skill, logs the result to Cloudflare, and gets smarter every week.

You: "Write 10 cold email variations for SaaS founders"
      │
      ▼
hermes/router.ts
  skill = 'cold-email'
  check KV routing:weights:cold-email:gpt-5.5 → score 4.3
  check KV routing:weights:cold-email:opus-4.7 → score 4.1
  decision: { cli: 'codex', model: 'gpt-5.5' }
      │
      ▼
hermes/dispatcher.ts
  spawn: codex --model gpt-5.5
  inject: .agents/product-marketing.md context
  run: cold-email skill
      │
      ▼
hermes/logger.ts
  D1: INSERT agent_runs (skill, model, cli, tokens, cost_cents)
  R2: PUT outputs/{run_id}/cold-emails.md
  KV: UPDATE token:used:gpt-5.5:{today}
      │
      ▼
Output returned to you
      │
      ▼  (you rate it: approved / revised / rejected)
D1: feedback_events
      │
      ▼  (Monday 9am)
Reflection Worker
  Re-scores skill × model composites
  Updates KV routing weights
  Hermes now knows GPT-5.5 wins cold-email
  
🧠
Hermes Harness
Routes tasks to the right model + CLI. Reads learned weights from CF KV. Improves weekly.
🔵
Claude Code + Opus 4.7
Deep reasoning, brand copy, strategy, CRO. High-craft tasks where quality justifies cost.
🟣
Codex CLI + GPT-5.5
Volume generation — social, cold email, ad variants. Fast and cost-efficient.
🟢
Pi Agent (Local)
Zero-cost tasks on local models. Safety guardrails. Parallel subagent execution. Camp chain pipelines.
☁️
Cloudflare Stack
D1 logs every run. KV stores routing weights. R2 stores outputs. Queue enables parallelism. AI Gateway caches prompts.
🔁
Self-Improving
Reflection Worker runs weekly. Scores skill × model. Rewrites routing weights. Gets smarter without manual tuning.
// INSTALLATION

Setup in 6 Steps

Everything you need to go from zero to a running marketing team. Run these commands in order. Total setup time is under 30 minutes.

Prerequisites

REQUIRED BEFORE STARTING
Claude Code
Install: npm install -g @anthropic-ai/claude-code · Requires Node 18+
Codex CLI
Install: npm install -g @openai/codex
Pi Agent
Install: npm install -g @badlogicgames/pi
Wrangler
Install: npm install -g wrangler then wrangler login
API Keys
ANTHROPIC_API_KEY · OPENAI_API_KEY · CLOUDFLARE_ACCOUNT_ID + API_TOKEN

Step-by-Step

// SPECIALIST AGENTS

Your 6-Person Team

Each agent is a specialist with a defined set of skills. Hermes decides who handles each request. All agents automatically read your product-marketing.md context before working.

Agent Default CLI/Model Skills Best for
Content Agent Claude Code / Opus 4.7 copywriting, copy-editing, emails, social, cold-email, video, image Brand voice, blog posts, email sequences
SEO Agent Claude Code / Opus 4.7 seo-audit, ai-seo, programmatic-seo, schema, site-architecture, competitors Audits, keyword strategy, schema markup
CRO Agent Claude Code / Opus 4.7 cro, signup, onboarding, popups, paywalls, ab-testing Landing page optimization, conversion flows
Paid Agent Codex CLI / GPT-5.5 ads, ad-creative, analytics, ab-testing Ad copy variants, campaign briefs, reporting
Growth Agent Codex CLI / GPT-5.5 referrals, free-tools, churn-prevention, co-marketing, community, lead-magnets Referral programs, retention, partnerships
Strategy Agent Claude Code / Opus 4.7 marketing-ideas, marketing-psychology, launch, pricing, revops, sales-enablement Go-to-market, positioning, launch plans
// MARKETINGSKILLS LIBRARY

40 Skills · One Library

All skills come from coreyhaines31/marketingskills — Agent Skills spec v2.0. They live in .agents/skills/ and are symlinked into all three CLIs. One update propagates everywhere.

✍️
Content
copywriting · copy-editing · emails · social · cold-email · video · image
🔍
SEO
seo-audit · ai-seo · programmatic-seo · schema · site-architecture · competitor-profiling
📈
CRO
cro · signup · onboarding · popups · paywalls · ab-testing
💰
Paid & Analytics
ads · ad-creative · analytics · ab-testing
🚀
Growth
referrals · free-tools · churn-prevention · co-marketing · community · lead-magnets
🧩
Strategy
marketing-ideas · marketing-psychology · launch · pricing · revops · sales-enablement

Pi Agent Extensions (disler/pi-vs-claude-code)

ExtensionWhat it unlocks
cross-agent.tsAuto-registers all .claude/ + .codex/ agents in Pi. Zero duplication.
agent-team.tsLive team grid dashboard — see which agent is running in real time.
agent-chain.tsCampaign pipelines as YAML — research → strategy → copy → review.
damage-control.tsSafety guardrails for autonomous CF writes and agent prompt updates.
subagent-widget.tsParallel execution — SEO + CRO + Competitor audits simultaneously.
tool-counter.tsPer-tool token cost tracking → feeds D1 for cost-aware routing.
pi-pi.tsMeta-agent that builds new specialist agents on demand.
// CLOUDFLARE INFRASTRUCTURE

The Brain in the Cloud

Five Cloudflare primitives work together to log every run, cache expensive prompts, queue parallel tasks, track token budgets, and store all outputs. The Reflection Worker reads this data every Monday and makes Hermes smarter.

CF AI GATEWAY
  All model API calls route through here (Anthropic + OpenAI endpoints)
  • Prompt cache: SHA-256 hash · saves tokens on repeated tasks
  • Cache TTL by skill: social=1800s · strategy=86400s · analytics=skip
  • Token tracking: input/output/cost per request
  • Model fallback: Opus 4.7 → Sonnet if unavailable
  • DLP guardrails: PII scan on prompts
      │
      ▼
CF QUEUE  (hermes-jobs)
  Hermes pushes { skill, model, cli, input, run_id }
  Queue Worker pulls → spawns CLI process
  • Parallel execution (SEO + CRO + Competitor simultaneously)
  • Auto-retry 3x on failure
  • Dead-letter → D1 failed_runs table
      │
      ▼
D1  (marketing-brain)
  agent_runs    — every invocation: model, cli, tokens, cost_cents, cache_hit
  feedback_events — your ratings (1-5 / approved / shipped / rejected)
  model_scores  — skill × model composite scores (updated weekly)
  campaign_log  — full campaign sequences with agent chains
  failed_runs   — dead-letter queue for debugging

KV  (MARKETING_KV)
  routing:weights:{skill}:{model}   — Hermes routing priors
  token:budget:{model}              — daily spend cap per model
  token:used:{model}:{date}         — running daily spend
  product-marketing:latest          — current product context
  cache:output:{skill}:{hash}       — R2 pointer for output cache

R2  (marketing-brain-outputs)
  outputs/{run_id}/        — full agent outputs (md files)
  cache/{skill}/{hash}/    — output cache layer
  improvement/{date}/      — weekly Reflection Worker summaries
  product-marketing/v{n}.md — versioned product context history
  

Token Budget System

Before every dispatch, Hermes checks your daily budget in KV. If Opus 4.7 hits its daily cap, it automatically downgrades to Sonnet. Costs accumulate in KV throughout the day and reset at midnight.

// hermes/router.ts — budget check before every dispatch
const used   = await env.KV.get(`token:used:${model}:${today}`);
const budget = await env.KV.get(`token:budget:${model}`);

if (Number(used) >= Number(budget)) {
  model = FALLBACK_MODELS[model]; // opus-4.7 → claude-sonnet-4-6
}

// After run — increment spend
await env.KV.put(
  `token:used:${model}:${today}`,
  String(Number(used || 0) + cost_cents)
);
  
// SMART ROUTING + SELF-IMPROVEMENT

How Hermes Learns

Every run is scored. Every Monday, the Reflection Worker reads the scores, computes which model wins each skill, and rewrites the routing weights. Hermes gets smarter without any manual tuning.

Reflection Worker  (Cloudflare Cron — every Monday 9am)

1. Query D1 agent_runs + feedback_events (last 7 days)
   GROUP BY skill_used × model

2. Compute per (skill, model):
   avg_score · approval_rate · avg_cost_cents
   composite = (avg_score × approval_rate) / avg_cost_cents

3. Example after 4 weeks:
   routing:weights:copywriting:opus-4.7  → composite 1.82  (wins)
   routing:weights:copywriting:gpt-5.5   → composite 1.21
   routing:weights:social:opus-4.7       → composite 0.71
   routing:weights:social:gpt-5.5        → composite 1.43  (wins)

4. UPDATE D1 model_scores
   PUT KV routing:weights:* (new values)
   Write improvement/YYYY-MM-DD/summary.md → R2

5. Next request for "copywriting" → Hermes routes to Opus 4.7
   Next request for "social" → Hermes routes to GPT-5.5
   You never had to configure this. It learned from your feedback.
  
DEFAULT ROUTING PRIORS (before data)
Opus 4.7
copywriting · strategy · cro · seo-audit · pricing · launch · revops · customer-research
GPT-5.5
social · cold-email · ad-creative · analytics · emails · copy-editing · ab-testing · directory
Pi / Local
image · video · programmatic-seo · schema · lead-magnets · community · referrals
// USING HERMES

Talking to Your Team

You talk to Hermes in plain English. Hermes decides who handles it and which model fires. Use these commands to trigger specific workflows.

CommandWhat it doesExample
/campaignFull campaign brief — routes through Strategy → Content → Paid agents/campaign launch my new SaaS product to startup CTOs
/copyDirect to Content Agent — copywriting, emails, social/copy write 5 cold email variations for B2B SaaS
/auditSEO + CRO parallel audit via Pi subagent-widget/audit my-site.com
/adsPaid Agent — Google/Meta ad copy and creative briefs/ads generate 10 Facebook ad variants for our trial offer
/strategyStrategy Agent — positioning, launch, pricing/strategy help me position against HubSpot for SMBs
/launchFull launch chain — Strategy → Content → SEO → Paid in sequence/launch Product Hunt launch plan
/feedbackRate last output — trains the routing weights/feedback approved · 5 · great tone
/weekly-reportPull D1 data — what ran, what scored, cost summary/weekly-report

First Thing to Do

// FULL STACK

What's Under the Hood

LayerTechnologyRole
OrchestratorHermes Harness (TypeScript)Routes, dispatches, logs every task
CLI AClaude Code + Opus 4.7High-craft, deep reasoning tasks
CLI BCodex CLI + GPT-5.5Volume, speed, cost-efficient tasks
CLI CPi Agent + Ollama/LocalZero-cost + safety + parallel execution
Skillscoreyhaines31/marketingskills v2.040 marketing skills, cross-CLI compatible
Pi Extensionsdisler/pi-vs-claude-codeagent-chain, damage-control, subagent-widget, pi-pi
AI GatewayCloudflare AI GatewayPrompt caching, token tracking, model fallback
QueueCloudflare QueuesAsync parallel dispatch, retry, dead-letter
DatabaseCloudflare D1 (SQLite)Run logs, feedback, model scores
StateCloudflare KVRouting weights, token budgets, product context
StorageCloudflare R2Output artifacts, improvement summaries
CronCloudflare Workers (cron)Reflection Worker — weekly self-improvement