{"skill":{"slug":"x-twitter-browser","displayName":"x-twitter-browser","summary":"Log in to X/Twitter via a real browser session and perform actions — posting, replying, reposting, liking, and bookmarking tweets via headless Playwright.","description":"---\nname: x-twitter-browser\ndescription: Log in to X/Twitter via a real browser session and perform actions — posting, replying, reposting, liking, and bookmarking tweets via headless Playwright.\nversion: 2.0.0\nuser-invocable: true\nmetadata:\n  openclaw:\n    emoji: \"🐦\"\n    skillKey: \"x-twitter-browser\"\n    requires:\n      bins:\n        - python3\nallowed-tools: Bash(python3:*)\n---\n\n# x-twitter-browser\n\nExecute browser actions on X using a saved login session, without the official X API.\n\nUsers log in once via a visible browser window. The session is saved and reused for all subsequent headless operations.\n\nAfter installing into OpenClaw, the skill lives at:\n\n```bash\n~/.openclaw/workspace/skills/x-twitter-browser/\n```\n\nCommands below assume you run from the skill root directory:\n\n```bash\ncd ~/.openclaw/workspace/skills/x-twitter-browser\n```\n\n## Use cases\n\n- You want to automate X actions without the official API\n- Running headless on a VM or Linux server\n- Building a long-term extensible browser skill for X automation\n\n## Architecture\n\nThis skill has two layers:\n\n### 1. Session layer\n\nManages login and cookie persistence (stored in the centralised OpenClaw auth directory):\n\n- `scripts/setup_session.py` — log in via visible browser, save cookies\n- `~/.openclaw/auth/x-twitter/cookies.json` — Playwright storage state\n\n### 2. Action layer\n\nPerforms actions using the saved session:\n\n- Post tweet: `scripts/post_tweet.py`\n- Reply to tweet: `scripts/reply_post.py`\n- Repost (retweet) / Quote tweet: `scripts/repost_post.py`\n- Like / Unlike tweet: `scripts/like_post.py`\n- Bookmark / Remove bookmark: `scripts/bookmark_post.py`\n\n## Dependencies\n\nFirst-time setup (installs Playwright + Chromium):\n\n```bash\n./scripts/setup.sh\n```\n\n**Note:** Chromium download is ~150MB and may take several minutes on first run.\n\n**OpenClaw:** When running `setup.sh` via OpenClaw, it executes in the background and the user cannot see the `echo` output. Forward each progress message to the user so they know the setup is progressing.\n\n## Session management\n\nSession cookies are stored in `~/.openclaw/auth/x-twitter/cookies.json` (centralised auth directory shared by all OpenClaw skills, survives skill updates). Do not commit or share this file.\n\n### Log in (first time or when session expires)\n\nThis is a two-phase process. You (the agent) drive both phases — the user does not need to touch the terminal.\n\n**Phase 1 — Launch the login browser:**\n\n```bash\npython3 scripts/setup_session.py\n```\n\nThis opens a visible browser window at the X login page. The script prints a banner and **waits for Enter on stdin** before saving cookies. Once the browser is open, tell the user:\n\n> A browser window has opened with the X login page. Please log in with your account (username, password, 2FA if prompted). Once you see the home timeline, let me know.\n\nThen wait for the user to confirm they have logged in. Do NOT send Enter yet.\n\n**Phase 2 — After the user confirms they are logged in:**\n\nSend Enter (newline) to the waiting script's stdin to trigger cookie saving. Check the output for `Session saved` to confirm success.\n\nIf the output shows a WARNING (\"The page still looks like a login page\"), ask the user to double-check they are actually logged in and can see the home timeline. Once confirmed, send Enter again to save anyway.\n\n### Verify session\n\n```bash\npython3 scripts/setup_session.py --verify-only\n```\n\nSuccess looks like:\n\n```text\nSession looks valid: https://x.com/home\n```\n\nIf verification fails, re-run the two-phase login flow above.\n\n### OpenClaw / headless-only environments\n\nIf running on a headless VM, set up the session on a local machine first, then copy:\n\n```bash\nscp ~/.openclaw/auth/x-twitter/cookies.json user@server:~/.openclaw/auth/x-twitter/cookies.json\n```\n\n## Workflow\n\n### 1. Set up session (once)\n\nFollow the two-phase login flow in the \"Session management\" section above. Do not simply run `setup_session.py` and tell the user to press Enter — you must run it, wait for the user to confirm login, then send Enter yourself.\n\n### 2. Post a tweet\n\n```bash\npython3 scripts/post_tweet.py \\\n  --text \"hello\"\n```\n\n### 3. Reply to a tweet\n\n```bash\npython3 scripts/reply_post.py \\\n  --tweet \"https://x.com/username/status/123456789\" \\\n  --text \"My reply\"\n```\n\n### 4. Repost (retweet) a tweet\n\nPlain repost (no comment):\n\n```bash\npython3 scripts/repost_post.py \\\n  --tweet \"https://x.com/username/status/123456789\"\n```\n\nQuote tweet (repost with your comment):\n\n```bash\npython3 scripts/repost_post.py \\\n  --tweet \"https://x.com/username/status/123456789\" \\\n  --text \"My comment\"\n```\n\nFor both reply and repost, `--tweet` accepts a full URL or just the tweet ID.\n\n### 5. Like a tweet\n\n```bash\npython3 scripts/like_post.py \\\n  --tweet \"https://x.com/username/status/123456789\"\n```\n\nUnlike (remove like):\n\n```bash\npython3 scripts/like_post.py \\\n  --tweet \"https://x.com/username/status/123456789\" \\\n  --undo\n```\n\n### 6. Bookmark a tweet\n\n```bash\npython3 scripts/bookmark_post.py \\\n  --tweet \"https://x.com/username/status/123456789\"\n```\n\nRemove bookmark:\n\n```bash\npython3 scripts/bookmark_post.py \\\n  --tweet \"https://x.com/username/status/123456789\" \\\n  --undo\n```\n\nFor like and bookmark, `--tweet` accepts a full URL or just the tweet ID.\n\n## Rules\n\n- `--verify-only` success means the session is likely usable\n- If the page behaves oddly, buttons are disabled, or extra dialogs appear, re-run `setup_session.py`\n- If Chromium fails to start, run `./scripts/setup.sh` to install browser deps\n\n## Operational requirements\n\n- Before the first action, check if session exists; if not, run the two-phase login flow (see \"Session management\" above)\n- Run `--verify-only` before any write operation\n- Confirm the action and content before executing\n- Do not commit cookies to the repo (`~/.openclaw/auth/`)\n- Call `scripts/*.py` directly\n\n## Troubleshooting\n\n### `No saved session. Run setup_session.py first to log in to X.`\n\nNo cookies found at `~/.openclaw/auth/x-twitter/cookies.json`. Run the two-phase login flow (see \"Session management\" above).\n\n### `Session is not authenticated`\n\n- Session cookies expired (typically lasts days to weeks)\n- Account triggered extra verification\n\nRe-run the two-phase login flow to log in again.\n","tags":{"latest":"1.0.10"},"stats":{"comments":0,"downloads":1067,"installsAllTime":0,"installsCurrent":0,"stars":1,"versions":11},"createdAt":1773213594337,"updatedAt":1779077931334},"latestVersion":{"version":"1.0.10","createdAt":1773891292385,"changelog":"- Improved session login flow: Now uses a two-phase \"agent-driven\" process where Enter is sent to the script only after the user confirms login, rather than requiring direct terminal interaction by the user.\n- Updated documentation to clarify operational requirements for session setup and management.\n- Added detailed instructions for handling login prompts and warnings during session creation.\n- Clarified workflow: agent now fully orchestrates session setup, enhancing user guidance and automation.","license":"MIT-0"},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"zhanghanjun2","userId":"s17fg5d219d503rz8wccbp1dgn83hqbx","displayName":"clawgrid","image":"https://avatars.githubusercontent.com/u/24560749?v=4"},"moderation":{"isSuspicious":false,"isMalwareBlocked":false,"verdict":"clean","reasonCodes":["review.llm_review"],"summary":"Review: review.llm_review","engineVersion":"v2.4.24","updatedAt":1780089969209}}