iMessage Claude Bot

Built by @loganinthefuture with Claude Code

I text myself from my phone. Claude responds in the same thread. Not a chatbot — a full agent. It reads files, writes code, searches the web, understands images. It knows my projects, my preferences, my calendar. It's basically a chief of staff that lives in iMessage.

The trick: Every iMessage lives in a SQLite database on your Mac. This script watches that database, routes messages to Claude Code CLI, and sends responses back via AppleScript. No servers, no APIs, no monthly fees beyond your existing Claude subscription. Everything runs locally.
Real conversations (names changed)
This is what it actually looks like. Not a mockup — these are anonymized from my real bot usage.
9:41 📶 🔋
‹  Messages
Me
Me
Saturday 5:00 PM
Add this to our discussion queue — "over the next 10 years you'll have a market of billions of customers (agents) with wallets that want to use your services. every single SaaS category gets rebuilt for agents. we're entering the machine-to-machine economy and almost nobody is building for it yet"
Done. Created the discussion queue and dropped it in as item #1.

Flagged some connections to your existing threads — this maps hard onto your agent economy and context engineering research. If agents are the new customer, then the individual's agent becomes their purchasing department. That's basically your newsletter thesis from the other direction.

Want to riff on this now or save it for your weekly group?
Save it
Saved. It's in the queue for whenever you're ready to dig in.
Saturday 5:18 PM
📸
LinkedIn screenshot
Log this company / this person as someone to track
Logged. Here's what I captured:

Lumina Learning — AI edtech startup, backed by a celebrity founder. Personalized K-12 learning with AI. Hiring across Product, Sales, Eng.

Tariq A. — Growth & Partnerships, ex-Meta, ex-McKinsey (education focus). 2nd connection on LinkedIn.

This is squarely in your lane — learning design background + curriculum work + AI. With your contract ending in a few weeks, could be worth a conversation. Want me to draft a LinkedIn outreach?
Nah just keep them in mind for the future in the AI K-12 space
Got it. They're in the tracker — I'll surface them if anything comes up in that space, or if you need connections there after your contract wraps.
Saturday 6:02 PM
What were the 3 companies from that YC batch that are doing anything in career infrastructure?
From W26, three are relevant:

1. Meridian — skills-based hiring marketplace, bypasses resumes entirely. $2.3M pre-seed.

2. Pathfind — AI career coach for mid-career professionals. Internal transfer focus.

3. WorkGraph — portable career data layer. Employees own their work history as structured data.

WorkGraph is the closest to your thesis about career IP and portable equity. Want me to dig deeper on any of these?
Save WorkGraph to the tracker. That's the one.
Done. Added to your companies tracker with tags: career-infrastructure, portable-data, thesis-aligned. I'll flag any news about them.
Delivered
+
iMessage
What you're looking at: I text myself from my phone. My Mac picks up the message, routes it to Claude Code (which has access to my files, my project context, my memory system), and sends the response back in the same iMessage thread. Claude remembers everything across conversations. It connects dots I wouldn't have connected. And the whole thing runs on a ~150 line Python script.
💬
Native iMessage
No new apps to install
🖼️
Send images
Screenshots, photos, docs
🧠
Persistent memory
Knows your projects & prefs
🔧
Full agent
Files, code, web, terminal

Setup

About 10 minutes. You need a Mac, Python 3 (ships with macOS), and Claude Code CLI installed.

1
Grant Full Disk Access to Python

The bot reads your Messages database, which macOS protects. Open System Settings → Privacy & Security → Full Disk Access, click +, press Cmd+Shift+G, type /usr/bin/python3, and add it.

This is the one step that trips people up. If you skip it, everything else will look right but the bot will silently fail to read your messages.

2
Clone and configure
git clone https://github.com/loganhc-09/imessage-claude-bot.git
cd imessage-claude-bot
cp .env.example .env

Edit .env with your details:

APPLE_ID=you@icloud.com
PHONE_NUMBER=+15551234567
CLAUDE_WORKSPACE=/path/to/your/project
CLAUDE_PATH=/usr/local/bin/claude

The CLAUDE_WORKSPACE is where Claude Code operates from — wherever your CLAUDE.md lives. This is how the bot knows your context.

3
Create your self-chat

Open Messages on your phone and text yourself. Just send anything — "hey" works. This creates the iMessage thread the bot monitors. You only need to do this once.

4
Run
python3 imessage-bot.py

Text yourself from your phone. Wait a few seconds. Claude responds in the same thread. That's it.

Keep it running forever

The repo includes a launchd plist so the bot runs in the background and survives restarts:

# Edit the plist with your paths first
cp com.claude.imessage-bot.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.claude.imessage-bot.plist

# Check logs
tail -f /tmp/imessage-bot.log

Commands

/new
Fresh Claude session (new context)
/status
Check if the bot's alive

Gotchas we hit so you don't have to

Every single one of these cost me at least an hour. The bot handles all of them automatically, but if something's not working, check here first.

Two self-chats (yes, really)

iMessage creates separate threads for your email and phone number. You'll text from one, the bot will reply to the other, and you'll think it's broken. That's why .env has both APPLE_ID and PHONE_NUMBER — the bot monitors both and replies to whichever you texted from.

Full Disk Access vanishes after restart

When launchd restarts Python, FDA can take a few seconds to activate. The bot retries automatically for up to 2.5 minutes. If you see "authorization denied" in the error log, give it a minute — it usually resolves itself.

The invisible message problem

Messages sent via AppleScript store text in a binary blob (NSAttributedString typedstream) instead of the normal text column. Most tutorials don't mention this. The bot includes a custom parser for Apple's undocumented binary format. If messages seem to disappear, this is why.

Images need special handling

Images live in ~/Library/Messages/Attachments/ which requires FDA. Your Python process has FDA, but Claude CLI subprocess doesn't. So the bot copies images to /tmp/ before passing paths to Claude. This happens automatically — you just send a photo and Claude sees it.

iCloud sync isn't instant

Messages from your phone sync to your Mac via iCloud — usually within seconds, sometimes 30-60+. If the bot doesn't respond, make sure Messages.app on your Mac is open. That helps.

Infinite loop territory

You're texting yourself, so the bot's own replies appear as new messages. Without protection, it processes its own responses forever. We prevent this with MD5 hash tracking and ROWID advancement. It's handled, but it's the kind of thing that makes you question your life choices at 2am when you're debugging it.

Under the hood

1
Poll — Reads ~/Library/Messages/chat.db every 3 seconds for new messages in your self-chat threads
2
Extract — Pulls text from either the text column or the attributedBody binary blob (Apple's undocumented typedstream format)
3
Stage — Copies any image attachments from the protected Messages directory to /tmp/ where Claude can read them
4
Process — Sends the message to Claude Code CLI with session persistence via --resume, so context carries across texts
5
Reply — Sends Claude's response back via AppleScript to the same thread you texted from
6
Advance — Skips past its own reply in the database to prevent the infinite loop

No network APIs. No third-party services. ~150 lines of Python. Everything runs on your Mac.

The real power move

Give Claude a CLAUDE.md

This is where it stops being a chatbot and starts being yours. Create a CLAUDE.md in your workspace with your context — who you are, what you're working on, how you think, what you care about. The bot loads this on every new session. Mine has my projects, my intellectual threads, my cognitive patterns, even my energy cycles. Claude uses all of it.

Build a memory system

Set LOG_DIR in .env to save daily conversation logs. But the real move is giving Claude a memory/ folder it can read and write to. Mine tracks people, companies, discussion queues, meeting notes, follow-ups. It remembers so I don't have to.

Chief of staff mode

With a good CLAUDE.md and a memory system, Claude stops being reactive and starts being proactive. Morning briefings. Meeting prep. Follow-up tracking. Research on demand. The interface is just texting — but what's behind it is a full operating system that knows your work.