|
| 1 | +# x-cli |
| 2 | + |
| 3 | +A small, sharp command-line tool for scraping and lightly automating X |
| 4 | +(formerly Twitter) from your own logged-in session. One static Go binary, |
| 5 | +built-in throttling, keychain-stored cookies, no server, no database, no MCP. |
| 6 | + |
| 7 | +> **Heads-up.** x-cli talks to X's internal web endpoints, not a supported |
| 8 | +> public API. Your real account cookie is the identity. This is not an official |
| 9 | +> client, there is no SLA, and mutations (follow / unfollow / like) can get |
| 10 | +> your account rate-limited, action-blocked, or suspended. Reading public data |
| 11 | +> is low risk. Mutating at scale is not. Read `skills/x-cli/references/auth.md` |
| 12 | +> before you run anything with `grow`. |
| 13 | +
|
| 14 | +## What it does |
| 15 | + |
| 16 | +- `x profile get <user>` — scrape profile |
| 17 | +- `x followers <user>` / `x following <user>` — paginated scraping |
| 18 | +- `x tweets list <user>` / `x tweets get <id>` — user timeline and single tweet |
| 19 | +- `x search posts <query>` / `x search users <query>` — scrape search results |
| 20 | +- `x thread unroll <id>` — reassemble a thread from a root tweet |
| 21 | +- `x media download <id|url>` — download images and videos from a tweet |
| 22 | +- `x monitor account <user>` — poll a profile/timeline and stream deltas |
| 23 | +- `x grow follow-engagers <tweet-id>` — follow likers/retweeters of a tweet (mutation, dry-run by default) |
| 24 | +- `x grow follow-by-keyword <query>` — follow authors matching a query (mutation, dry-run by default) |
| 25 | + |
| 26 | +## What it is not |
| 27 | + |
| 28 | +- Not a wrapper over X's official v2 API. No API keys, no OAuth. |
| 29 | +- No MCP server. The CLI *is* the skill — see `skills/x-cli/SKILL.md`. |
| 30 | +- No Chrome extension, no dashboard, no database, no payments. |
| 31 | +- No credential/password login. Cookie import only. |
| 32 | + |
| 33 | +## Install |
| 34 | + |
| 35 | +``` |
| 36 | +make build |
| 37 | +./bin/x auth import |
| 38 | +./bin/x doctor |
| 39 | +./bin/x profile get jack |
| 40 | +``` |
| 41 | + |
| 42 | +## Auth |
| 43 | + |
| 44 | +Log into x.com in your real browser, DevTools → Application → Cookies, copy |
| 45 | +`auth_token` and `ct0`, then: |
| 46 | + |
| 47 | +``` |
| 48 | +x auth import |
| 49 | +# paste: auth_token=...; ct0=...; twid=u%3D... |
| 50 | +``` |
| 51 | + |
| 52 | +**Where the cookie lives.** x-cli tries the OS keychain first (`go-keyring`: |
| 53 | +Keychain on macOS, libsecret on Linux, Credential Manager on Windows). If the |
| 54 | +keychain is unavailable — headless boxes, containers, CI, Linux without a |
| 55 | +Secret Service daemon — x-cli falls back to an AES-256-GCM file at |
| 56 | +`$XDG_CONFIG_HOME/x-cli/session.enc` with mode `0600`. |
| 57 | + |
| 58 | +**Be honest about the fallback.** The file's encryption key is derived from a |
| 59 | +machine-stable seed (`/etc/machine-id` or the hostname), not from a passphrase |
| 60 | +you control. Its job is to keep the cookie from being casually visible in |
| 61 | +plaintext and to fail-closed on a file copied between machines. It is **not** |
| 62 | +a defense against an attacker with read access to your home directory — they |
| 63 | +can reproduce the key and decrypt it. Treat the keychain path as the real |
| 64 | +at-rest protection; treat the file fallback as obfuscation. |
| 65 | + |
| 66 | +`x auth logout` removes both the keychain entry and the file fallback. |
| 67 | + |
| 68 | +## Throttle |
| 69 | + |
| 70 | +Built in. Per-endpoint token buckets; mutation commands have a hard daily |
| 71 | +budget, minimum action gap, and jitter. Configured in `endpoints.yaml` |
| 72 | +alongside the query IDs. Mutations require `--apply`; default is dry-run. |
| 73 | + |
| 74 | +## Layout |
| 75 | + |
| 76 | +``` |
| 77 | +cmd/ cobra commands |
| 78 | +api/ HTTP transport, endpoints, throttle, auth |
| 79 | +internal/ cmdutil, keychain store, TLS fingerprint, version |
| 80 | +skills/ agentic skill (CLI as skill) |
| 81 | +endpoints.yaml query IDs + features + per-endpoint budgets |
| 82 | +``` |
| 83 | + |
| 84 | +## Credits |
| 85 | + |
| 86 | +Endpoint map cross-referenced from [`twikit`](https://github.com/d60/twikit) |
| 87 | +and [`twitter-scraper`](https://github.com/the-convocation/twitter-scraper), |
| 88 | +both MIT. Reference layout inspired by |
| 89 | +[`atlas-cli`](https://github.com/lroolle/atlas-cli) and |
| 90 | +[`gh`](https://github.com/cli/cli). `XActions` is a reference only; no code |
| 91 | +was copied (BSL-1.1). |
0 commit comments