I built a hive mind for my AI agents (and they coordinate better than most teams)
I run 4-5 Claude Code agents simultaneously. One is refactoring my astrology platform's transit engine. Another is publishing articles across four blog platforms. A third is generating TikTok videos with ML-scored engagement predictions. A fourth is autonomously building UI components, recording them, and posting to X.
They all share the same brand voice, the same knowledge base, the same metrics, and the same understanding of what the others are doing right now.
This is the system I built to make that work.
What the hive mind actually is
It's not one thing. It's a network of interconnected systems that give every AI agent access to:
- Shared memory across all projects (what's being worked on, what was decided, what's broken)
- 140+ tools via MCP servers (schedule posts, query analytics, publish articles, manage photos)
- A local brand API that injects domain knowledge into every generation call
- Cross-account boost rules that automatically amplify content between accounts
- Autonomous pipelines that research, build, record, and publish without human input
Here's the full architecture:
Claude Code agents (4-5 concurrent sessions)
│
├── Shared Memory Layer (16 markdown files)
│ ├── active-work.md ← live coordination
│ ├── projects/*.md ← per-project state
│ ├── gotchas.md ← known bugs
│ ├── decisions.md ← architecture choices
│ └── live-metrics.md ← auto-updated daily
│
├── MCP Servers (5 registered)
│ ├── Spellcast MCP ← 140 tools: posts, articles, analytics, AI content, boosts
│ ├── Lunary MCP ← 100+ tools: metrics, grimoire, OG images, video scripts
│ ├── Photos MCP ← 22 tools: album access, usage tracking, Spellcast pipeline
│ ├── Blog MCP ← 6 tools: personal blog CRUD + publish
│ └── Git MCP ← standard git operations
│
├── Brand API (localhost:9002)
│ ├── Ollama (llama3.1:8b with brand system prompt)
│ ├── 40+ grimoire JSON files (crystals, tarot, spells, zodiac)
│ ├── 10 brand knowledge markdown files
│ └── Smart context injection (only loads relevant data per query)
│
├── Open WebUI (localhost:8080)
│ ├── 4 knowledge bases (Sammii Brain, Grimoire, Content Strategy, Tech Architecture)
│ └── 5 Python tools (brand knowledge, grimoire search, content engine, metrics, Spellcast)
│
└── Autonomous Pipelines
├── Content Creator ← video/carousel generation + ML scoring + Spellcast scheduling
├── Prism Pipeline ← scout → curator → builder → recorder → publisher (daily)
└── Daily Metrics Cron ← pulls DAU/MAU/MRR at 07:00, writes to live-metrics.md
Every piece connects to the others. Let me walk through each layer.
Layer 1: shared memory (how agents coordinate)
The core problem: when I start a new Claude session, it has no idea what my other agents are doing. Two agents might both try to modify the same config file. One might re-solve a bug another already fixed.
The fix is a directory of markdown files at ~/.claude/projects/.../memory/ that every agent reads on startup and updates continuously as it works.
The critical file is active-work.md:
## In Progress
### [lunary] - Refactoring transit engine
- **Started**: 2026-03-06 10:00
- **Doing**: Rewriting severity calculation
- **Files touched**: src/lib/transits.ts, src/lib/severity.ts
- **Status**: working
### [spellcast] - Article publishing pipeline
- **Started**: 2026-03-06 10:30
- **Doing**: Adding LinkedIn companion post generation
- **Files touched**: apps/api/src/routes/articles.ts
- **Status**: working
### [prism] - Design engineering component library
- **Started**: 2026-03-06
- **Doing**: Building MagneticButton component
- **Files touched**: prism/ (entire project)
- **Status**: working
Every agent checks this before starting work. Every agent updates it as status changes. Every agent removes its entry when done. It's a coordination protocol built entirely on file reads and writes.
The key insight: continuous updates, not batch updates at session end. If an agent crashes, its entry stays visible. If an agent finishes something, others see it immediately.
I'll cover the full memory system in Part 2 of this series.
Layer 2: MCP servers (the tool network)
MCP (Model Context Protocol) lets Claude call external tools during a session. I have five servers registered, giving every agent access to the same capabilities.
Spellcast MCP: 140 tools for content operations
Spellcast is my social media scheduling platform. Its MCP server exposes everything:
// spellcast-mcp/src/index.ts
const server = new McpServer({ name: "spellcast", version: "1.0.0" });
registerPostTools(server); // 30 tools: create, schedule, bulk operations
registerArticleTools(server); // 6 tools: publish to Dev.to, Hashnode, Medium
registerAnalyticsTools(server); // 9 tools: engagement trends, best times, velocity
registerContentTools(server); // 15 tools: AI generation, variations, scoring
registerEngagementTools(server); // 15 tools: replies, discovery, competitor tracking
registerBoostTools(server); // 6 tools: cross-account amplification
registerAutopilotTools(server); // 7 tools: autonomous post generation
registerBrandVoiceTools(server); // 5 tools: per-account voice profiles
registerAbTestTools(server); // 5 tools: content A/B testing
// ... plus campaigns, dumps, RSS, categories, system
This means any Claude agent, in any project, can schedule posts, publish articles, analyse engagement, generate AI content, and manage boost rules. The agent working on Lunary can pull fresh metrics and create a Build in Public tweet without switching context.
Lunary MCP: 100+ tools for product analytics
The Lunary MCP connects directly to my admin API:
// lunary-mcp/src/client.ts
async function lunary(path: string, options = {}): Promise {
const res = await fetch(`${BASE_URL}/api/admin${path}`, {
headers: { Authorization: `Bearer ${ADMIN_KEY}` },
// ...
});
}
It exposes analytics (DAU/WAU/MAU, revenue, cohort retention, feature adoption), grimoire search (semantic vector search across 2,000+ articles), OG image generation with auto-scheduling to Spellcast, video script generation, and the Astral Guide AI chat.
The social tools are particularly interesting. They bridge Lunary and Spellcast:
// lunary-mcp/src/tools/social.ts
async function uploadToSpellcast(imageBuffer: Buffer, filename: string) {
const formData = new FormData();
formData.append('file', new Blob([imageBuffer]), filename);
const res = await fetch(`${SPELLCAST_API_URL}/api/media/upload`, {
method: 'POST',
headers: { Authorization: `Bearer ${SPELLCAST_API_KEY}` },
body: formData,
});
}
Lunary generates OG images (horoscope cards, moon phase graphics, cosmic state visualisations), uploads them to Spellcast's CDN, generates AI captions, and auto-schedules them with cadence guards so accounts don't over-post.
Photos MCP: 22 tools bridging macOS Photos to social
This one connects my local Photos.app library to the publishing pipeline:
// photos-mcp/src/tools/pipeline.ts
async function uploadToSpellcast(filePath: string) {
const fileBuffer = readFileSync(filePath);
const formData = new FormData();
formData.append('file', new Blob([fileBuffer], { type: mimeType }), filename);
const res = await fetch(`${SPELLCAST_API_URL}/api/media/upload`, {
method: 'POST',
headers: { Authorization: `Bearer ${SPELLCAST_API_KEY}` },
body: formData,
});
}
I can tell Claude "post unused photos from the Concepts album to Instagram" and it will browse my Photos library via osxphotos, find unused images, upload them to Spellcast, generate AI captions, and schedule them with cadence-aware timing. It tracks which photos have been used so nothing gets double-posted.
Layer 3: the brand API (local knowledge injection)
Every AI-generated caption, comment, article, and boost reply needs to sound like me and know my domain. That's what the Brand API does.
It's a Node.js server wrapping Ollama (running llama3.1:8b locally) that intelligently injects relevant knowledge into every LLM call:
// ollama-brand/src/server.ts
const PORT = Number(process.env.PORT ?? 9002);
const OLLAMA_URL = process.env.OLLAMA_URL ?? 'http://localhost:11434';
const MODEL = process.env.MODEL ?? 'sammii-brand';
const MAX_CONTEXT_TOKENS = Number(process.env.MAX_CONTEXT_TOKENS ?? 12000);
The clever part is smart context injection. When a query comes in about crystals, it only loads crystal data. When it's about tarot, it only loads tarot cards. It analyses the query to determine which of 40+ data sources are relevant:
POST /analyze { "query": "What crystals help with protection?" }
Response:
{
"active": ["crystals", "correspondences", "moonPlacements"],
"estimatedTokens": 7500
}
The data sources include 30+ crystals with chakra and element mappings, 78 tarot cards (full Major and Minor Arcana), 20+ spells with ingredients and timing, Elder Futhark runes, angel numbers, zodiac signs, planetary placements, and synastry aspects. Plus 10 brand knowledge files covering writing style, metrics, platform strategy, and project details.
Spellcast uses this as the first choice for all content generation, falling back to DeepInfra if the local API is unavailable:
// spellcast/apps/api/src/lib/deepinfra.ts
async function tryBrandApi(messages: ChatMessage[]): Promise {
const health = await fetch(`${BRAND_API_URL}/health`, {
signal: AbortSignal.timeout(1000),
});
if (!health.ok) return null;
const res = await fetch(`${BRAND_API_URL}/v1/chat/completions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ model: 'sammii-brand', messages, temperature: 0.7 }),
});
// ... parse response
}
Free, local, brand-aware, and grimoire-grounded. The fallback to DeepInfra (meta-llama/Llama-4-Scout-17B-16E-Instruct) only kicks in when the local model is unavailable.
Layer 4: cross-account boost rules
When my personal account (@sammiihk) posts, my brand account (@LunaryApp) automatically likes and comments within 3-15 minutes. And vice versa. The comments aren't generic "great post!" rubbish; they're generated with the brand voice of the commenting account:
// spellcast/apps/api/src/lib/boost-queue.ts
async function generateBoostComment(rule, post, boosterAccountId) {
// Load brand voice for the booster account
const voice = await getBrandVoiceProfile(userId, boosterAccountSetId);
const systemPrompt = `You are commenting as ${boosterAccount.name}.
${voiceProfileToPrompt(voice)}
Write a genuine 1-2 sentence comment that references specific content.
Never write generic comments like "Love this!" or "Great post!"`;
return generateText([
{ role: 'system', content: systemPrompt },
{ role: 'user', content: `Comment on: "${post.content}"` },
]);
}
The boost cron runs every 2 minutes, finds pending actions, resolves the platform-specific post ID, and executes through Postiz's engagement API. Each action has a random delay within the configured window so it doesn't look automated.
Layer 5: autonomous pipelines
Content Creator: AI video pipeline with ML scoring
The Content Creator generates TikTok videos and Instagram carousels from persona blueprints:
// content-creator/src/lib/pipeline/content-planner.ts
async function createGenerationPlans(personaId, config) {
// 1. Load persona blueprint -> extract content_pillars
// 2. Count existing items this week
// 3. Calculate needed = max(0, postsPerWeek - existingCount)
// 4. Rotate through pillars (unused first, then least recently used)
// 5. Mix in trending topics (probability = config.trendInfluence)
// 6. Return GenerationPlan[] with pillar, contentType, theme, trendTags
}
Each generated video gets scored by an ML model before approval:
// content-creator/src/lib/ml.ts
modelWeights = {
hookStrength: 0.20, // Strongest signal
motionLevel: 0.18,
avgBrightness: 0.15,
avgContrast: 0.12,
colorVariance: 0.10,
textCoverage: 0.08,
duration: 0.07,
contentLength: 0.05,
toneScore: 0.05
}
The pipeline runs twice a week (Thursday and Sunday at 2AM), generates 3-4 items per persona, and auto-schedules approved content to Spellcast with cadence-aware timing.
Prism: fully autonomous component pipeline
Prism is my newest pipeline. It builds UI components daily with zero input:
# prism/pipeline/orchestrator.sh auto
# Runs: scout → curator → builder → recorder → publisher
# Scout (Claude Haiku + Chrome MCP)
# Browses X for trending UI interactions and component patterns
# Curator (Claude Sonnet)
# Picks today's component, writes detailed build brief
# Builder (Claude Sonnet)
# Builds the component, demo, registry entry, verifies build passes
# Recorder (Playwright)
# Records 12-second 1080x1080 video with organic cursor movement
# Publisher (Claude Haiku)
# Uploads video + creates/scores/schedules tweet via Spellcast MCP
Each agent passes data to the next through state files in pipeline/state/queue/. The scout writes findings, the curator reads them and writes a brief, the builder reads the brief and writes code, the recorder captures it, and the publisher posts it.
Daily metrics cron
A shell script runs at 07:00 every morning, pulls fresh data from Lunary's admin API, and writes it to the shared memory layer:
# ~/.claude/scripts/daily-metrics-snapshot.sh
# Endpoints queried:
# /api/admin/analytics/dashboard?time_range=30d (DAU, WAU, MAU)
# /api/admin/analytics/revenue?time_range=30d (MRR, Pro subs)
# /api/admin/analytics/dau-wau-mau?time_range=7d (engagement)
#
# Output: memory/live-metrics.md
# Preserves SEO section from previous /seo Chrome scrape
This means when I ask any Claude agent "how's Lunary doing?", it reads live-metrics.md and gives me real numbers, not hardcoded guesses from the instructions file.
How it all connects
Here's a real workflow that touches most of the system:
- I tell a Claude agent "publish my latest article about transit calculations"
- Agent reads
active-work.mdto check nothing conflicts - Agent calls Spellcast MCP
create_and_publish_articlewith Dev.to + Hashnode targets - Spellcast's API auto-generates an X thread (via Brand API for voice-consistent content)
- Spellcast auto-generates a LinkedIn companion post (scheduled for next Tue/Wed/Thu 17:30)
- Blog MCP publishes to the personal blog
- When the X thread goes live, boost rules trigger: @LunaryApp auto-likes and comments within 3-15 minutes
- Agent updates
active-work.mdandprojects/spellcast.mdwith what it just did - Next morning, the metrics cron updates
live-metrics.mdwith any traffic spike - Tomorrow's Build in Public post references real numbers from that file
One command. Eight platforms. Boost engagement. Metrics tracked. All coordinated through shared memory so the next agent knows exactly what happened.
The numbers
- 5 MCP servers registered, always available to every agent
- 260+ tools across Spellcast (140), Lunary (100+), Photos (22), Blog (6)
- 16 shared memory files for cross-agent coordination
- 40+ data sources loaded by the Brand API based on query relevance
- 10 projects connected through the same infrastructure
- 2 autonomous pipelines (Content Creator + Prism) generating and publishing daily
The total cost of running this locally: electricity for Ollama. The Brand API is free. The memory layer is free. MCP servers are free. Spellcast and the Content Creator run on my own infrastructure. The only paid API calls are DeepInfra fallbacks and Remotion rendering.
What's next in this series
This article is the overview. In the next parts, I'll deep-dive into each layer with full code walkthroughs:
- Part 2: The context layer - how shared markdown files give AI agents session continuity and multi-agent coordination
- Part 3: Automated content at scale - the Content Creator pipeline, persona system, ML scoring, and Spellcast scheduling
- Part 4: Building a local brand API - Ollama with smart context injection and grimoire knowledge
- Part 5: The autonomous pipeline - Prism's daily scout, curator, builder, publisher cycle
I'm Sammii, founder of Lunary and indie developer building tools I actually want to use. I write about shipping products solo, the technical decisions behind them, and figuring it all out in public.
Top comments (0)