Guide the user through X (Twitter) Developer API application, authentication, and connection. Use when the user says "x-connect-apiして", "X API接続したい", "Developer API申請したい", "API繋ぎたい", "x-post使いたい", "API料金知りたい", or when skills report that X API is not available and the user wants to enable it. Walks through portal application, app creation, credential retrieval, .env setup, and connection test with detailed cost expectations upfront. Most suitable for non-developer users (business owners, content creators).
Walk the user through connecting X Developer API. x-tweetcraft's real power (L2分析, L3トレンド, 週次戦略, 自動投稿) requires this connection. Without it, only L1 (draft generation) works.
Target user: Non-developers. Assume zero familiarity with APIs, tokens, or Developer portals.
Always start by fetching the latest pricing info from X's official site. X changes their API pricing frequently, and stale cached info can mislead users.
Use WebFetch to retrieve the official pages:
Extract:
Fallback: If WebFetch fails (401/403/network error), use the cached snapshot in references/api-plans-and-costs.md and explicitly tell the user:
公式サイトから最新料金を取得できませんでした。キャッシュ情報(YYYY-MM-DD時点)で説明しますが、正確な金額は https://developer.x.com/#features で直接確認してください。
Version mismatch detection: If the fetched info differs significantly from the cached snapshot, use the fetched (latest) info and note the discrepancy:
※ 公式情報と内部キャッシュに差異があったため、最新の公式情報で説明しています。
Use the retrieved info to populate Step 1 below.
Before starting the application, set accurate expectations. Tell the user:
Present the pricing using the latest info fetched in Step 0:
X API接続は x-tweetcraftの真価を発揮するため必須 です。ただし料金がかかります。
最新の公式料金情報(取得済み/要確認は公式URLで):
- 公式ページ: https://developer.x.com/#features
- [ここに Step 0 で取得した最新のプラン情報を展開して説明]
一般的なプラン体系(2026年4月時点のキャッシュ情報、最新は上記公式URL参照):
- Free プラン ($0): 自動投稿のみ。分析・トレンド機能は実質使えない
- Pay-Per-Use: 使った分だけ従量課金。個人ユーザー推奨
- Basic プラン ($200/月前後): 月数千投稿のヘビー運用向け
なぜお金が必要? X社が2023年以降、APIを有料化しました。無料枠では深い分析や検索には使えません。
詳細な料金表・ケース別コスト目安は:
${CLAUDE_PLUGIN_ROOT}/skills/x-connect-api/references/api-plans-and-costs.md最初のおすすめ: まず Free で申請して動作確認 → 必要を感じたら Pay-Per-Use or Basic にアップグレード
続けますか?
If user wants more cost info: Read references/api-plans-and-costs.md and present relevant sections.
If user hesitates: Remind them x-tweetcraft still works without API (L1生成のみ)。急がなくてOK。
Ask the user where they are:
現在の状況を教えてください:
A) まだ何もしていない(Developer Portalアカウント未作成) B) Developer Portalは登録済み、App未作成 C) App作成済み、認証情報取得済み D) 認証情報を .env に設定済み、接続テストをしたい
For detailed step-by-step walkthrough, read references/detailed-setup-guide.md and follow the relevant sections:
The detailed guide covers:
When reading references, adapt the content to user's specific situation. Don't dump the whole file into chat — guide conversationally.
If the user has a pre-drafted application text (e.g., ceo/x-automation/X_API_APPLICATION.md for VITAL Z users), read it and offer to use that.
Otherwise, provide the generic template from the detailed guide and customize with the user's specifics (use case, target audience from brand-voice.md if available).
Always remind before credential handling:
⚠️ 絶対にやってはいけないこと:
- APIキーをGitリポジトリにコミットしない
- APIキーをチャット(ChatGPT/Claude.ai等)に貼らない
- APIキーをSlackや公開チャンネルに書かない
- スクリーンショットを撮らない
保存先:
~/.x-tweetcraft.env(ホーム直下、リポジトリ外) バックアップ: パスワードマネージャー推奨
Claudeがbashコマンドを実際に実行してユーザーを詰まらせない。ユーザーは Y/N で答えるだけ。
全bash実行前に必ずユーザー確認を取る:
これから以下を実行します。よろしいですか?
<コマンド>(Y/N)
Run:
python3 --version
references/python-env-setup.md のOS別導入手順を参照して案内するRun:
python3 -m pip --version
python3 -m ensurepip --upgrade を案内プラグインのインストール場所を特定:
echo "${CLAUDE_PLUGIN_ROOT}"
その値を使ってrequirements.txtをインストール(--user フラグでシステムPython汚染回避):
python3 -m pip install --user -r "${CLAUDE_PLUGIN_ROOT}/mcp-server/requirements.txt"
エラー時の分岐:
externally-managed-environment (macOS Homebrew Python 3.11+): venvモードを案内Permission denied: --user フラグが抜けていないか確認references/python-env-setup.md のトラブルシュートを参照import確認:
python3 -c "import tweepy; import fastmcp; import dotenv; print('All OK')"
確認後に実行:
# 既存チェック
ls -la ~/.x-tweetcraft.env 2>/dev/null
cat > ~/.x-tweetcraft.env << 'EOF'
# X Developer API credentials for x-tweetcraft
# Get these from https://developer.x.com/en/portal/dashboard
X_BEARER_TOKEN=
X_API_KEY=
X_API_SECRET=
X_ACCESS_TOKEN=
X_ACCESS_TOKEN_SECRET=
EOF
chmod 600 ~/.x-tweetcraft.env
ユーザーに2つの方式を提示:
認証情報をどう入力しますか?
A) エディタで直接貼り付け(簡単・macOS推奨) → ファイルをテキストエディタで開いて、値を貼り付けて保存
B) 対話スクリプトで入力(よりセキュア) → 画面に表示されない方式で1つずつ入力。チャット履歴にも残らない
どちらにしますか?
方式A選択時:
open -t ~/.x-tweetcraft.env # macOS
# または
xdg-open ~/.x-tweetcraft.env # Linux
# または
notepad "$env:USERPROFILE\.x-tweetcraft.env" # Windows
ユーザーに伝える:
エディタが開きました。5つの
=の右側に各値を貼り付けて、保存してください。 ダブルクォート(")で囲まないでください。保存したら教えてください。
方式B選択時:
python3 "${CLAUDE_PLUGIN_ROOT}/mcp-server/setup-credentials.py"
対話形式でgetpass経由入力(画面非表示)。
Claudeがやってはいけないこと:
cat ~/.x-tweetcraft.env を実行しない(値が見えてしまう)空欄チェックのみ(値は読まない):
grep -c "^X_[A-Z_]*=$" ~/.x-tweetcraft.env
0 と出れば全入力完了。他の数字が出たらユーザーに未入力の項目があることを伝える(どの項目かは言わない、プライバシーのため「○項目未入力です」だけ)。
ファイル権限確認:
ls -la ~/.x-tweetcraft.env
-rw------- であることを確認。違う場合は chmod 600 ~/.x-tweetcraft.env を実行。
詳細参照:
references/python-env-setup.mdreferences/credential-input-guide.mdMCPサーバーは .mcp.json 経由で起動する。認証情報を設定した後は Claude Codeセッションを再起動 するとMCPサーバーが新しい .env を読み込む。
ユーザーに伝える:
認証情報のセットアップが完了しました。
新しい認証情報を読み込むため、Claude Codeを一度終了して再起動してください:
/exit(またはCtrl+D)→ claude --plugin-dir <plugin-path> で再起動再起動後、「X APIの接続テストして」と言えば、軽いAPI呼び出しで動作確認します。
Once setup is complete:
🎉 X API接続準備完了です!これで以下が使えるようになります:
今すぐ使えるもの(API依存スキル):
x-analyze-posts— 過去投稿の深い傾向分析x-research-trends— 市場トレンド研究x-content-strategist— 週次戦略レビュー(agent)x-draft— API連携データ込みでより精度の高い下書き生成計画中(P1実装予定):
x-post— 下書きを直接投稿x-refresh-brand-voice— 過去投稿100件以上を分析してbrand-voice深化まず試すなら:
- 「自分の投稿分析して」で
x-analyze-postsを実行- 「今伸びてるツイート調べて」で
x-research-trendsを実行
references/detailed-setup-guide.mdreferences/api-plans-and-costs.mdUser's application gets rejected:
User is confused about Project vs App:
User has multiple X accounts:
User hesitates due to cost:
Access Token was generated BEFORE setting Read+Write permissions:
~/.x-tweetcraft.env (user's home, NOT in repo)