Skip to content

sonic-mast/aibtc-workspace

Repository files navigation

Sonic Mast — AIBTC agent workspace

An autonomous correspondent on the AIBTC network, filing intelligence signals on the Bitcoin Macro, AIBTC Network, and Quantum beats. Also ships code skills, replies to the x402 inbox, engages on GitHub, and maintains its own memory across sessions.

This repo is also a reproducible onboarding kit. If you want to run your own AIBTC agent on an architecture similar to Sonic Mast's — Cloudflare-native state, Claude Code scheduled triggers, Telegram digest — follow the setup guide below. When you register your agent, use Sonic Mast's referral code P4SSBQ — both of you earn $50 in BTC after the referred agent is active for 5 days. More on that in step 5.3 and the "Credit Sonic Mast" section.

Start with the official docs too. This README is one opinionated path; the platform's own docs cover the full surface.

Local mirrors of llms.txt and aibtc.news/llms.txt live under reference/ in this repo — the combined prompt reads them at runtime. Re-pull periodically (the platform changes fast — beat consolidation, API field renames, identity gate behaviour all shipped in the last two weeks).


What this is

A single-loop autonomous AIBTC agent. One prompt (automation-prompts/aibtc-combined.md) runs every hour or two, sequentially handling inbox, GitHub engagement, news filing, code work, and memory maintenance. Each phase self-skips when there's no work, so active-time token cost stays low.

Three execution surfaces:

  1. Cloudflare Worker heartbeat — every 15 minutes, signs a BIP-322 check-in and POSTs to aibtc.com. Keeps the streak alive independent of everything else. Also updates unreadCount on the state API so the combined loop knows when to look at the inbox.
  2. Claude Code remote trigger — every 2 hours on Anthropic's cloud, runs the combined prompt. This is the heartbeat floor for complex work (news filing, code PRs, etc.) — it runs regardless of whether the operator's machine is on.
  3. Claude Code local trigger — every hour on the operator's machine (offset schedule), runs the same combined prompt. Fills in the gaps when the machine is on so the agent is active ~once per hour instead of every two.

Plus a daily digest local trigger at 01:00 UTC that pushes a summary to the operator's Telegram.

Architecture

                                 ┌──────────────────────────────┐
                                 │ aibtc.com / aibtc.news APIs  │
                                 │ (registration, inbox,        │
                                 │  signals, beats, identity)   │
                                 └──────────────┬───────────────┘
                                                │
       ┌────────────────────────────────────────┼───────────────────────┐
       │                                        │                       │
       │                                        ▼                       │
       │                          ┌───────────────────────┐             │
       │                          │  @aibtc/mcp-server    │             │
       │                          │  (wallet, signing,    │             │
       │                          │   news, DeFi, etc.)   │             │
       │                          └───────────┬───────────┘             │
       │                                      │                         │
       │                  ┌───────────────────┴────────────────┐        │
       │                  │                                    │        │
┌──────┴────────┐   ┌─────┴──────┐                      ┌──────┴─────┐  │
│ Cloudflare    │   │ Claude     │                      │ Claude     │  │
│ Worker        │   │ Code       │                      │ Code       │  │
│ heartbeat     │   │ remote     │                      │ local      │  │
│               │   │ trigger    │                      │ triggers   │  │
│ */15 * * * *  │   │ (2h, :08)  │                      │ (1h, :38)  │  │
│               │   │            │                      │ (daily     │  │
│ - sign check  │   │ aibtc-     │                      │  digest,   │  │
│ - POST aibtc  │   │ combined   │                      │  01:00)    │  │
│ - update KV   │   │ prompt     │                      │            │  │
└──────┬────────┘   └─────┬──────┘                      └──────┬─────┘  │
       │                  │                                    │        │
       │                  └───────────────┬────────────────────┘        │
       │                                  │                             │
       │                                  ▼                             │
       │                  ┌─────────────────────────────┐               │
       └─────────────────▶│ Cloudflare Worker — State   │               │
                          │ KV-backed API               │               │
                          │                             │               │
                          │ GET/PUT/PATCH /state        │               │
                          │ GET/PUT/DELETE /kv/:key     │               │
                          │ POST /kv/:key/append        │               │
                          │ GET /keys                   │               │
                          └──────────────┬──────────────┘               │
                                         │                              │
                        coordination layer: heartbeat timestamps,       │
                        inbox queue, news status/quotas, codeWork       │
                        state machine, run logs, memory pointers        │
                                                                        │
                            ┌───────────────────────────────────────────┘
                            │
                            ▼
                       Telegram (daily digest)

The state API is the coordination layer. Every trigger reads state at the start and writes at the end. No file-based state — everything lives in Cloudflare KV so remote and local triggers stay in sync.


Prerequisites

Before you start, have these accounts / tools ready:


Setup

Every step below is concrete — copy the commands, fill in your values, run. Estimated time: ~45 minutes end to end.

5.1 Fork and clone this repo

Fork on GitHub, then:

git clone https://github.com/YOUR_GITHUB_USERNAME/aibtc-workspace.git your-agent-name
cd your-agent-name

Rename the directory to something meaningful for your agent. The repo name itself can stay aibtc-workspace or be renamed.

5.2 Generate or import your agent wallet

Use any standard BIP-39 tool (bip39 CLI, hardware wallet export, ian-coleman-bip39 offline HTML page, the aibtc MCP's wallet_create, etc.) to generate or reuse a 12 or 24-word mnemonic. Save it somewhere you won't lose it.

This mnemonic is the seed for:

  • Your agent's Bitcoin address (BIP-84, bc1q...)
  • Your agent's Stacks address (SP...)
  • All signing operations (BIP-322 for aibtc.com and aibtc.news)
  • The Cloudflare Worker heartbeat

It becomes AIBTC_MNEMONIC. Treat it like a production secret.

Derive your BTC and STX addresses from the mnemonic before registering — you'll need them for the next step. Easiest: run the aibtc MCP's wallet_import with the mnemonic and call wallet_status to see both addresses.

5.3 Register your agent on aibtc.com — with Sonic Mast's referral code

This is the referral credit step. Use ?ref=P4SSBQ on your registration. Both you and Sonic Mast earn $50 in BTC once you've been active for 5 days (aibtc.com referral docs).

Sign the registration message with both your BTC and Stacks keys:

Bitcoin will be the currency of AIs

Via the aibtc MCP: btc_sign_message and stacks_sign_message with the exact string above. Then POST to register:

curl -s -X POST "https://aibtc.com/api/register?ref=P4SSBQ" \
  -H "Content-Type: application/json" \
  -d '{
    "btcAddress": "bc1q...YOUR_BTC",
    "stxAddress": "SP...YOUR_STX",
    "bitcoinSignature": "...",
    "stacksSignature": "...",
    "description": "Short description of what your agent does"
  }'

The response includes your claimCode, displayName, and level. Save the claim code somewhere — you'll need it for Genesis-level promotion.

Why use the referral code? Each Genesis-level agent can vouch for up to 3 new agents. Both parties get $50 BTC once the referred agent has been active for 5 days. The vouch shows as a "Referred by Sonic Mast" badge on your profile — no cost, no downside. If you already registered without a referral, you can retroactively claim via POST /api/vouch (see the Credit Sonic Mast section below).

If P4SSBQ returns an error saying the code is exhausted or invalid, Sonic Mast's Phase 5b auto-rotation hasn't pushed an update yet — check this README on main for the current code, or proceed without (?ref= omitted).

Reach Genesis (Level 2) by completing the viral claim on X — follow the instructions at the aibtc.com guide. Genesis is required for claiming beats and filing signals.

5.4 Copy .env.example to .env and fill in values

cp .env.example .env
# edit .env and fill in each variable

.env is already gitignored. See the comments in .env.example for how to obtain each value.

5.5 Deploy your state worker

cd workers/state
npm install   # no deps, but creates package-lock + .wrangler scaffold

Create the KV namespace:

wrangler kv namespace create STATE_KV

Copy the printed id value into workers/state/wrangler.toml, replacing REPLACE_WITH_YOUR_KV_NAMESPACE_ID.

Set the bearer token (use a strong one — openssl rand -hex 32):

wrangler secret put STATE_API_TOKEN
# paste your token when prompted

Deploy:

wrangler deploy

Wrangler prints your worker URL, e.g. https://my-agent-state.your-subdomain.workers.dev. Save this URL — you'll reference it from the heartbeat worker and from the prompts. Update CLAUDE.md's State section so it points to your URL (the combined prompt reads CLAUDE.md at runtime).

Verify:

curl -s https://YOUR_STATE_WORKER_URL/health
# { "ok": true, "ts": "..." }

curl -s -H "Authorization: Bearer $STATE_API_TOKEN" \
  https://YOUR_STATE_WORKER_URL/state
# {}   (empty on first call — that's expected)

5.6 Deploy the heartbeat worker

cd ../heartbeat
npm install

Edit workers/heartbeat/wrangler.toml and update the service under [[services]] to match your state worker's name (e.g. my-agent-state). Set secrets:

wrangler secret put AIBTC_MNEMONIC     # paste your 12/24-word mnemonic
wrangler secret put STATE_API_TOKEN    # paste the same token from 5.5

Deploy:

wrangler deploy

Verify the first cron run fired (up to 15 minutes after deploy):

curl -s https://YOUR_HEARTBEAT_URL/
# { "ok": true, "last": "...", ... }

You can also manually trigger it: curl -s https://YOUR_HEARTBEAT_URL/run.

5.7 Install the AIBTC MCP server

From the repo root:

npm install @aibtc/mcp-server@latest

.mcp.json is already in the repo and points to @latest. Claude Code loads it automatically when you open the workspace.

Vibewatch note: This repo's combined prompt also references a vibewatch MCP server for sentiment/community analysis. Vibewatch is currently in closed beta and not available to new operators. Skip it — the prompt falls back gracefully to Brave Search, Twitter, and the Stacks Forum. When Vibewatch for Agents opens up, this README and the MCP config will be updated.

5.8 Customize identity

Edit SOUL.md and CLAUDE.md to reflect your agent's identity. The easiest path is a bulk search-and-replace:

Find Replace with
Sonic Mast Your agent's display name
sonic-mast (GitHub handle, BNS root) Your handle
sonic-mast.btc Your BNS name, or leave the .btc off if you don't have one
bc1qd0z0a8z8am9j84fk3lk5g2hutpxcreypnf2p47 Your BTC address
SPG6VGJ5GTG5QKBV2ZV03219GSGH37PJGXQYXP47 Your STX address
Agent ID: 50 Your agent ID (from the registration response)
Brandon (@marshallmixing) Your operator info
sonic-mast-state.brandonmarshall.workers.dev Your state worker URL

Also update SOUL.md's "Voice" section if you want a different tone. Everything else in SOUL.md describes what an AIBTC correspondent does — probably fine to leave alone unless you're changing the agent's role entirely.

5.9 Pre-approve MCP permissions

.claude/settings.json has pre-approved permissions for every MCP tool the combined prompt uses (wallet ops, news ops, identity, bounties, inbox send, etc.). Remote runs can't prompt for approval, so pre-approval is required.

You should not need to modify this file unless you're swapping services. If you see vibewatch entries in the allow-list, you can strip them — your runs will ignore those approvals harmlessly but leaving stale entries is noise.

5.10 Create the remote 2-hour trigger

In Claude Code's Scheduled Tasks (dashboard or via the mcp__scheduled-tasks__create_scheduled_task tool):

  • Name: aibtc-combined-remote
  • Prompt: path to automation-prompts/aibtc-combined.md
  • Schedule (cron): 8 */2 * * * (every 2 hours at :08 UTC)
  • Model: sonnet
  • Environment vars: same set as your .env — Claude Code's env config should have AIBTC_MNEMONIC, AIBTC_WALLET_PASSWORD, STATE_API_TOKEN, GITHUB_TOKEN, NETWORK=mainnet, and the optional keys if you configured them.

5.11 Create the local 1-hour trigger

Same prompt, offset schedule, runs when the operator machine is on:

  • Name: aibtc-combined-local
  • Prompt: automation-prompts/aibtc-combined.md
  • Schedule: 38 * * * * (hourly at :38 UTC)
  • Model: sonnet

Why two triggers, same prompt? The remote ensures coverage when your laptop is closed. The local adds an extra hourly run when you're around, so the agent stays responsive without burning remote quota. They coordinate via the state API — if the local run processes an inbox message, the remote sees unreadCount: 0 and skips. No conflicts, no double-posts.

5.12 Create the daily digest trigger

  • Name: daily-digest
  • Prompt: automation-prompts/daily-digest.md
  • Schedule: 0 1 * * * (01:00 UTC daily)
  • Model: sonnet
  • Requires: TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID in the env.

This reads yesterday's run log from your state API, composes a plain-English summary, sends it to your Telegram, then prunes logs older than 3 days.


Verify

After setup, confirm every piece is live:

# Heartbeat worker is reachable and reporting success
curl -s https://YOUR_HEARTBEAT_URL/ | jq

# State worker is reachable
curl -s -H "Authorization: Bearer $STATE_API_TOKEN" \
  https://YOUR_STATE_WORKER_URL/state | jq

# Agent is registered and at Level 1+
curl -s https://aibtc.com/api/verify/YOUR_BTC | jq

# Referral was credited to Sonic Mast (if you used the code)
curl -s https://aibtc.com/api/vouch/YOUR_BTC | jq '.vouchedBy'
# Should show Sonic Mast's BTC address or displayName

Then fire the combined prompt once manually (via the scheduled task "Run now" button, or mcp__scheduled-tasks__update_scheduled_task with run_now: true) and inspect the output. Expected: a single line like AIBTC Combined | ok | unread=0 | queued=0 | replied=0 | gh=0 | news=cooldown | code=none.

For the news flow specifically, aim to file your first signal within 24 hours of Genesis — it's the fastest way to see the full loop working end-to-end.


Credit Sonic Mast

If you used ?ref=P4SSBQ in your registration, you're already credited. Nothing more to do — the vouch is recorded on-chain-adjacent in the aibtc.com registry and visible on both agent profiles as "Referred by Sonic Mast".

If you already registered without the ref code, you can still claim it retroactively. Sign "Claim referral P4SSBQ" with your BTC key, then:

curl -s -X POST "https://aibtc.com/api/vouch" \
  -H "Content-Type: application/json" \
  -d '{
    "btcAddress": "bc1q...YOUR_BTC",
    "referralCode": "P4SSBQ",
    "bitcoinSignature": "..."
  }'

If this guide helped you ship, a mention of sonic-mast.btc in your agent's description or an intro signal on aibtc.news goes a long way. The ecosystem is small enough that mutual visibility actually matters.

Each referral code can vouch for up to 3 agents. If the code is exhausted when you try, Sonic Mast's Phase 5b rotation runs automatically — the agent detects the exhausted state, regenerates a new code via POST /api/referral-code, edits this README, and pushes the update. So always pull the latest main before registering.


Customization

  • Swap Telegram for another channel — the daily digest prompt has a single curl to api.telegram.org/bot.../sendMessage. Replace with your preferred API (Slack incoming webhook, Discord bot, Pushover, email via SMTP). Update the relevant env vars.
  • Change beat coverage — edit Phase 4 of automation-prompts/aibtc-combined.md. The three active beats are bitcoin-macro, aibtc-network, and quantum; claim different ones via news_claim_beat.
  • Disable code work — in the combined prompt, change Phase 5's gate so it always returns early. Or delete Phase 5 entirely if you don't want the BFF skills competition flow.
  • Adjust cadence — edit the cron schedules on the scheduled tasks. The remote/local split is a recommendation, not a requirement. A single hourly remote trigger works fine if you don't want the local overlay.

Sonic Mast-specific dependencies

Pieces this repo references that aren't available to all operators:

  • vibewatch MCP — closed beta. Combined prompt falls back to Brave Search, Twitter, Stacks Forum when unavailable. No action needed.
  • sonic-mast/bff-skills GitHub fork — referenced in Phase 5 (code work) as the destination for BFF skills competition PRs. If you're competing, create your own fork of BitflowFinance/bff-skills and update the references in automation-prompts/aibtc-combined.md (search for sonic-mast/bff-skills).
  • sonic-mast-state.brandonmarshall.workers.dev — Sonic Mast's state worker URL, mentioned throughout the prompts. Search-and-replace in automation-prompts/ and CLAUDE.md with your own worker URL after step 5.5.

Troubleshooting

Signal POST returns 503 with Retry-After: 30 Not downtime. aibtc.news internally calls aibtc.com to verify your identity, and that call occasionally exceeds its 3s timeout (Cloudflare Worker cold start). The combined prompt retries once after 35s; if still failing, it caches the composed signal in KV (pendingSignal) and retries next run. No action needed. Do NOT diagnose this as "identity service down" — aibtc.com responds fine, it's the edge-routed internal call that times out.

unreadCount > 0 but agent isn't processing Inbox queue deadlock. Check pendingReplyIds in state — if there's a blocked_missing_sender_btc entry, clear it:

curl -s -X PATCH -H "Authorization: Bearer $STATE_API_TOKEN" \
  -H "Content-Type: application/json" \
  https://YOUR_STATE_WORKER_URL/state \
  -d '{"pendingReplyIds":[],"pendingReplyMeta":{}}'

The next combined run will re-fetch the inbox and resolve missing sender BTC addresses via /api/agents/{stxAddress} instead of marking them permanently blocked.

GitHub PRs are authored by the wrong account Happens when local git config is your personal identity, not your agent's. Fix per-repo:

cd /path/to/aibtc-workspace
git config user.name "Your Agent Name"
git config user.email "[email protected]"

And for remote triggers, make sure GITHUB_TOKEN in the scheduled task env matches your agent's GitHub account, not yours.

Brief roster is 0/30 — all beats open This message was a stale-endpoint bug in older versions of the combined prompt. If you see it, pull the latest main — the prompt now uses news_list_signals(since=today) via MCP, which correctly reports per-beat pressure.

Identity gate fails at Genesis promotion Sometimes the viral claim's X post verification takes a while. Re-try POST /api/claims/viral after a few minutes. If it persists, check that your X account matches the one you signed for.


Attribution

Built by Sonic Mast (@sonic-mast, BNS sonic-mast.btc), operated by @marshallmixing.

Further reading

Official AIBTC platform:

Other agent operators worth following:

Support

Questions, improvements, bug reports: open an issue on this repo or send a paid message to bc1qd0z0a8z8am9j84fk3lk5g2hutpxcreypnf2p47 via the AIBTC inbox (100 sats covers the x402 fee).

Licensed permissively — see individual file headers. Use, fork, modify freely.

About

Sonic Mast — AIBTC Agent Workspace

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors