DEV Community

~K¹yle Million
~K¹yle Million

Posted on

Building a Revenue-Generating Agent from Scratch with Claude Code

I needed to make money while I wasn't watching my computer.

Not passive income in the vague "build once, earn forever" sense. I mean: while I was dealing with family obligations in rural Missouri, the system had to identify opportunities, create content, update product listings, monitor funnels, and report what happened — without me touching it.

I built that system with Claude Code. This is how it works and what I learned doing it.


The Core Insight: Claude Code Is Infrastructure, Not a Tool

Most people use Claude Code like a better code editor. They open it, type a prompt, review the result, close it.

That's leaving most of its value on the table.

Claude Code has native capabilities that, when assembled correctly, form an autonomous operating loop:

  • Headless execution (claude -p "prompt") — runs a full task without a human in the loop
  • Auto-memory extraction — persists learning across sessions automatically
  • Task queue — manages async work within an active session
  • Multi-agent — parallel Claude Code instances in tmux panes
  • CLAUDE.md — persistent system prompt that survives every invocation

The pattern is: system crontab calls claude -p "task". Claude reads CLAUDE.md, executes the task, writes output, exits. No human involved.

This is the foundation everything else builds on.


Step 1: CLAUDE.md as the Operating System

Before writing any code, I wrote CLAUDE.md — a file that lives at the root of the project directory and is automatically read by Claude Code at every invocation.

CLAUDE.md is not a readme. It is the agent's operating system.

Mine contains:

Identity — who the agent is, what it's optimizing for, what it's not allowed to do without approval. The goal is stated explicitly: autonomous revenue generation.

Approval boundary — a precise list of what the agent can do without asking:

Self-authorized:
- All filesystem operations within ~/intuitek/
- API calls: Anthropic, ClawMart, Supabase, Stripe (read), Google Calendar
- Telegram notifications
- Ollama local inference
- Cron registration (idempotent adds only)

Kyle's approval required:
- Production deploys of new services
- Credential rotation
- Stripe charges or product changes
- Irreversible operations
Enter fullscreen mode Exit fullscreen mode

This boundary is what makes the agent safe to run autonomously. It has a clear blast radius. It knows what it can decide and what it needs to escalate.

System inventory — every active system: the ACE license server, ClawMart listings, dev.to credentials, Supabase LTM, Google Calendar, Telegram. The agent can't operate what it doesn't know about.

Standing mission — what to do when no inbox tasks are queued: evaluate the goal, identify the highest-leverage available action, execute it, document it.

The first time you write a thorough CLAUDE.md, you realize how much of what you normally think is "managing a project" is actually just answering the same questions repeatedly. CLAUDE.md answers them once.


Step 2: The Inbox Pattern

My agent runs on a 10-minute heartbeat via system crontab:

*/10 7-23 * * * bash ~/intuitek/run_task.sh "Check ~/intuitek/inbox/ for task files. Read each one, execute the TASK: directive, write result to ~/intuitek/outputs/, archive to ~/intuitek/logs/processed/."
Enter fullscreen mode Exit fullscreen mode

run_task.sh is a thin wrapper that:

  1. Sources .env (all credentials)
  2. Sets PATH correctly ($HOME/.local/bin for the claude binary)
  3. Runs claude -p "prompt" --allowedTools "Bash(*),Read(*),Write(*)"
  4. Logs exit code and timestamps

Any process can drop a file into ~/intuitek/inbox/ and the agent will pick it up within 10 minutes. This creates a clean interface between my two agent instances without requiring them to be running simultaneously.

Task file format:

TASK: [directive — treated as the actual instruction]
PRIORITY: high / normal / low
FROM: openclaw-aegis / kyle
CONTEXT: [what the sender knows]
EXPECTED_OUTPUT: [where to write the result]
Enter fullscreen mode Exit fullscreen mode

The TASK: line is what Claude Code executes. Everything else is context.


Step 3: Revenue Infrastructure

Before the agent can generate revenue, you need something to sell and a way to deliver it.

My stack:

ClawMart listings — packaged AI agent skills, priced $19–$199. These are distilled expertise: tested prompts, CLAUDE.md patterns, system architectures that save hours of debugging. The agent can update listing content autonomously.

ACE license server — FastAPI on Railway. When a customer pays via Stripe, the webhook hits ACE, which provisions a Fernet-encrypted license key and sends it via Resend email. The entire flow is automated — Stripe → webhook → license → email → confirmation page. No human touches it.

Stripe payment links — embedded directly into product listings. One click from product page to checkout to delivery.

The key principle: the delivery mechanism must be zero-touch. If you have to manually fulfill anything, you don't have an autonomous revenue system — you have a lead generation system with a manual bottleneck.


Step 4: Distribution as an Autonomous Task

Traffic doesn't appear because you built something. The agent has to generate it.

My current distribution loop:

  1. Article research — reads what's trending, what questions appear repeatedly, what knowledge gaps exist
  2. Article writing — synthesizes what it knows from building the actual system into 1500–2500 word technical pieces
  3. dev.to publishing — posts via API with correct tags (claudecode, devtools, aiagents)
  4. Reddit posting — posts full article inline (no external links in body — new accounts get spam-filtered otherwise), then drops the dev.to URL as first comment

One thing I learned: spam filters on Reddit are aggressive for new accounts. External links in the post body get silently removed. The workaround: post the full content inline, comment the link immediately after. The filter passes the post; readers find the source link in comments.


Step 5: The Coordination Layer

Running two agent instances — one persistent, one headless — requires a coordination protocol or they collide.

My approach: shared directories + lock files.

~/intuitek/coordination/
├── for_openclaw/        ← Claude Code writes tasks here
├── for_claude_code/     ← OpenClaw writes tasks here
├── in_progress/         ← Lock files go here
└── CURRENT_STATE.md     ← Active snapshot
Enter fullscreen mode Exit fullscreen mode

Before any autonomous action on a shared resource, the agent writes a lock file:

touch ~/intuitek/coordination/in_progress/reddit-post-$(date +%s).lock
Enter fullscreen mode Exit fullscreen mode

Checks for existing locks before posting. Cleans up on completion.

Without this, two instances running at the same time will duplicate work. I had one race condition where both instances posted the same article to Reddit simultaneously. The lock protocol prevents that.


Step 6: Observable Outcomes

Autonomous systems fail silently if you let them. I built explicit observability:

Telegram notifications — every headless execution sends a structured notification:

bash ~/intuitek/notify.sh "📥 [Claude Code] Starting: [task]"
bash ~/intuitek/notify.sh "✅ [Claude Code] Done: [task] → outputs/[file]"
bash ~/intuitek/notify.sh "⚠️ [Claude Code] Error: [what failed]"
Enter fullscreen mode Exit fullscreen mode

These go to my phone. I don't watch the agent work — I read what it produced.

outputs/ directory — every task produces a file with a descriptive name. Weekly ClawMart reports, article drafts, error analyses, session summaries. The directory is the audit trail.

logs/errors.log — every failure logged with timestamp, task, and reason. Silent failure is the main risk in autonomous systems. This file being quiet is a positive signal.

SHARED_MIND.md — a file both instances read and write, updated after every significant action. Operational state, what's in motion, what's been learned. Two agents maintaining one shared picture of the world.


What I'd Do Differently

Write CLAUDE.md first. Every hour spent clarifying the approval boundary up front saves three hours of recovering from an agent that made a decision you didn't authorize.

Mock the full headless loop before connecting live credentials. The headless execution path (claude -p) behaves differently than interactive. Test with safe prompts before giving it Stripe and Railway access.

Explicit observability from day one. The temptation is to skip Telegram notifications because they feel like overhead. Don't. Without them, you have no idea what the agent actually did between sessions.

Tier 0 for everything that doesn't need API quality. Run Ollama locally for classification and routing tasks. Zero API cost. Only escalate to Haiku or Sonnet when the task genuinely requires it.


The Honest Current State

The purchase flow is fully live. Stripe → license server → Resend email. No manual steps.

The distribution funnel is running. Articles on dev.to, posts on Reddit, product listings live.

MRR: $0. The funnel is built; traffic converts it.

The next phase is increasing distribution velocity — more articles, more channels, faster iteration on what's working — entirely autonomous.

Building the infrastructure takes most of the time. Operating it takes almost none. That's the point.


~K¹ (W. Kyle Million) / IntuiTek¹

Top comments (0)