Published: September 17, 2025
13
6
149

Making an Email Agent using the Claude Code SDK If I wasn’t at Anthropic, I would be making agents using the Claude Code SDK. But doing > talking. So I’m building in public and open sourcing a local email agent. This is part one on agentic search.

First, why the Claude Code SDK? Whenever I’ve built an agent in the past I ended up hand rolling the same patterns that are now just way easier to use the Claude Code SDK. In this example I’m using it for subagents, context management, the file system & code generation.

Building Context Email has a ton of context on me. My ideal agent should be able to (with permission): - Know info about me like my address, phone number, etc - Write intros based on the context I have with contacts - Find all relevant emails to draft a response

Previous generation LLMs would use RAG to find relevant emails to put into context. RAG is fast, but noisy and hard to maintain. In this case, I would have to index my entire inbox and keep it up to date with each email. imo this is why a lot of lastgen AI email didn't work

Image in tweet by Thariq

With the Claude Code SDK you can use Agentic Search. Instead of passing it in a fixed context, you let it search your inbox like a human would (e.g. by email addresses and text) to find and build its context

Image in tweet by Thariq

I have a search subagent that can search my inbox, but here’s the twist- Instead of the tool call returning an array of emails, it writes it to a log file and then it uses grep to search across these files. This performed way better and is super easy with the SDK.

Image in tweet by Thariq

What does this mean? I can get my agent to build a profile for me from scratch just by agentically searching my inbox. This is what that looks like right now, it honestly surprised me by how much it was able to find. Open source repo coming soon!

Image in tweet by Thariq

@trq212 Cool I’ve got a few Claude Code sdk projects underway, great to see patterns like this to learn from

@trq212 i just had a deju-vu. Anyone remember who else made this exact thing using cursor or claude or something

@trq212 cool! what other usecases/tools could be interesting to integrate with the SDK you think?

@trq212 we are sleeping on building entire pipelines with claude code sdk

@trq212 Are you so sure you'd use the closed-source one?

@trq212 Keep these posts coming. 🔥So much opportunity locked within the Claude SDK

@trq212 Your thread is very popular today! #TopUnroll https://threadreaderapp.com/th... 🙏🏼@bilqisium for 🥇unroll

@trq212 Amazing

@trq212 If you weren't at Anthropic, you'd probably get this

Image in tweet by Thariq

@trq212 nice! I guess 'mcp_email_search_inbox' is just a tool name (as per CC SDK docs) and not mcp which pollutes the context window?

@trq212 time to read the SDK docs

Share this thread

Read on Twitter

View original thread

Navigate thread

1/18