Blog
Architecture
Overview Harness Data Layer Skills
Pricing Get Started

How Kai Works

Harness engineering for marketing. 28 quality rules score every piece. 8 YAML policies gate publishing. A self-improvement loop makes the 50th piece better than the 1st.

28
Quality Rules
8
Gate Policies
14
Marketing Skills
15+
API Integrations

Content Harness

A CI/CD pipeline for marketing content. Brief → Write → Score → Gate → Publish → Check → Learn. Each stage enforced.

1

Brief Generator

Pulls live GSC + GA4 data. Identifies competitor weakness. Outputs structured JSON brief.

2

Content Writer

Loads knowledge frameworks, winning patterns, and MARKETING.md config. No free choices about structure.

3

Quality Scorer

28 rules across 4 categories score 0–100. Per-line violations with exact fix suggestions.

4

Gate

YAML policy decides: auto-approve (score ≥85), hold for review (60–85), or reject (<60). SQLite audit trail.

5

Surgical Revision

On rejection, feeds exact violations back to the writer. Rule ID, line number, fix suggestion. Max 2 retries.

6

Discord Approval

Posts draft + score + proposal ID. Human approves or rejects. python -m scripts.quality gate --approve <id>

7

30-Day Check

Cron pulls GSC position + CTR, GA4 session duration. Grades winner / avg / underperformer.

Deep dive into each stage View on GitHub

Unified Quality Scorer

28 rules encoding marketing research into automated checks. Algorithmic Authorship, GEO/AEO citation science, content structure, and Four U's — all scored per-line with fix suggestions.

Algorithmic Authorship (35%)

Conditions after clauses, verb-first instructions, sentence length, anchor words, entity naming, back-references, filler detection. 15 rules from SEO research.

GEO/AEO Signals (20%)

Citation density, quotation marks, statistics per 1K words, technical term frequency. Based on academic research: citations +115%, quotes +40%, stats +37%.

Content Structure (25%)

Reading level (grade 6–8), active voice ≥90%, heading balance, paragraph length, you/your ratio, AI cliche detection.

Four U's (20%)

LLM-scored uniqueness, usefulness, specificity, urgency. Each 1–4, minimum 12/16. Separate model call — grader ≠ writer.

$ python -m scripts.quality score article.md

Score: 78.3/100 (grade C)

Algorithmic Authorship:  82.1  (weight 0.35)
GEO/AEO Signals:        65.0  (weight 0.20)
Content Structure:       89.4  (weight 0.25)
Four U's:               71.0  (weight 0.20)

Top fixes:
1. [AA-01] Condition before clause (line 14, 6 violations)
   "If you want better results, do X" → "Do X to get better results"
2. [GEO-01] Citation density low (3 per 1K words, target: 5)
3. [CS-07] AI cliche detected (line 42): "it's important to note"

8 Gate Policies

Each content format has a YAML policy. Auto-approve, hold, or reject based on score. Required rules and blocked terms per format. Change the YAML, change the behavior.

Policy Format Auto-approve Hold Reject Blocked terms
blog-publish Blog, SEO ≥85 60–85 <60 "in conclusion", "harness the power"...
linkedin-article LinkedIn ≥80 55–80 <55 "it's important to note"...
cold-email Cold email ≥75 50–75 <50 "guaranteed", "act now"...
press-release PR ≥80 55–80 <55 "excited to announce", "industry-leading"...
tiktok-script TikTok ≥70 45–70 <45 "link in bio", "mind-blowing"
meta-ad Meta ads ≥70 45–70 <45 "click here", "don't miss out"...
google-ad Google ads ≥65 40–65 <40
default Everything else ≥85 60–85 <60

The System Gets Smarter

Every published piece feeds data back. Quality scores correlate with search performance. Policy thresholds auto-adjust. The 100th piece has 99 data points behind it.

Nightly: Retro Score

Batch quality-scores all published content. Stores per-rule scores alongside GSC/GA4 performance data.

Weekly: Rule Correlation

Correlates quality rule scores with winner/loser classification. Finds which rules actually predict search success.

Weekly: Pattern Extract

Surfaces statistical patterns: best persona per site, best hook type, best publish day. Only states patterns with n≥5 and ≥15% lift.

Auto-Update: Policy Thresholds

When winner patterns emerge, adjusts YAML policy approve/reject thresholds. Updates MARKETING.md learned defaults. Next run picks up changes without restart.

3-Tier Agent Hierarchy

One orchestrator. Seven domain specialists. Each agent gets only the context it needs.

Tier 1 — Orchestrator
Kai-CMO (this session)
Receives all Discord messages. Routes to domain agents or handles inline. Aggregates results. Posts cross-product summaries to #updates. Never does domain work itself.
spawns ↓
Tier 2 — Domain Agents
7 Specialists
Each agent owns a product or function. Runs in its own session. Posts directly to its Discord channel.
📞 KaiCalls — leads, outreach
🎉 ABP — vendor matching
💰 Finance — Stripe, MRR
⛩️ Gate — approvals, health
🏗️ BWK — signups, activity
🏥 Infra — VPS, cron
📚 Research — papers, patents
loads ↓
Tier 3 — Skills
Procedural Guides
Skills are procedural guides loaded into the orchestrator's context when needed. They describe how to do something. Agents do the actual work.
seo-content linkedin-writing cold-email meta-advertising tiktok-marketing press-releases algorithmic-authorship perception-engineering landing-pages technical-seo dev-workflow kaicalls-outbound abp-vendor-match coding-agent
heartbeat fires (every 30 min)
  ├── sessions_spawn(kaicalls-agent)  → #kai-calls
  ├── sessions_spawn(abp-agent)       → #awesomebackyard
  ├── sessions_spawn(finance-agent)   → #finance
  ├── sessions_spawn(gate-agent)      → #zehrava
  ├── sessions_spawn(bwk-agent)       → #build-with-kai
  ├── sessions_spawn(infra-agent)     → #health
  └── sessions_spawn(research-agent)  → #research
  sessions_yield()
  → each agent returns NOTHING or posts directly to its channel
  → 7 checks in parallel ~30s vs. serial ~3.5min

Zehrava Gate

Every write action — emails sent, calls made, vendor outreach — goes through Gate before execution. Human approval, then automation.

Intent Proposal

Agent proposes an action (e.g. gmail.send, kaicalls.outbound). Gate holds it pending approval. Nothing executes until a human approves at the dashboard.

Policy Enforcement

Each intent type has a policy. abp-followup-call enforces TCPA hours. outbound-email checks for duplicates. Rules run before approval is even requested.

Approval Dashboard

All pending, approved, and blocked proposals visible at zehrava.com/dashboard. One click to approve or block. PII scrubbed from the public log.

ABP lead arrives → abp-agent runs
  ├── ZIP → NJ → Ken Rent match
  ├── OpenAI draft vendor email
  ├── gate.propose({ policy: "outbound-email", payload: {...} })
  │     → returns proposalId
  ├── Post to #awesomebackyard: "Approve at zehrava.com/dashboard"
  └── Human approves → email sends automatically
      No code. No re-run. Gate handles execution on approval.

Visit Zehrava Data Layer

CMO Analytics CLI

~5,800 lines of Python. One command for any metric across 10+ data sources.

$ cmo kaicalls leads --days=7
# 57 leads this week. 34 with emails. Houston HVAC top source.

$ cmo ga4 all --days=7
# Traffic overview for ALL 10 sites in one table

$ cmo stripe_report mrr
# MRR: $67.91 | 11 active subs | 0 at-risk

$ cmo gsc opportunities --site=kaicalls
# SEO opportunities: 12 keywords ranking 4-10 (low-hanging fruit)

$ cmo daily_report executive
# Cross-product status in 30 seconds
Module Commands Data Source
kaicalls leads, calls, agents, transcripts, dashboard, funnel, weekly Supabase
bwk counts, businesses, plans, generations, invocations Supabase
abp counts, leads, vendors, blog, dashboard Supabase
ga4 sites, overview, pages, sources, channels, daily, all Google Analytics
gsc sites, queries, pages, opportunities, devices, gaps Search Console
stripe_report mrr, revenue, subs, customers, overview, at-risk Stripe API
instantly campaigns, leads, stats, upload Instantly API
daily_report executive, daily, weekly All sources

Marketing Knowledge Base

100+ markdown files. 1000+ indexed chunks. Semantic search via ChromaDB.

100+
Markdown Files
1000+
Indexed Chunks
11
AEO Frameworks
16
Checklists
/knowledge/
├── frameworks/
│   ├── content-copywriting/    # Algorithmic Authorship, Four U's, QDP
│   ├── aeo-ai-search/          # Perplexity ranking, Entity SEO, AEO
│   └── meta-advertising/       # Andromeda, GEM, Lattice
├── channels/                   # LinkedIn, SEO, email, PR, TikTok (10)
├── checklists/                 # Content, SEO, technical audits (16)
├── personas/                   # 8 audience archetypes + pain points
├── playbooks/                  # Local SEO, content velocity, TAM (8)
├── design/                     # B2B SaaS, B2C fintech guides
└── examples/                   # LinkedIn articles scoring 14-16/16

15+ API Integrations

Everything connected. Everything automated.

Google Analytics
Search Console
Stripe
Supabase
Gmail
Calendar
Discord
Apollo
Instantly
ElevenLabs
OpenAI
Perplexity
Reddit
Apify
Firecrawl

Want to see the code?

The harness page walks through every stage of the content pipeline with implementation details, config examples, and real output.

Read the Harness Deep-Dive View Pricing