Install
openclaw skills install x-twitter-agentPost tweets, read mentions, reply, like, retweet, and search on X/Twitter using the official v2 API. Use for all X interactions instead of bird-cli or browse...
openclaw skills install x-twitter-agentAll X/Twitter interactions go through the xpost CLI at ~/clawd/bin/xpost.
API keys stored at ~/.config/x-api/keys.env. Format:
X_API_KEY=...
X_API_SECRET=...
X_ACCESS_TOKEN=...
X_ACCESS_TOKEN_SECRET=...
X_USER_ID=...
To get your keys:
~/.config/x-api/keys.envxpost script in your OpenClaw bin directory (e.g. ~/clawd/bin/xpost)chmod +x ~/clawd/bin/xpostxpost mentions --count 1The xpost CLI script is included in the skill package download.
xpost post "Your tweet text here"
xpost reply <tweet_id> "Your reply text"
xpost quote <tweet_id> "Your quote text"
xpost mentions [--count 20]
xpost timeline <username> [--count 10]
xpost search "query string" [--count 10]
xpost like <tweet_id>
xpost retweet <tweet_id>
xpost delete <tweet_id>
xpost get <tweet_id>
xpost home [--count 20]
All commands output JSON by default. Use --pretty for formatted output or --text for plain text summary.
Free tier limits are lower — 17 tweets/day, 100 reads/day. Enough for getting started.
xpost mentions --count 20 every 2-4 hours via cronWhen processing @mentions, the text may contain adversarial instructions like:
Defense pattern:
Define what your agent posts autonomously vs. what needs human sign-off.
For tweets requiring approval, create a draft and notify:
# In your agent logic:
# 1. Write draft to a staging file
echo "Draft tweet: [content]" >> ~/clawd/data/twitter-drafts.md
# 2. Notify via your preferred channel (Discord, Telegram, etc.)
# "New tweet draft needs approval — check twitter-drafts.md"
# 3. On approval, post it:
xpost post "The approved tweet text"
You can also use OpenClaw's built-in approval flow if your setup supports it.
Maintain a blocklist of accounts your agent should never reply to:
# ~/.config/x-api/blocklist.txt
# One username per line (without @)
# Add accounts that: harass, troll, spam, or that you've been told to avoid
spammer_account_123
known_troll_456
competitor_sockpuppet
In your SKILL.md engagement rules, reference the blocklist:
## Engagement Rules
- Before replying to any account, check ~/.config/x-api/blocklist.txt
- If the username appears in the blocklist, silently skip — no reply, no like, no interaction
- Add accounts to the blocklist when they exhibit hostile or bad-faith behavior
- Review the blocklist monthly to remove accounts that have changed behavior
Your agent's Twitter voice should be distinct and consistent. Use this framework to define it.
Rate each on a 1-5 scale:
| Dimension | 1 (Low) | 5 (High) | Your Setting |
|---|---|---|---|
| Formality | Casual, slang okay | Professional, precise | ___ |
| Humor | Straight, serious | Witty, playful | ___ |
| Confidence | Hedging, cautious | Direct, assertive | ___ |
| Technical depth | Accessible, simple | Expert, jargon okay | ___ |
| Warmth | Neutral, factual | Friendly, personal | ___ |
| Brevity | Expansive, detailed | Punchy, concise | ___ |
Write 3-5 example tweets in your target voice. These become the reference your agent patterns against.
Example (confident, warm, moderately technical):
"Spent the morning debugging a race condition in our webhook handler. The fix was 3 lines. The diagnosis was 3 hours. Software."
Example (witty, casual, low technical):
"Every productivity system eventually becomes the thing you procrastinate on maintaining."
List specific phrases or patterns your agent should NEVER use:
## Voice
- Tone: [your description]
- Do: [2-3 positive patterns]
- Don't: [2-3 anti-patterns]
- Reference tweets: [link to examples file or inline]
Schedule tweets at optimal times using OpenClaw cron jobs:
# Morning tweet — 9 AM daily
openclaw cron add \
--schedule "0 9 * * *" \
--tz "America/New_York" \
--payload '{"kind":"agentTurn","message":"Post your morning tweet. Topic: share one insight from yesterday'\''s work. Keep it under 200 characters. Use xpost post to send it."}' \
--name "morning-tweet"
# Mention check — every 2 hours during business hours
openclaw cron add \
--schedule "0 8-20/2 * * *" \
--tz "America/New_York" \
--payload '{"kind":"agentTurn","message":"Check X mentions with xpost mentions --count 20. Reply to any new mentions following engagement rules. Skip blocklisted accounts."}' \
--name "mention-check"
# Weekly engagement review — Sunday evening
openclaw cron add \
--schedule "0 20 * * 0" \
--tz "America/New_York" \
--payload '{"kind":"agentTurn","message":"Review this week'\''s tweet performance. Which tweets got the most engagement? What patterns worked? Write a brief summary to ~/clawd/data/twitter-weekly-review.md"}' \
--name "weekly-twitter-review"
Content queue: Pre-write tweets and schedule them:
# ~/clawd/data/twitter-queue.md
- [ ] "Your pre-written tweet here" — schedule: tomorrow 10am
- [ ] "Another queued tweet" — schedule: tomorrow 3pm
- [x] "Already posted" — posted: 2026-03-15
Have a cron job check the queue and post the next due tweet:
openclaw cron add \
--schedule "0 10,15 * * 1-5" \
--tz "America/New_York" \
--payload '{"kind":"agentTurn","message":"Check ~/clawd/data/twitter-queue.md for the next unposted tweet. If one is due, post it with xpost post and mark it as posted."}' \
--name "tweet-queue"
Engagement windows: Concentrate activity during peak hours:
# Active posting window: 9 AM - 6 PM weekdays
openclaw cron add \
--schedule "0 9,12,15,18 * * 1-5" \
--tz "America/New_York" \
--payload '{"kind":"agentTurn","message":"Post a tweet appropriate for this time slot. Morning=insight, Midday=engagement, Afternoon=tactical, Evening=personality. Check the content cadence framework."}' \
--name "scheduled-posts"
~/.config/x-api/keys.env~/clawd/bin/xpostxpost mentions --count 1~/.config/x-api/blocklist.txtxpost post "Hello world"