소개
Twitter/X CLI without API keys. xsh is a command-line interface for Twitter/X that works with cookie-based authentication. No developer account, no API keys, no rate limit headaches. Just log in with your browser and go.
보안 및 개인정보 보호What you can do
- Browser-cookie authentication; no API key is needed
- An MCP server for Claude, Cursor, and other MCP clients
- Multiple accounts, with commands to switch between them
- JSON, YAML, and compact output for scripts and agents
측정된 스타 증가
- in 24h
- 기록 수집 중
- in 7 days
- 기록 수집 중
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalxsh Twitter/X CLI
A command-line interface for Twitter/X, written in Go. xsh uses cookies from your browser session, so you do not need an API key.

Table of Contents
- Features
- Installation
- Quick Start
- Authentication
- Commands
- Output Formats
- MCP Server
- Configuration
- Endpoint Management
- Diagnostics & Status
- Development
- Security
Features
- Browser-cookie authentication; no API key is needed
- An MCP server for Claude, Cursor, and other MCP clients
- Multiple accounts, with commands to switch between them
- JSON, YAML, and compact output for scripts and agents
- GraphQL endpoint discovery from authenticated X.com bundles
- Tweet publishing with up to four images, plus media downloads
- Commands for tweets, DMs, lists, bookmarks, jobs, trends, scheduled posts, and relationships
- Community browsing with cursor-based pagination
- Note Tweet publishing from text or a file, with explicit confirmation
- Fallbacks for stale X operations; quote search uses
SearchTimeline
Installation
Using go install (Recommended)
Requires Go 1.24+:
go install github.com/benoitpetit/xsh@latest
Using Install Script
Linux/macOS:
curl -fsSL https://xsh.devbyben.fr/install | bash
Windows (PowerShell as Administrator):
iwr -useb https://xsh.devbyben.fr/install | iex
Pre-built Binaries
Download from Releases:
# Linux (amd64)
curl -L https://github.com/benoitpetit/xsh/releases/latest/download/xsh-linux-amd64 -o xsh && \
chmod +x xsh && \
sudo mv xsh /usr/local/bin/
To update an installed release binary:
xsh update --check # Check the latest compatible stable release
xsh update # Download, verify SHA-256, and install it
The updater selects the binary for your OS and architecture. It needs write
access to the installed executable; installations in protected directories may
require running xsh update with elevated privileges. xsh auto-update is a
separate command that refreshes X GraphQL endpoint IDs.
From Source
git clone https://github.com/benoitpetit/xsh
cd xsh
go build -o xsh .
sudo mv xsh /usr/local/bin/
Quick Start
# 1. Authenticate (extracts cookies from your browser)
xsh auth login
# 2. View your timeline
xsh feed
# 3. Post a tweet
xsh tweet post "Hello from xsh!"
# 4. Search tweets
xsh search "golang" --pages 2
# 5. View a user profile
xsh user elonmusk
Authentication
Automatic Browser Extraction
# Auto-detect browser (Chrome, Firefox, Brave, Edge, Chromium)
xsh auth login
# Target a specific browser
xsh auth login --browser firefox
xsh auth login --browser brave
# Pass the cookie database path when browser auto-detection misses it
xsh auth login --browser chrome --cookie-path "$HOME/Library/Application Support/Google/Chrome/Default/Network/Cookies"
# Save under a named account
xsh auth login --account work
Manual / Import
# Import from Cookie Editor JSON export
xsh auth import cookies.json
xsh auth import cookies.json --account work
# Set credentials manually
xsh auth set
# Check authentication status
xsh auth status
# Show current user info
xsh auth whoami
# List all stored accounts
xsh auth accounts
# Switch default account
xsh auth switch work
# Remove stored credentials
xsh auth logout
Shortcuts
xsh accounts,xsh switch <name>, andxsh import <file>are also available at root level.
Commands
Global Flags
These flags apply to every command:
| Flag | Short | Description |
|---|---|---|
--account <name> |
Use a specific stored account | |
--json |
Output as JSON | |
--yaml |
Output as YAML | |
--compact |
-c |
Compact output for AI agents |
--verbose |
-v |
Show HTTP requests (debug) |
--watch <seconds> |
-w |
Refresh output periodically |
Tweet Operations
# View a tweet (with optional thread tree)
xsh tweet view <id>
xsh tweet view <id> --thread
xsh tweet view <id> --count 50
xsh tweet get <id> # Fetch the tweet without its thread
xsh tweet view <id> --export article.json --export-format json
# Post a tweet
xsh tweet post "Hello world!"
# Publish a long-form Note Tweet (confirmation required)
xsh tweet note --file essay.txt
xsh tweet post "With image" --image photo.jpg
xsh tweet post "Multiple images" -i img1.jpg -i img2.jpg -i img3.jpg
xsh tweet post "Reply" --reply-to <tweet-id>
xsh tweet post "Quote" --quote https://x.com/user/status/<id>
# Delete your tweet
xsh tweet delete <id>
# Like / unlike
xsh tweet like <id>
xsh tweet unlike <id>
# Retweet / undo
xsh tweet retweet <id>
xsh tweet unretweet <id>
# Bookmark / remove
xsh tweet bookmark <id>
xsh tweet unbookmark <id>
Shortcuts are also available at the root level:
xsh unlike <id>
xsh unretweet <id>
xsh unbookmark <id>
Timeline & Search
# Home timeline
xsh feed
xsh feed --type following # Following timeline
xsh feed --count 50 --pages 3 # 150 tweets total
xsh feed --filter top --top 20 # Top 20 by engagement
xsh feed --filter score --threshold 100
xsh feed --cursor <cursor> # Paginate
xsh feed --page-json --json # Include next_cursor and has_more
# Search
xsh search "golang"
xsh search "golang" --type Latest # Types: Top, Latest, Photos, Videos
xsh search "golang" --count 50 --pages 2
xsh search "golang" --cursor <cursor>
xsh search "golang" --page-json --json # Include next_cursor and has_more
Users
# View profile
xsh user <handle>
# User's tweets
xsh user tweets <handle>
xsh user tweets <handle> --replies # Include replies
xsh user tweets <handle> --count 50
# User's reposts
xsh user reposts <handle>
xsh user reposts <handle> --count 50 --cursor <cursor>
# Liked tweets
xsh user likes <handle> --count 30
# Followers / following
xsh user followers <handle> --count 50
xsh user following <handle> --count 50
xsh user followers <handle> --cursor <cursor>
# Media and relationship discovery
xsh user media <handle> --count 50
xsh user followers-you-know <handle> --count 50
xsh user blue-verified-followers <handle> --count 50
xsh user media <handle> --json --cursor <cursor>
Communities
# Discover communities and fetch another page from its cursor
xsh community explore --count 20
xsh community explore --json --cursor <cursor>
# Inspect a community, read its tweets, or join/leave it
xsh community view <community-id>
xsh community tweets <community-id>
xsh community join <community-id>
Social Actions
# Follow / unfollow
xsh follow <handle>
xsh unfollow <handle>
# Block / unblock
xsh block <handle>
xsh unblock <handle>
# Mute / unmute
xsh mute <handle>
xsh unmute <handle>
# Read relationship lists
xsh social blocked --count 50
xsh social muted --count 50
xsh social blocked --json --cursor <cursor>
Bookmarks
# View all bookmarks
xsh bookmarks
xsh bookmarks --count 50
# List bookmark folders
xsh bookmarks-folders
# View tweets in a specific folder
xsh bookmarks-folder <folder-id>
Direct Messages
# View inbox
xsh dm inbox
# Send a DM
xsh dm send <handle> "Your message"
# Delete a DM message
xsh dm delete <message-id>
Lists
# View all your lists
xsh lists
# Read list metadata and memberships
xsh lists info <list-id>
xsh lists memberships
# View tweets from a list
xsh lists view <list-id>
xsh lists view <list-id> --count 50
xsh lists view <list-id> --json --cursor <cursor>
# Create / delete a list
xsh lists create "List name"
xsh lists delete <list-id>
# Manage members
xsh lists members <list-id>
xsh lists members <list-id> --cursor <cursor>
xsh lists memberships --json --cursor <cursor>
xsh lists add-member <list-id> <handle>
xsh lists remove-member <list-id> <handle>
# Pin / unpin
xsh lists pin <list-id>
xsh lists unpin <list-id>
# Update metadata (requires confirmation; JSON requires --force)
xsh lists update <list-id> --name "New name"
xsh lists update <list-id> --private=false --force --json
Scheduled Tweets
# Schedule a tweet
xsh schedule "My future tweet" --at "2026-04-01 09:00"
# List scheduled tweets
xsh scheduled
# Cancel a scheduled tweet
xsh unschedule <scheduled-tweet-id>
Trends
# Worldwide trends
xsh trends
# By location name
xsh trends --location "Paris"
xsh trends --location "France"
# By WOEID
xsh trends --woeid 1 # Worldwide
xsh trends --woeid 615702 # Paris
Jobs
# Search job listings
xsh jobs search "software engineer"
xsh jobs search "data engineer" --location "Paris"
xsh jobs search "devops" --location-type remote
xsh jobs search "backend" --employment-type full_time
xsh jobs search "intern" --seniority entry_level
xsh jobs search "manager" --company Google --pages 2
# Available filters:
# --location <city/country>
# --location-type remote | onsite | hybrid
# --employment-type full_time | part_time | contract | internship
# --seniority entry_level | mid_level | senior
# --company <name>
# --industry <sector>
# --count <n> (default 25)
# --pages <n> (default 1)
# View job details
xsh jobs view <job-id>
Media Download
# Download all media from a tweet
xsh download <tweet-id>
xsh download <tweet-id> --output-dir ./media
Compose Thread
# Interactive mode (prompts for each tweet)
xsh compose
# From a text file (auto-splits into thread)
xsh compose --file thread.txt
# From stdin
cat thread.txt | xsh compose
# Preview without posting
xsh compose --file thread.txt --dry-run
Export
Export tweets as json, jsonl, csv, tsv, or md files.
# Export timeline
xsh export feed --format csv --output timeline.csv
xsh export feed --format jsonl --output tweets.jsonl --count 200
xsh export feed --type following --filter top
# Export search results
xsh export search "golang" --format md --output results.md
# Export bookmarks
xsh export bookmarks --format json --output bookmarks.json
# Write to stdout
xsh export feed --format jsonl --output -
Batch Operations
# Fetch multiple tweets by ID
xsh tweets <id1> <id2> <id3>
# Fetch multiple user profiles
xsh users <handle1> <handle2> <handle3>
# Fetch multiple profiles by numeric user ID
xsh users --id 44196397 --id 783214
Character Count
# Count characters in text
xsh count "My tweet draft"
# From a file
xsh count --file draft.txt
# From stdin
echo "My tweet" | xsh count
# Show formatted preview
xsh count "My tweet" --preview
xsh count --file draft.txt --preview --width 80
Read/write safety
Read commands are safe to exercise against a connected account. Commands that
publish, send, follow, block, mute, bookmark, schedule, delete, or update data
change remote state. lists update requires at least one explicit field and a
human confirmation; in JSON mode it also requires --force. tweet note
accepts text or --file, validates the 25,000-character limit, and uses the
same confirmation rule. Never use --force in an automated smoke test unless
the remote mutation is intentional.
Output Formats
All commands support structured output for scripting and AI integration:
# JSON
xsh feed --json
xsh user elonmusk --json
# YAML
xsh search "golang" --yaml
# Compact (essential fields only, ideal for AI agents)
xsh feed --compact
# Pipe auto-detection: JSON is used automatically when stdout is not a TTY
xsh feed | jq '.[].text'
# Cursor-enabled user/list commands expose an envelope
xsh user tweets ben | jq '.items[] | .text'
# Cursor-based commands return an envelope in structured modes:
# {"items": [...], "next_cursor": "...", "has_more": true}
# Pass next_cursor back with --cursor to fetch the next page.
# feed and search keep their historical flat output by default; add --page-json
# to include the pagination envelope in JSON, YAML, or compact output.
# Compact JSON is one line, suitable for pipes and agents
xsh user followers ben --compact | jq -c .
# Use a specific account
xsh feed --account work
MCP Server
xsh can run as a Model Context Protocol server for clients such as Claude Desktop and Cursor.
xsh mcp
Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"xsh": {
"command": "xsh",
"args": ["mcp"]
}
}
}
Available MCP Tools
| Category | Tools |
|---|---|
| Timeline | get_feed, get_home_latest_timeline |
| Search | search, search_bookmarks |
| Tweets | get_tweet, get_tweet_thread, post_tweet, delete_tweet, get_tweets_batch |
| Engagement | like, unlike, retweet, unretweet, bookmark, unbookmark |
| Users | get_user, get_users_batch, get_user_tweets, get_user_likes, get_user_media, get_followers, get_following, get_followers_you_know, get_blue_verified_followers |
| Relationships | get_blocked_accounts, get_muted_accounts |
| Social | follow, unfollow, block, unblock, mute, unmute |
| Bookmarks | list_bookmarks, get_bookmark_folders, get_bookmark_folder |
| Lists | get_user_lists, get_list_info, get_list_memberships, get_list_timeline, get_list_members, create_list, delete_list, add_list_member, remove_list_member, pin_list, unpin_list |
| DMs | dm_inbox, send_dm, delete_dm |
| Scheduled | schedule_tweet, get_scheduled_tweets, delete_scheduled_tweet |
| Trends | get_trending |
| Jobs | search_jobs, get_job |
| Media | download_media, upload_media |
| Compose | compose_thread |
| Utils | count_characters, export_tweets |
| Endpoints | get_endpoints, refresh_endpoints |
Configuration
Authentication and local storage
xsh resolves credentials in this order: explicit environment variables
(X_AUTH_TOKEN/X_CT0, then legacy TWITTER_AUTH_TOKEN/TWITTER_CT0), the
selected --account, the configured default account, and finally browser
extraction. Use XSH_CONFIG_DIR to select an isolated configuration root;
otherwise xsh follows the platform XDG/OS configuration directory.
Credentials and caches are written with private directory/file permissions and
atomic replacement. If a JSON file is corrupted, xsh preserves it as a .bak
file before returning the error. Remove or restore that backup only after
inspection.
Endpoint cache and discovery
Endpoint snapshots have size limits and a schema version. Discovery fetches an authenticated homepage (10 MiB limit) and JavaScript bundles (5 MiB limit), follows imports with a bounded worker pool, and merges duplicate operations in bundle priority order. xsh retries stale endpoints only for safe reads. It does not replay write operations automatically. An operation in quarantine stays there until discovery finds a replacement endpoint.
Output and cancellation
--json, --yaml, and --compact are mutually exclusive. Structured output
is emitted on stdout, diagnostics on stderr, and credentials are redacted.
Long-running commands honor context cancellation and stop their refresh,
stream, and watch loops without writing partial machine-readable records.
Configuration is stored below the platform user configuration directory, or
under the directory selected by XSH_CONFIG_DIR. Use xsh config path to
display the exact file path on the current system:
# Show current configuration
xsh config
xsh config show
# Get a specific value
xsh config get filter.likes_weight
# Set a value
xsh config set display.theme dark
xsh config set request.timeout 60
# Open in editor
xsh config edit
# Show config file path
xsh config path
# Reset to defaults
xsh config reset
Example config.toml
default_count = 20
[display]
theme = "default"
show_engagement = true
show_timestamps = true
max_width = 100
[request]
delay = 1.5
timeout = 30
max_retries = 3
[filter]
likes_weight = 1.0
retweets_weight = 1.5
replies_weight = 0.5
bookmarks_weight = 2.0
views_log_weight = 0.3
min_score = 0
request.delay controls the delay after read requests. Keep the default
1.5 for normal interactive use; set it to 0 for an explicitly fast local
workflow. request.timeout controls the HTTP client timeout in seconds.
Platform compatibility
The published Linux, Windows, and macOS binaries are built with CGO_ENABLED=0
and include the portable Chromium/Firefox cookie-database readers. Browser
profiles are discovered in the platform's standard locations, including
common Snap and Flatpak layouts on Linux. Chromium-based browsers may still
require access to the operating-system key store to decrypt protected cookies;
when that store is unavailable, xsh reports the affected authentication cookie
instead of silently using incomplete credentials.
Endpoint Management
xsh discovers GraphQL operation IDs from the authenticated X.com web client and caches them locally. Discovery uses stored session cookies, follows nested Vite/Rollup chunks, and reads persisted GraphQL URLs built at runtime.
# List all cached endpoints
xsh endpoints list
# Check status of a specific endpoint
xsh endpoints check HomeTimeline
# Refresh endpoints from the authenticated X.com session
xsh endpoints refresh
# Show endpoint system status
xsh endpoints status
# Manually update a single endpoint
xsh endpoints update <operation> <endpoint-id>
# Reset all endpoints to bundled defaults
xsh endpoints reset
# Auto-update obsolete endpoints (requires an authenticated session)
xsh auto-update
xsh auto-update --dry-run # Check only, don't update
xsh auto-update --force # Force refresh (ignore cache)
endpoints status reports whether the dynamic cache is available and how many
operations were quarantined after a confirmed 404. If discovery is unavailable,
xsh keeps the last valid cache and uses static IDs only when a verified fallback
exists. It refreshes a stale operation once and quarantines a confirmed 404 to
avoid repeated discovery requests.
Discovery refuses a logged-out x-web shell and never treats the public shell
as an authenticated endpoint source. If refresh fails with an authentication
or shell error, log in again and retry:
xsh auth status
xsh endpoints refresh --verbose
An operation can remain in the inventory after X stops serving it. TweetQuotes
returns 404, so xsh quotes uses SearchTimeline. CommunitiesMainPageTimeline
is tracked as a candidate but is not exposed as a discovery command until X
serves it again. In the latest live check, Followers was discovered but
returned 404 and was quarantined. Following and FollowersYouKnow are separate
operations; neither provides the Followers list.
Diagnostics & Status
# System status: auth, endpoints, cache health
xsh status
xsh status --check # Validate cached endpoint metadata and required operations
xsh status --local # Skip connectivity and endpoint checks; use local state only
xsh status --json
# Full diagnostic report
xsh doctor
# Print version
xsh version
Development
# Clone
git clone https://github.com/benoitpetit/xsh
cd xsh
# Build
go build -o xsh .
# Run the complete test suite
go test ./...
# Build with version info
make build VERSION=v0.1.0
Project Structure
core/
├── main.go # Entry point
├── cmd/ # Cobra CLI commands
├── core/ # API client, auth, config, endpoints
├── models/ # Tweet, User, DM, etc.
├── display/ # Terminal formatters
├── utils/ # Helpers (filter, validation, article, delay, hash)
├── browser/ # Browser cookie extraction
└── tests/ # Integration tests
Requirements
- Go 1.24+
- A Twitter/X account
- A supported browser (for cookie extraction)
Security
xsh is an independent open-source client, not a hosted service. It reuses your own browser session (cookies read locally) and only accesses what that account can already see in a browser. It is not affiliated with or endorsed by X; review X's Terms of Service before using any third-party client.
For the full data disclosure — what the CLI and the website touch, and what they do not — see https://xsh.devbyben.fr/privacy.
- Credentials stored locally with
0600permissions - No data sent to third parties — direct API calls to X/Twitter only
- TLS fingerprinting (uTLS) so requests look like the browser client they come from
- Cookie values sanitized per RFC 6265 before use
Relay and failover
GitHub is the source of truth and the primary distribution; the automatic git.gay relay is the fallback:
- Git mirror:
https://git.gay/starbyte/xsh(all branches and tags, updated on every push). - Releases: binaries, archives and
checksums.txtmirrored onhttps://git.gay/starbyte/xsh/releases. - Website relay:
https://starbyte.pages.gay/xsh_website/, including a rawinstallscript at its root. - Go module:
go install github.com/benoitpetit/xsh@latest.
Installers and xsh update try GitHub first and fall back to git.gay when GitHub fails. SHA-256 of every downloaded binary is checked against checksums.txt before installation. If git.gay disappears, no command above changes; if GitHub disappears, the git.gay mirror keeps serving the code and binaries it has already synced.
git.gay states that you are responsible for your own backups; the relay protects against GitHub being closed, not against the relay itself becoming unavailable.
About
xsh is a Go reimplementation of the original clix Python project. It focuses on performance, reliability, and modern Go practices.
License
Made with ❤️ and Go
관련 프로젝트 살펴보기
불러오는 중…