Files
xBot/CLAUDE.md
Matthew Jackson dacc7604cc Migrate to Docker: containerize for docker-server deployment
- Add Dockerfile + cron.js (daily 4pm UTC loop replacing EC2 cron)
- Add infra/docker-compose.yml and deploy-stack.sh for Portainer
- Support DATA_DIR env var in bot.js for persistent history volume
- Support PROMPTS_JSON env var in cron.js (no SSH needed for config)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 17:15:18 -07:00

2.3 KiB

xBot

AI-powered Twitter/X bot that generates tweets via the Anthropic Claude API and posts them using stealth browser automation through Kernel.sh (residential proxies + CAPTCHA solving).

Key Features

  • AI tweet generation (claude-sonnet-4-6, max 280 tokens)
  • Multi-account support (credentials keyed by account name in .env)
  • Configurable scheduling (daily or random interval posting)
  • Tweet history tracking to avoid repetition
  • Link injection (URLs added post-generation, never sent to AI)
  • Anti-detection: keyboard.type() with delays, adaptive login flow

Tech Stack

Node.js 18+ (ES modules), @onkernel/sdk, dotenv

Project Structure

  • bot.js — Core logic: login to X, generate tweet via Claude, post it
  • scheduler.js — Picks random times within a window, invokes bot.js via child_process
  • package.json — Dependencies & scripts
  • .env — Credentials (not tracked)
  • prompts.json — Prompt configs with account mapping, schedule, and link placeholders (not tracked)
  • history-<prompt-name>.json — Per-prompt tweet history (auto-generated)

Entry Points

  • node bot.js <prompt-name> — Post a single tweet immediately
  • node scheduler.js <prompt-name> — Schedule random posts for the day

External Services

Service Purpose Config Key
Kernel.sh Stealth browser automation (residential proxies, CAPTCHA solving, Playwright) KERNEL env var
Anthropic Claude API Tweet generation ANTHROPIC env var
X/Twitter Target platform for posting Per-account: {PREFIX}_USER, {PREFIX}_PW, {PREFIX}_EMAIL, {PREFIX}_PHONE

Multi-account credentials use uppercase prefix pattern in .env (e.g., MYACCOUNT_USER, MYACCOUNT_PW).

Deployment

Deployed on AWS EC2 in us-west-2:

  • Instance: i-088b711cac69e6ac9
  • Name: xbot
  • Type: t4g.nano (ARM-based)
  • Public IP: 44.249.48.3
  • AWS account: 457667483187
  • Cron: 0 16 * * * (4pm UTC / before 8am PST window), one job per prompt

Guidelines

  • All changes must preserve stealth/anti-detection behavior and multi-account architecture
  • bot.js is the core; scheduler.js orchestrates timing
  • Config lives in .env + prompts.json
  • All project memory/context stays in this file (or a CLAUDE-memory/ folder in the repo) — never save to the external ~/.claude/projects/.../memory/ system