
by The-Focus-AI
Claude Code plugin for Twitter/X API - OAuth 2.0 PKCE, tweets, timeline, lists, engagement
SKILL.md
name: twitter description: This skill should be used when the user asks to "post a tweet", "read timeline", "check twitter", "like a tweet", "retweet", "search twitter", "manage twitter lists", "twitter auth", "get twitter user", "delete tweet", "trending topics", "what's trending", or mentions Twitter/X integration. Provides full Twitter API v2 access for posting, reading, engagement, and list management. version: 1.3.0
Twitter/X API Integration
This skill provides full Twitter/X API integration through OAuth 2.0 PKCE authentication. Post tweets, read timelines, engage with content, search, view trends, and manage lists.
Script Location
The CLI script is located at:
${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts
Run commands using:
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts <command> [options]
First-Time Setup
Quick Start (Using Embedded Credentials)
Just run the auth command - no setup required:
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts auth
A browser will open for Twitter authentication. Authorize the app and you're ready to go.
Using Your Own Credentials (Optional)
If you prefer to use your own Twitter Developer credentials:
- Go to Twitter Developer Portal
- Create a new project and app
- In "User authentication settings":
- App type: "Web App, Automated App or Bot"
- App permissions: "Read and Write"
- Callback URI:
http://127.0.0.1:3000/callback(NOT localhost!) - Website URL:
http://127.0.0.1:3000
- Copy Client ID and Client Secret
- Create
~/.config/twitter-skill/credentials.json:
{
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}
Token Storage
Tokens are looked up in this order:
- Project-local:
.claude/twitter-skill.local.json(in current project directory) - Global fallback:
~/.config/twitter-skill/tokens.json
This allows different projects to use different Twitter accounts, with a global default for projects without local tokens. Project-local tokens are automatically added to .gitignore.
Available Commands
Authentication
# Run OAuth flow (opens browser) - saves token to project-local .claude/
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts auth
# Run OAuth flow and save token globally (for use across all projects)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts auth --global
# Check authentication status
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts check
Response fields:
auth: Checks token validity and expirationcheck: Returns{ authenticated: boolean, user?: string, expiresAt?: string }
User Information
# Get authenticated user info
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts me
# Get authenticated user info including email
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts me --email
# Get user by username
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts user elonmusk
# Get user by ID
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts user-id 44196397
# Get multiple users by IDs (max 100, comma-separated)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts users "44196397,12,178273"
Response fields for user objects:
id: User's unique IDname: Display nameusername: @handle (without the @)created_at: Account creation datedescription: Bio textlocation: User-provided locationprofile_image_url: Avatar URLprotected: Whether tweets are protectedverified: Whether account is verifiedverified_type: Type of verification (e.g., "blue", "business", "government")url: User's website URLpublic_metrics: Object containing:followers_count: Number of followersfollowing_count: Number followingtweet_count: Total tweetslisted_count: Times listed
Posting & Deleting Tweets
# Post a new tweet
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts post "Hello from Claude Code!"
# Delete a tweet
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts delete 1234567890
Important: Always confirm with the user before posting tweets.
Response fields:
post: Returns{ id, text, url }- theurlis the direct link to the posted tweetdelete: Returns{ deleted: true }on success
Reading Tweets
Note on Long-Form Content (Articles/Note Tweets):
The skill automatically requests the note_tweet field. If a tweet contains long-form content (up to 25k chars), the full text will be returned in the note_tweet object within the response.
# Get specific tweet by ID
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts tweet 1234567890
# Get my recent tweets (last 10)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts tweets
# Get home timeline (last 20 tweets from followed accounts)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts timeline
Response fields for tweet objects:
id: Tweet's unique IDtext: Tweet content (up to 280 chars, or checknote_tweetfor long-form)author_id: User ID of the authorcreated_at: When the tweet was postedconversation_id: Thread ID (same as first tweet in thread)source: App used to post (e.g., "Twitter Web App")lang: Detected language codepublic_metrics: Object containing:retweet_count: Number of retweetsreply_count: Number of replieslike_count: Number of likesquote_count: Number of quote tweetsbookmark_count: Number of bookmarksimpression_count: View count
entities: Object containing parsed URLs, mentions, hashtagsreferenced_tweets: Array of{ type, id }for retweets, quotes, repliesnote_tweet: Object with{ text, entities }for long-form content
Engagement
# Like a tweet
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts like 1234567890
# Unlike a tweet
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts unlike 1234567890
# Retweet
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts retweet 1234567890
# Undo retweet
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts unretweet 1234567890
# Get users who retweeted a tweet (up to 100)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts retweeters 1234567890
Response fields:
like/unlike: Returns{ liked: boolean }retweet/unretweet: Returns{ retweeted: boolean }retweeters: Returns array of user objects (see User Information section)
Search
# Search recent tweets (last 7 days)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts search "claude ai"
Response: Returns array of tweet objects (see Reading Tweets section). Search queries support Twitter's search operators:
from:username- Tweets from a specific userto:username- Replies to a specific user#hashtag- Tweets with hashtag"exact phrase"- Exact phrase match-word- Exclude wordlang:en- Filter by language
Trends
# Get personalized trending topics
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts trends
Note: This endpoint requires X Premium subscription for full data. Non-premium users may receive "Unknown" for category and post_count fields.
Response fields for trend objects:
trend_name: The trending topic or hashtagcategory: Topic category (e.g., "Sports", "Entertainment", "Technology")post_count: Approximate number of posts (e.g., "10K", "100K+")trending_since: When the topic started trending
List Management
# Get my lists
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts lists
# Get list details
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list 1234567890
# Get tweets from a list (last 20)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list-tweets 1234567890
# Get list members (up to 100)
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list-members 1234567890
# Add user to list
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list-add <list-id> <user-id>
# Remove user from list
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list-remove <list-id> <user-id>
# Create a new list
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list-create "My List" --description "Description" --private
# Delete a list
pnpm tsx ${CLAUDE_PLUGIN_ROOT}/scripts/twitter.ts list-delete 1234567890
Response fields for list objects:
id: List's unique IDname: List namedescription: List descriptionprivate: Whether the list is privateowner_id: User ID of list ownermember_count: Number of membersfollower_count: Number of followerscreated_at: When the list was created
Response fields for operations:
list-add: Returns{ is_member: true }on successlist-remove: Returns{ is_member: false }on successlist-delete: Returns{ deleted: true }on success
Response Format
All commands output JSON with a consistent structure:
{
"success": true,
"data": {
// Response data here
}
}
Error responses:
{
"success": false,
"error": "Error message here"
}
Rate Limit Information
The CLI outputs rate limit info to stderr after each request:
[rate-limit] /users/me: 75/75, resets in 15m
Status indicators:
- Normal:
X/Y- plenty of requests remaining - Low:
X/Y (low)- less than 50% remaining - Critical:
X/Y (CRITICAL)- less than 20% remaining
Common Workflows
Post a Tweet
- Confirm the tweet text with the user
- Run:
post "Tweet text" - Return the tweet URL to the user
Check Notifications/Mentions
- Get the timeline:
timeline - Filter for mentions or important accounts
- Summarize for the user
See What's Trending
- Get trends:
trends - Present the top trending topics
- Search for tweets on interesting trends:
search "#trending_topic"
Manage Lists
- List existing lists:
lists - Get members:
list-members <id> - Add/remove members as needed
Research a Topic
- Search for tweets:
search "topic" - Get specific tweets for more detail:
tweet <id> - Get user info for context:
user <username>
Analyze Tweet Engagement
- Get the tweet:
tweet <id> - Check public_metrics for engagement stats
- Get retweeters:
retweeters <id>to see who shared it
API Rate Limits
Twitter API v2 has rate limits. The most common:
- Tweets lookup: 300 requests per 15 minutes
- Post tweet: 200 tweets per 24 hours
- Like/Unlike: 50 per 24 hours
- Search: 180 requests per 15 minutes
- Trends: 75 requests per 15 minutes
The skill will return rate limit errors when exceeded.
Troubleshooting
"Something went wrong" during auth
- Ensure callback URL is
http://127.0.0.1:3000/callback(NOT localhost) - Check that port 3000 is not in use
Token expires quickly
- The skill automatically refreshes tokens before expiry
- If issues persist, run
authagain
"Not authorized" errors
- Check that your app has the required permissions
- Run
authto re-authenticate with updated scopes
Rate limit exceeded
- Wait for the rate limit window to reset (usually 15 minutes)
- Space out requests when doing bulk operations
Trends showing "Unknown" values
- This endpoint requires X Premium subscription for full data
- Non-premium accounts will see trend names but not categories or post counts
スコア
総合スコア
リポジトリの品質指標に基づく評価
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
1ヶ月以内に更新
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
レビュー
レビュー機能は近日公開予定です
