How to Automate X (Twitter) Posting with Claude Code and AI Agents in 2026

Claude Code can queue X posts from the terminal because it runs shell commands. The live Sent2X commands are sent2x create "text" --at "2026-09-08T09:00", sent2x list, sent2x import posts.md and sent2x delete <id>, after you export SENT2X_API_KEY. There is no superx-cli and no sent2x login --key. That is the whole answer to “how do I get Claude to actually post”: give the agent a real CLI, not a browser login.

The CLI costs nothing to start. Sent2X Free is $0 for 10 scheduled posts a month, 30 AI replies and 2 Signal runs, no card. The agent drafts and queues; you read the text before it goes into the queue, and replies always stay on a human send. The pen in X's own reply box is the desktop Chrome extension; Discovery, Signal and the queue also run in the web app on a phone. Get Sent2X free and generate the key in Settings.

That workflow is legal for your own original posts. X's Automation rules, updated April 2026 and still the live help article in the 3 August 2026 Wayback capture, allow automated posts of original or authorized information through the official API (II.B.1) and forbid scripting the X website. They do not allow keyword auto-replies (II.B.2) or unapproved AI reply bots (II.B.3). Since 23 February 2026, self-serve POST /2/tweets replies are blocked unless the original author mentioned you or quote-posted you. Queue the post. Send the reply yourself.

Generate a key in Sent2X Settings and let the agent talk to the CLI, not the browser. Start a free Sent2X workspace.

What changed for agent-driven X posting in September 2026?

Four dated facts. The 4 September 2026 refresh replaces the stale “Typefully is REST-only” line from the 3 September version of this page.

  • Typefully now has two official agent paths: MCP and Agent Skills. The Typefully MCP help article (updated late August 2026, still live on 4 September 2026) documents https://mcp.typefully.com/mcpwith OAuth. Claude Code's one-liner is claude mcp add typefully --transport http --url "https://mcp.typefully.com/mcp". Coding agents are steered to Agent Skills: npx skills add typefully/agent-skills. There is still no global typefully npm CLI like @bufferapp/cli. Claiming “Typefully has no agent surface” is now false.
  • Unsolicited API replies are a hard fail, not just a policy risk. PiunikaWeb (24 February 2026) and Roboin (24 February 2026) report that on 23 February 2026 X restricted programmatic replies on POST /2/tweets. Self-serve and pay-per-use tiers can reply only when the original author mentioned the posting account or quote-posted it. Enterprise and Public Utility apps are exempt. Original posts are unchanged. An agent that drafts replies still needs a human send.
  • X API writes are still metered, including summoned replies. docs.x.com pricing lists $0.015 per Post: Create and $0.200 per Post: Create (with URL). Bundle.social (17 August 2026) re-checked that card and adds $0.010 for a summoned post (a reply to a mention of your app), plus a 3 millionpost-read cap per billing cycle. Sent2X's CLI refuses URLs so a scheduled post stays on the $0.015 write, not the $0.200 one.
  • Buffer still has two official agent paths: CLI and MCP. Buffer's legacy REST retirement note (Justina Petraityte, 27 July 2026) says the GraphQL Public API, MCP server, and CLI launched in May 2026. The Buffer CLI guide, still live on 4 September 2026, installs with npm install -g @bufferapp/cli and writes a Claude Code skill via buffer install claude. Buffer's Claude integration page documents a second path: claude mcp add --transport http buffer https://mcp.buffer.com/mcp. Claiming “Buffer has no CLI” is still false.

Timing still matters once the post is queued. Kirsti Lang at Buffer (13 March 2026) measured 8.7 million tweets and ranked Tuesday 9 a.m. local first, then Wednesday 10 a.m. and Wednesday 9 a.m. Point --at at those windows unless your own analytics disagree.

How do I set up Claude Code with the Sent2X CLI?

1

Generate an API key

Open Sent2X Settings and create a key. The live prefix is s2x_, not sxk_. Regenerate it if it leaks into a chat log.

2

Export the two environment variables

export SENT2X_URL=https://sent2x.com and export SENT2X_API_KEY=s2x_xxxx. The binary reads those names only — SUPERX_API_KEY is ignored.

3

Point Claude Code at the repo CLI

Claude Code's setup docs still recommend curl -fsSL https://claude.ai/install.sh | bash (npm install -g @anthropic-ai/claude-code is deprecated). From the Sent2X checkout, the agent runs node bin/sent2x.js. Put that path in CLAUDE.md so it uses the real subcommands (create, list, import, delete) instead of inventing flags.

4

Create one post at a named time

node bin/sent2x create "Shipped the CLI fix. No dashboard this time." --at "2026-09-08T09:00". Plain text, ≤280 characters, no https://. Use --immediate only when you mean now.

5

Verify the queue

node bin/sent2x list prints scheduled rows. If the list is empty, the key is wrong or the --at timestamp did not parse.

# One session, three posts, Tuesday window

export SENT2X_URL=https://sent2x.com

export SENT2X_API_KEY=s2x_xxxx

$ node bin/sent2x create "Just shipped the queue fix." --at "2026-09-08T09:00"

$ node bin/sent2x create "Debugging was the whole afternoon." --at "2026-09-08T11:00"

$ node bin/sent2x create "Hot take: most launch threads are recaps." --at "2026-09-09T09:00"

$ node bin/sent2x list

3 scheduled posts

Voice extras live on the same binary: sent2x experience add and sent2x soul set tone. They do not publish. They only update the documents later drafts read.

Which X schedulers can an AI agent call in 2026?

SurfaceSent2XBufferTypefully
Official CLIYes (bin/sent2x.js)Yes (@bufferapp/cli)No global npm CLI
Agent skill / MCPCLAUDE.md in-repobuffer install claude + mcp.buffer.comnpx skills add + mcp.typefully.com
HTTP APIBearer SENT2X_API_KEYGraphQL (May 2026)REST v2 (Dec 2025)
X-onlyYesNo (multi-channel)No (5 networks)
URL in the post bodyRejected by CLIAllowedAllowed
Paid floor (X-only)$39 Pro / $59 Max$6 per channelSee typefully.com

Buffer's public API announcement (Amanda Marochko, 27 May 2026) states the GraphQL API, MCP server, and CLI are on every plan including Free. Legacy REST clients have a hard stop on 1 February 2027, with brownouts on 11 November and 9 December 2026 (Justina Petraityte, 27 July 2026). If an old agent still calls the REST API, migrate it. Buffer's pricing.md (last updated November 2025, still the live card on 3 September 2026) caps API calls at 3,000 / 30 days on Free and 7,500 on Essentials.

Sent2X Free is $0 (10 posts/month). Pro is $39/month (500 posts, 150 AI replies/day). Max is $59/month (750 posts, 400 AI replies/day). The reply quota is for drafts you approve — not for an agent that hits send. For native-desktop vs third-party vs API paths, see How to Schedule Posts to X in 2026.

What does a compliant agent posting loop look like?

A coding agent is a shell with a language model attached. The legal line is what it is allowed to fire:

  • Allowed: draft your own post, run sent2x create --at, confirm with sent2x list. II.B.1 covers automated original posts through the API.
  • Not allowed without X's written approval: an agent that searches keywords and posts replies (II.B.2) or an AI reply bot that generates and sends dynamic responses (II.B.3). Even with approval, self-serve POST /2/tweets replies fail unless the author summoned you (PiunikaWeb, 24 February 2026).
  • Never: script x.com in a headless browser. The April 2026 rules say non-API automation can permanently suspend the account.

Keep the agent on the original-post queue. Put reply drafts in a file you read. That split is the same one in Is Automating Your X Posts Against the Rules?.

What are the useful use cases — and which numbers are not claims?

Build-in-public founders

The agent reads today's commits or a changelog bullet and queues one or two posts into Buffer's Tuesday–Thursday morning window. You still edit the sentence that would get you in trouble. The Sent2X founder account that ran this loop recorded 0→100 followers, 53 verified accounts in the conversation, 50.8K impressions, and 149 replies received — those four figures are first-party, not a vendor study.

Deploy announcements

A CI step can call the same CLI the agent uses. Buffer's CLI guide positions this as a deploy one-liner; Sent2X's equivalent is node bin/sent2x create --at after the release tag.

Voice notes, not auto-replies

sent2x experience add and sent2x soul set keep the voice file current so later drafts sound like you. They do not send. Replies stay human-in-the-loop — the February 2026 API change made unsolicited programmatic replies a hard error, not just a policy warning.

This page does not invent hours-saved or posts-per-week outcomes. The sourced numbers above are X's write prices, the 23 February 2026 reply restriction, Buffer's 8.7 million-tweet timing study, Buffer's May 2026 CLI and MCP launch, Typefully's late-August 2026 MCP and Agent Skills docs, and the Sent2X founder run (0→100 / 53 / 50.8K / 149). Replace any workflow volume with your own log. Product-level comparisons live on the Buffer alternative and Typefully alternative pages — this page stays on the CLI commands.

Frequently Asked Questions

how do I get Claude / an agent to actually post to X

You do not give Claude your X password. You give it a scheduler it can run as a shell command or an MCP tool. For Sent2X: generate a key in Settings (prefix s2x_), export SENT2X_URL=https://sent2x.com and SENT2X_API_KEY=s2x_xxxx, then tell Claude Code to run node bin/sent2x create "Shipped the queue fix." --at "2026-09-08T09:00" and confirm with node bin/sent2x list. Anthropic's Claude Code overview still installs with curl -fsSL https://claude.ai/install.sh | bash — the agent is a shell that can fire that binary. Buffer's path is claude mcp add --transport http buffer https://mcp.buffer.com/mcp, or npm install -g @bufferapp/cli then buffer posts create. Typefully's 2026 path is no longer curl-only: claude mcp add typefully --transport http --url "https://mcp.typefully.com/mcp" (OAuth) or npx skills add typefully/agent-skills. That queues your own original post. It is not an unattended reply bot — X's April 2026 Automation rules II.B.3 require prior written approval before an AI agent generates and sends replies on its own, and the 23 February 2026 API change (PiunikaWeb, 24 February 2026) blocks unsolicited programmatic replies on self-serve tiers.

getting AI to actually work with the other thing is where I lose hours

The hours go into glue, not prose. Pick one scheduler the agent can exec: Sent2X is node bin/sent2x create "text" --at "2026-09-08T09:00" after SENT2X_API_KEY is set. Buffer is buffer posts create or claude mcp add --transport http buffer https://mcp.buffer.com/mcp. Typefully is claude mcp add typefully --transport http --url "https://mcp.typefully.com/mcp" or npx skills add typefully/agent-skills. One export, one command, one list check. Do not also wire Zapier, a second MCP, and a custom webhook on the same afternoon. The lost hours are usually the second integration.

Can Claude Code schedule X posts automatically?

Yes, if it can run a shell command against a scheduler that posts through the official X API. Anthropic's Claude Code setup docs still recommend the native installer: curl -fsSL https://claude.ai/install.sh | bash. The live Sent2X CLI is node bin/sent2x create "text" --at "2026-09-08T09:00" after SENT2X_API_KEY is set. That queues your own original post. It is not an unattended reply bot — X's April 2026 Automation rules II.B.3 require prior written approval before an AI agent generates and sends replies on its own, and the 23 February 2026 API change (PiunikaWeb, 24 February 2026) blocks unsolicited programmatic replies on self-serve tiers.

How do I connect an AI agent to my X scheduler?

Generate an API key in Sent2X Settings, export SENT2X_URL=https://sent2x.com and SENT2X_API_KEY=s2x_xxxx, then tell the agent to run sent2x create and sent2x list (sent2x import posts.md batch-loads a plain-text file; sent2x delete <id> removes a queued post). There is no sent2x login --key command and no npm package named superx-cli. Buffer now has two official agent paths: BUFFER_API_KEY plus buffer posts create, or claude mcp add --transport http buffer https://mcp.buffer.com/mcp (buffer.com/integrations/claude). Typefully now has two first-party agent paths as well: the MCP server at https://mcp.typefully.com/mcp (help article updated late August 2026) and npx skills add typefully/agent-skills. The v2 REST API is still there if the agent has to curl.

What is the best X scheduler with CLI support?

In September 2026 the CLI field is no longer empty. Buffer launched a GraphQL Public API in May 2026 with an official CLI (npm install -g @bufferapp/cli), a Claude skill via buffer install claude, and an MCP server on every plan including Free. Sent2X ships a zero-dependency Node CLI in the repo (bin/sent2x.js) scoped to one X account. Typefully still has no global typefully npm binary like @bufferapp/cli — agents use MCP, the official Agent Skill (which wraps ./scripts/typefully.js), or HTTP to api.typefully.com. Pick Buffer if you already queue several networks; pick Sent2X if the job is X-only growth at Free $0 / Pro $39 / Max $59.

Can AI agents generate and schedule X content automatically?

They can draft and queue your own posts. X's Automation rules (updated April 2026) allow automated posts of original or authorized information through the official API (II.B.1) and forbid scripting the X website. They do not allow keyword-triggered auto-replies (II.B.2) or unapproved AI reply bots (II.B.3). Since 23 February 2026, POST /2/tweets replies on self-serve and pay-per-use tiers are allowed only when the original author mentioned you or quote-posted you (PiunikaWeb, 24 February 2026). A compliant loop is: agent drafts, you approve, CLI queues, Sent2X publishes at --at. Do not paste a URL into sent2x create — the CLI rejects https:// because X bills Post: Create (with URL) at $0.200 versus $0.015 for plain text (docs.x.com; Bundle.social, 17 August 2026).

How much does API-driven X posting cost in 2026?

X replaced subscription API tiers with pay-per-use in February 2026 (Bundle.social, 17 August 2026). Official write rates on docs.x.com, re-checked against that 17 August card, are $0.015 per Post: Create, $0.200 per Post: Create (with URL), and $0.010 for a summoned post (a reply to a mention of your app). Reads are capped at 3 million posts per monthly billing cycle. Sent2X Free is $0 for 10 posts a month; Pro is $39/month for 500 posts and 150 AI replies/day; Max is $59/month for 750 posts and 400 AI replies/day. Those product prices include the queue — they are not a substitute for X's own credit balance if you call the X API yourself.

Is there a Twitter scheduler on GitHub?

Yes. Sent2X's CLI lives in the product repo as a zero-dependency Node script: node bin/sent2x create "text" --at "2026-09-08T09:00" after SENT2X_API_KEY is set (github.com/alex-zz7/x-scheduler). Buffer's official CLI is the npm package @bufferapp/cli against a GraphQL API launched in May 2026. Typefully's official Agent Skill is the GitHub repo typefully/agent-skills, installed with npx skills add typefully/agent-skills — that is a skill pack, not a global typefully binary. Self-hosted schedulers on GitHub still need your own X API credits at $0.015 per text post (docs.x.com; Bundle.social, 17 August 2026).

What Buffer alternative has an API?

Buffer already has an API: GraphQL at api.buffer.com on every plan, with a 30-day limit of 3,000 requests on Free and 7,500 on Essentials (buffer.com/pricing.md, last updated November 2025, still the card cited on 3 September 2026). A Buffer alternative with an API is the wrong frame if you only need a queue — stay on Buffer. Sent2X is the X-only alternative: Settings issues an API key, then sent2x create / sent2x list. Typefully's v2 REST API plus MCP and Agent Skills cover the same job on five networks. Pick Buffer for multi-network GraphQL and MCP; pick Sent2X when the agent should also sit next to Discovery and Signal.

Does Typefully have a REST API?

Yes. Typefully's v2 REST API is documented at typefully.com/docs/api and in a help article dated 5 May 2026: drafts go to https://api.typefully.com/v2/social-sets/{id}/drafts with a Bearer token. As of late August 2026 that is no longer the only agent path. Typefully's MCP help article (updated over a week before 4 September 2026) documents https://mcp.typefully.com/mcp with OAuth, and the Agent Skills article documents npx skills add typefully/agent-skills. There is still no official global typefully CLI on npm. REST access is not the scarce feature in 2026 — an X-scoped growth loop with a human send on replies is.

Ready to let Claude Code talk to a real queue? Start a free Sent2X workspace — export the key, run sent2x create --at, and keep replies on a human send.