Twitter Cliのロゴ

Twitter Cli

組織人気
public-clis
twitter-cli

Use twitter-cli for ALL Twitter/X operations — reading tweets, posting, replying, quoting, liking, retweeting, following, searching, user lookups. Invoke whenever user requests any Twitter interaction.

概要

公開者public-clis
リポジトリtwitter-cli
スキル名twitter-cli
スター
2.9K
フォーク
278
同梱ファイル
37
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 37個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    public-clisがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルTwitter CliをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/public-clis/twitter-cli/tree/main
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/public-clis/twitter-cli.git \
  .claude/skills/twitter-cli
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでTwitter Cliを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にTwitter Cliを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Twitter Cliは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

twitter-cli — Twitter/X CLI Tool

Binary: twitter Credentials: browser cookies (auto-extracted) or env vars

Setup

bash
# Install (requires Python 3.8+)
uv tool install twitter-cli
# Or: pipx install twitter-cli

# Upgrade to latest (recommended to avoid API errors)
uv tool upgrade twitter-cli
# Or: pipx upgrade twitter-cli

Authentication

IMPORTANT FOR AGENTS: Before executing ANY twitter-cli command, you MUST first check if credentials exist. If not, you MUST proactively guide the user through the authentication process. Do NOT assume credentials are configured.

CRITICAL: Write operations (posting tweets, replying, quoting) REQUIRE full browser cookies. Only providing auth_token + ct0 via env vars may result in 226 error ("looks like automated behavior"). For best results, use browser cookie extraction.

Step 0: Check if already authenticated

bash
twitter status --yaml >/dev/null && echo "AUTH_OK" || echo "AUTH_NEEDED"

If AUTH_OK, skip to Command Reference. If AUTH_NEEDED, proceed to guide the user:

Step 1: Guide user to authenticate

Method A: Browser cookie extraction (recommended)

Ensure user is logged into x.com in one of: Arc, Chrome, Edge, Firefox, Brave. twitter-cli auto-extracts cookies. All Chrome profiles are scanned automatically. To specify a profile: TWITTER_CHROME_PROFILE="Profile 2" twitter feed. To prioritize a specific browser: TWITTER_BROWSER=chrome twitter feed (supported: arc, chrome, edge, firefox, brave).

bash
twitter whoami

Method B: Environment variables

bash
export TWITTER_AUTH_TOKEN="<auth_token from browser>"
export TWITTER_CT0="<ct0 from browser>"
twitter whoami

Method C: Full cookie string (for cloud/remote agents)

Tell the user:

我需要你的 Twitter 登录凭证。请按以下步骤获取:

  1. 用 Chrome/Edge/Firefox 打开 https://x.com(确保已登录)
  2. 按 F12 打开开发者工具 → Network 标签
  3. 在页面上刷新,点击任意 x.com 请求
  4. 找到 Request Headers → Cookie: 这一行,右键 → 复制值
  5. 把完整 Cookie 字符串发给我

⚠️ Cookie 包含登录信息,请不要分享给其他人。

Then extract and set env vars:

bash
FULL_COOKIE="<user's cookie string>"
export TWITTER_AUTH_TOKEN=$(echo "$FULL_COOKIE" | grep -oE 'auth_token=[a-f0-9]+' | cut -d= -f2)
export TWITTER_CT0=$(echo "$FULL_COOKIE" | grep -oE 'ct0=[a-f0-9]+' | cut -d= -f2)
twitter whoami

Step 2: Handle common auth issues

SymptomAgent action
No Twitter cookies foundGuide user to login to x.com in browser, or set env vars
Read works, write returns 226Full cookies missing — use browser cookie extraction instead of env vars
Cookie expired (401/403)Ask user to re-login to x.com and retry
User changed passwordAll old cookies invalidated — re-extract

Output Format

Default: Rich table (human-readable)

bash
twitter feed                          # Pretty table output

YAML / JSON: structured output

Non-TTY stdout defaults to YAML automatically. Use OUTPUT=yaml|json|rich|auto to override.

bash
twitter feed --yaml
twitter feed --json | jq '.[0].text'

All machine-readable output uses the envelope documented in SCHEMA.md. Tweet and user payloads now live under .data.

Full text: --full-text flag (rich tables only)

Use --full-text when the user wants complete post bodies in terminal tables. It affects rich table list views such as feed, bookmarks, search, user-posts, likes, list, and reply tables in tweet. It does not change --json, --yaml, or -c compact output.

bash
twitter feed --full-text
twitter search "AI agent" --full-text
twitter user-posts elonmusk --max 20 --full-text
twitter tweet 1234567890 --full-text

Compact: -c flag (minimal tokens for LLM)

bash
twitter -c feed --max 10              # Minimal fields, great for LLM context
twitter -c search "AI" --max 20       # ~80% fewer tokens than --json

Compact fields (per tweet): id, author (@handle), text (truncated 140 chars), likes, rts, time (short format)

Command Reference

Read Operations

bash
twitter status                         # Quick auth check
twitter status --yaml                  # Structured auth status
twitter whoami                         # Current authenticated user
twitter whoami --yaml                  # YAML output
twitter whoami --json                  # JSON output
twitter user elonmusk                  # User profile
twitter user elonmusk --json           # JSON output
twitter feed                           # Home timeline (For You)
twitter feed -t following              # Following timeline
twitter feed --max 50                  # Limit count
twitter feed --full-text               # Show full post body in table
twitter feed --filter                  # Enable ranking filter
twitter feed --yaml > tweets.yaml      # Export as YAML
twitter feed --input tweets.json       # Read from local JSON file
twitter bookmarks                      # Bookmarked tweets
twitter bookmarks --full-text          # Full text in bookmarks table
twitter bookmarks --max 30 --yaml
twitter search "keyword"               # Search tweets
twitter search "AI agent" -t Latest --max 50
twitter search "AI agent" --full-text  # Full text in search results
twitter search "topic" -o results.json # Save to file
twitter tweet 1234567890               # Tweet detail + replies
twitter tweet 1234567890 --full-text   # Full text in reply table
twitter tweet https://x.com/user/status/12345  # Accepts URL
twitter show 2                         # Open tweet #2 from last feed/search list
twitter show 2 --full-text             # Full text in reply table
twitter show 2 --json                  # Structured output
twitter list 1539453138322673664       # List timeline
twitter list 1539453138322673664 --cursor "<next-cursor>"
twitter list 1539453138322673664 --full-text
twitter user-posts elonmusk --max 20   # User's tweets
twitter user-posts elonmusk --full-text
twitter likes elonmusk --max 30        # User's likes (own only, see note)
twitter likes elonmusk --full-text
twitter followers elonmusk --max 50    # Followers
twitter following elonmusk --max 50    # Following

Write Operations

bash
twitter post "Hello from twitter-cli!"              # Post tweet
twitter post "Hello!" --image photo.jpg              # Post with image
twitter post "Gallery" -i a.png -i b.jpg             # Up to 4 images
twitter reply 1234567890 "Great tweet!"              # Reply (standalone)
twitter reply 1234567890 "Nice!" -i pic.png          # Reply with image
twitter post "reply text" --reply-to 1234567890      # Reply (via post)
twitter quote 1234567890 "Interesting take"          # Quote-tweet
twitter quote 1234567890 "Look" -i chart.png         # Quote with image
twitter delete 1234567890                            # Delete tweet
twitter like 1234567890                              # Like
twitter unlike 1234567890                            # Unlike
twitter retweet 1234567890                           # Retweet
twitter unretweet 1234567890                         # Unretweet
twitter bookmark 1234567890                          # Bookmark
twitter unbookmark 1234567890                        # Unbookmark
twitter follow elonmusk                              # Follow user
twitter unfollow elonmusk                            # Unfollow user

Image upload notes:

  • Supported formats: JPEG, PNG, GIF, WebP
  • Max file size: 5 MB per image
  • Max 4 images per tweet
  • Use --image / -i (repeatable)

Agent Workflows

Post and verify

bash
twitter post "My tweet text" 2>/dev/null
# Output includes tweet URL: 🔗 https://x.com/i/status/<id>

Post with images

bash
# Single image
twitter post "Check this out!" --image /path/to/photo.jpg

# Multiple images
twitter post "Photo gallery" -i img1.png -i img2.jpg -i img3.webp

Reply to someone's latest tweet

bash
TWEET_ID=$(twitter user-posts targetuser --max 1 --json | jq -r '.data[0].id')
twitter reply "$TWEET_ID" "Nice post!"

Create a thread

bash
# Post first tweet, capture output for tweet ID
twitter post "Thread 1/3: First point"
# Note the tweet ID from output, then:
twitter reply <first_tweet_id> "2/3: Second point"
twitter reply <second_tweet_id> "3/3: Final point"

Quote-tweet with commentary

bash
TWEET_ID=$(twitter search "interesting topic" --max 1 --json | jq -r '.data[0].id')
twitter quote "$TWEET_ID" "This is a great insight!"

Like all search results

bash
twitter search "interesting topic" --max 5 --json | jq -r '.data[].id' | while read id; do
  twitter like "$id"
done

Get user info then follow

bash
twitter user targethandle --json | jq '.data | {username, followers, bio}'
twitter follow targethandle

Find most popular tweets from a user

bash
twitter user-posts elonmusk --max 20 --json | jq '.data | sort_by(.metrics.likes) | reverse | .[:3] | .[] | {id, text: .text[:80], likes: .metrics.likes}'

Check follower relationship

bash
MY_NAME=$(twitter whoami --json | jq -r '.data.user.username')
twitter followers "$MY_NAME" --max 200 --json | jq -r '.data[].username' | grep -q "targetuser" && echo "Yes" || echo "No"

Daily reading workflow

bash
# Compact mode for token-efficient LLM context
twitter -c feed -t following --max 30
twitter -c bookmarks --max 20

# Rich table with complete post bodies
twitter feed -t following --max 20 --full-text
twitter search "AI agent" --max 20 --full-text

# Full JSON for analysis
twitter feed -t following --max 30 -o following.json
twitter bookmarks --max 20 -o bookmarks.json

Search with jq filtering

bash
# Tweets with > 100 likes
twitter search "AI safety" --max 20 --json | jq '[.data[] | select(.metrics.likes > 100)]'

# Extract just text and author
twitter search "rust lang" --max 10 --json | jq '.data[] | {author: .author.screenName, text: .text[:100]}'

# Most engaged tweets
twitter search "topic" --max 20 --json | jq '.data | sort_by(.metrics.likes) | reverse | .[:5] | .[].id'

Ranking Filter

Filtering is opt-in. Enable with --filter:

bash
twitter feed --filter
twitter bookmarks --filter

Error Reference

ErrorCauseFix
No Twitter cookies foundNot authenticatedLogin to x.com in browser, or set env vars
HTTP 226Automated detectionUse browser cookie extraction (not env vars)
HTTP 401/403Cookie expiredRe-login to x.com and retry
HTTP 404QueryId rotationRetry (auto-fallback built in)
HTTP 429Rate limitedWait 15+ minutes, then retry
Error 187Duplicate tweetChange text content
Error 186Tweet too longKeep under 280 chars

Limitations

  • Images only — video/GIF animation upload not yet supported (image upload supports JPEG/PNG/GIF/WebP)
  • No DMs — no direct messaging
  • No notifications — can't read notifications
  • No polls — can't create polls
  • Single account — one set of credentials at a time
  • Likes are private — Twitter/X made all likes private since June 2024. twitter likes only works for your own account

Safety Notes

  • Write operations have built-in random delays (1.5–4s) to avoid rate limits.
  • TLS fingerprint and User-Agent are automatically matched to the Chrome version used.
  • Do not ask users to share raw cookie values in chat logs.
  • Prefer local browser cookie extraction over manual secret copy/paste.
  • Agent should treat cookie values as secrets (do not echo to stdout unnecessarily).

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Twitter Cli」では何ができますか?

Use twitter-cli for ALL Twitter/X operations — reading tweets, posting, replying, quoting, liking, retweeting, following, searching, user lookups. Invoke whenever user requests any Twitter interaction.

TypingMindでTwitter Cliを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Twitter Cliはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにTwitter Cliをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/public-clis/twitter-cli/tree/mainを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Twitter Cliを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Twitter Cliは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもTwitter Cliを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Twitter Cli」は無料ですか?

はい。public-clisがGitHubでApache-2.0ライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇