All posts
open sourceAI agentssocial APItoken efficiencyinfrastructure

Why We Built crossmind-cli: Token Efficiency and LLM-First Tool Design

Running an AI agent that hits social media APIs burned through credits fast. We built crossmind-cli to solve the efficiency problem — here's the infrastructure decision and what we learned.

by Nova Yu


TL;DR: An AI agent querying X/Reddit/HN APIs hundreds of times a day hits the pricing wall fast. We built crossmind-cli to compress structured output (-83% tokens per call) and layer auth by cost (Public API → Cookie → OAuth). It’s open source because early-stage builders keep rebuilding this same stack.

The Problem: API Cost vs Agent Reality

Running an AI agent that handles growth work means hitting social media APIs fast. X’s API charges per request — search, DM, post. An agent running every 2 hours burns through credits before it learns anything useful.

Raw GraphQL output isn’t usable by an LLM agent either. 10 tweets returned ~3,892 tokens of unstructured data. When an agent hits that endpoint hundreds of times a day, you’re spending context window on formatting instead of reasoning.

We needed three things:

  1. Structured output that fits in context — not raw GraphQL
  2. Auth flexibility — different platforms, different cost layers
  3. Built for agent tool use — not human CLI consumption

What We Built

crossmind-cli (https://github.com/crossmindio/crossmind-cli) is community research and social automation across 15 platforms: X, Reddit, HN, GitHub, Stack Overflow, arXiv, Product Hunt, LinkedIn, and more.

The core use case is search and collection, not broadcasting. The agent scans continuously to understand where conversations are happening and what people are frustrated about before any outreach starts.

Three design decisions that mattered:

  1. Compact structured output: ~666 tokens for 10 tweets vs ~3,892 raw GraphQL. That’s -83% per call. At hundreds of calls per day, this is the difference between an agent that fits in context and one that doesn’t.

  2. Three-tier auth: Public API → Cookie → OAuth. The agent uses the minimum cost layer per operation. Not all queries need OAuth; most don’t.

  3. Built for LLM tool use specifically. jackwener’s opencli, twitter-cli, and rdt-cli solved the auth problem (7.6k, 2.1k, 300 stars respectively). crossmind-cli solves what the agent does with the output.

The Infrastructure Surprise: X’s Hidden API Changes

Mid-build, X rotated their SearchTimeline GraphQL query IDs and added a new requirement: x-client-transaction-id, a per-request token generated from their homepage JS.

Spent a day chasing 404s before finding it. The fix is in the repo and open for others.

This wasn’t documented anywhere. Found it by reverse-engineering the homepage network requests. It’s the kind of thing that breaks agent automation silently unless you’re monitoring.

Real-World Use: The 69 DMs Lesson

I’ve been running this agent on CrossMind for a few months. Week 1: 69 cold DMs, 0 replies. Mass automation without community context is just noise.

Then I switched strategies. Used crossmind-cli for research first — scanning Reddit, HN, Twitter threads to find where relevant conversations were actually happening. Then entered those conversations naturally.

First external user came from a single Reddit reply. 11.4 hours after posting. I was asleep.

The infrastructure matters. But so does strategy.

What’s Next

  • Stream mode: tailing mentions and keyword threads in real time so the agent reacts rather than polls
  • Library mode: import as Python rather than shell out to CLI

For Builders

A lot of early-stage builders are hand-rolling this same stack with Claude Code or their own agents. crossmind-cli is the piece I kept rebuilding from scratch every time.

Figured it was worth open-sourcing.

github.com/crossmindio/crossmind-cli — PRs welcome. Happy to get into the auth architecture, token efficiency tradeoffs, or X API changes in more detail.

Want an AI to handle your growth work?

CrossMind is your AI cofounder. Join the waitlist for early access.

Join Waitlist