
xfetch
Fetch and export public X (Twitter) data with a self-contained Python CLI (twikit; no API keys, uses the user's own login cookies): profiles, a user's tweets/replies/likes, threads, search, followers, timelines, JSON/JSONL/CSV/SQLite output, resumable pagination. Use to scrape, archive, monitor, or analyze tweets or accounts.
- Installs
- 266
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/agents365-ai/365-skills --skill xfetch- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads xfetch automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
xfetch
Fetch public data from X (Twitter) — profiles, tweets, threads, search, followers — using the user's own login cookies instead of the paid developer API. This skill ships a single self-contained CLI, scripts/xfetch.py, that calls X's GraphQL API directly and emits structured data an agent can parse.
How it stays working (the architecture that matters): the hard part of X scraping is that X constantly changes its site — it rotates GraphQL query IDs every few weeks, migrates endpoints between GET and POST, and reshapes response JSON. This CLI splits those concerns so a break in one place doesn't take everything down:
- It reuses the current query IDs and feature flags shipped by the twikit package (kept fresh with
pip install -U twikit) — so you don't hand-maintain the fastest-rotating values. - It does its own HTTP requests and JSON parsing, which sidesteps the two things most likely to be broken in twikit at any moment: (1) its homepage-scraped anti-bot transaction ID — this CLI sends a harmless placeholder
x-client-transaction-id, which X accepts for read endpoints; and (2) its response-model layer — this CLI parses the raw JSON itself. It also auto-falls-back GET↔POST on a 404, so an endpoint X migrates keeps working.
Net: if a command suddenly errors for everyone, the first fix is still pip install -U twikit (refreshes query IDs). If that doesn't help, X changed a response shape — check the parser in scripts/xfetch.py.
The agent-native contract
scripts/xfetch.py is built so you can drive it in a loop without surprises. Rely on these three channels rather than scraping prose:
stdoutcarries the data payload only (JSON by default). Redirect or pipe it — nothing else is written there.stderrcarries human status (✓ Saved…) and errors. Read it to diagnose; ignore it when parsing.- exit code is the truth signal:
0= success,1= error,2= not authenticated,3= rate limited (stderr carriesrate_limit_reset=<epoch>),64= usage error (bad flag or argument — fix the command, don't re-auth). Branch on the exit code, not on stderr text.
Setup (once per environment)
-
Confirm Python and install twikit (a virtualenv is cleanest so you don't touch system packages):
python3 -m pip install -r scripts/requirements.txt # installs twikit>=2.3.3 -
Verify the CLI loads:
python3 scripts/xfetch.py --version # -> xfetch-skill 0.3
Invoke every command as python3 scripts/xfetch.py <command> … using this skill's own copy of the script.
Authenticate first — this is the #1 failure mode
Every data command needs the user's X cookies (auth_token + ct0). Without them the command prints Not authenticated. to stderr and exits 2. Auth is delegated: the human sets it up once, the CLI saves a session to ~/.config/xfetch/cookies.json, and you reuse it — you don't own the credential lifecycle, you just check it's present.
Always run this first and branch on the exit code:
python3 scripts/xfetch.py auth check
If it isn't authenticated, get the human to provide credentials, in order of preference:
-
Extract from a logged-in browser (most convenient — reads the x.com cookies straight from the browser's store, no copy/paste):
python3 scripts/xfetch.py auth extract --browser chrome # supported: chrome, chromium, firefox, safari, edge, brave, arc, opera, vivaldi, librewolfRequires
browser_cookie3(inrequirements.txt). On macOS this may prompt for Keychain access — that's the OS handing over the cookie-decryption key, which is expected. -
Import a cookies file (best for browsers without a reader — e.g. ChatGPT Atlas, Orion, or any Chromium fork): export cookies with a "Get cookies.txt" browser extension (Netscape
cookies.txtor JSON both work), then point the CLI at the file — it extractsauth_token+ct0for you:python3 scripts/xfetch.py auth import --file ~/Downloads/x.com_cookies.txt -
Paste cookie tokens (works for any browser): open DevTools → Application → Cookies →
https://x.com, copy theauth_tokenandct0values, then:python3 scripts/xfetch.py auth set --auth-token <token> --ct0 <token> -
Environment variables (good for CI / one-off, saves nothing to disk):
XFETCH_AUTH_TOKEN=<token> XFETCH_CT0=<token> python3 scripts/xfetch.py user @handle -
Username/password login (twikit performs a real login; may trip a captcha or 2FA — pass
--totpfor TOTP-based 2FA):python3 scripts/xfetch.py auth login --username <user> --password <pass>
Never invent or guess cookie values. Prefer auth set/env over login so no password passes through the command line. If auth is missing and you can't obtain it, stop and ask the human — you cannot proceed without it. These read a real account, so its login is a shared, rate-limited resource: don't hammer it.
Choose the output format for the consumer
The default json is pretty-printed for a human reading one result. For anything you or a pipeline will parse, pick deliberately with --format:
| Format | Flag | Use when |
|---|---|---|
| JSON (pretty) | (default) | Inspecting a single object or a small result |
| JSONL | --format jsonl | Large / multi-page results — one record per line, appendable, stream-friendly |
| CSV | --format csv | Spreadsheets or quick tabular analysis (nested fields are JSON-encoded in-cell) |
| SQLite | --format sqlite --db out.db | Building a queryable dataset; rows go to a tweets/users table, a summary prints to stderr |
Add --plain for compact single-line JSON. Save to a file by redirecting stdout, e.g. … --format jsonl > tweets.jsonl.
Commands
# Profile (by @handle or numeric id)
python3 scripts/xfetch.py user @elonmusk
# A user's tweets (--replies for replies, --media for media-only)
python3 scripts/xfetch.py tweets @elonmusk -n 50
python3 scripts/xfetch.py tweets @elonmusk --replies --all --format jsonl > timeline.jsonl
# A user's liked tweets
python3 scripts/xfetch.py likes @handle -n 40
# Single tweet, and a tweet with its replies (thread)
python3 scripts/xfetch.py tweet https://x.com/user/status/1234567890
python3 scripts/xfetch.py thread 1234567890
# Search (--type top|latest|media)
python3 scripts/xfetch.py search "AI agents" -n 100 --type latest
python3 scripts/xfetch.py search "from:openai since:2024-01-01" --all --format csv > openai.csv
# Followers / following, paginated into a SQLite dataset
python3 scripts/xfetch.py followers @handle --all --format sqlite --db network.db
python3 scripts/xfetch.py following @handle -n 100
# Your own timelines (uses the logged-in account)
python3 scripts/xfetch.py home # "For You"
python3 scripts/xfetch.py home --following # chronological
python3 scripts/xfetch.py bookmarks -n 50
search supports X's advanced operators (from:, to:, since:, until:, filter:, min_faves:, etc.) — pass them inside the quoted query. For the full flag reference and the exact fields each command returns, read references/commands.md.
DMs, lists, and trends are not exposed as commands (to keep this CLI small), but twikit supports them (get_dm_history, get_list_tweets, get_trends) — add a command following the existing pattern in scripts/xfetch.py if the user needs one.
Pagination and rate limits
Listing commands (tweets, search, followers, following, likes, home, bookmarks) share these flags — single page by default, opt into more:
-n 40 # results per page
--all # every page until exhausted
--max-pages 10 # cap the pages
--cursor <c> # start from a specific pagination cursor
--delay 1.5 # seconds between pages (default 1.0 — keep it >0 for --all)
When more pages remain — or a pull is interrupted or rate limited mid-way — the CLI prints next_cursor=<value> to stderr. Capture it and pass it back via --cursor to resume exactly where the pull stopped instead of refetching from the top.
X enforces per-account rate limits (roughly a few hundred requests per 15-minute window per endpoint) and this uses the user's real account. For bulk pulls keep a real --delay, prefer --max-pages over --all when you only need a sample, and remember aggressive scraping can get the account throttled or flagged. Route through a proxy for heavier work with --proxy http://user:pass@host:port.
When something fails
Check the exit code, then read stderr to classify:
- exit 2 /
Not authenticated→ run the auth flow above. - exit 64 / usage error → the command line itself is wrong (unknown flag, bad value). Fix the invocation — do not re-run auth.
- exit 3 / rate limited → stderr carries
rate_limit_reset=<epoch>; wait until then, raise--delay, and resume from thenext_cursor=value printed on stderr. - exit 1 with a GraphQL / parsing error that started suddenly for everyone → X likely changed its site. Upgrade twikit (
pip install -U twikit) and retry. - Timeout / network errors mid-pull → resume from the
next_cursor=line on stderr instead of refetching from the top. - Empty result → the account may be private (you only see what the logged-in account can), suspended, or the handle is wrong.
Scope and good-citizen notes
This reads public data plus whatever the logged-in account can see (its own home, bookmarks, likes). It does not post, like, follow, or modify anything — it's read-only by design. Because it uses the user's own session, the user is responsible for staying within X's Terms of Service and rate limits. Use it for legitimate purposes — research, personal archiving, monitoring accounts the user is entitled to read — not for harassment, mass surveillance, or evading a block. Session cookies live under ~/.config/xfetch/; clear them with auth clear.
FAQ
What does the xfetch skill do?
Fetch and export public X (Twitter) data with a self-contained Python CLI (twikit; no API keys, uses the user's own login cookies): profiles, a user's tweets/replies/likes, threads, search, followers, timelines, JSON/JSONL/CSV/SQLite output, resumable pagination. Use to scrape, archive, monitor, or analyze tweets or accounts.
How do I install xfetch?
Run npx skills add https://github.com/agents365-ai/365-skills --skill xfetch in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/xfetch/ (personal) or .claude/skills/xfetch/ (project).
Which AI agents can use xfetch?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is xfetch safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains xfetch?
It is published by agents365-ai in agents365-ai/365-skills. It has 266 recorded installs.
More from agents365-ai/365-skills
drawio-skill
agents365-ai/365-skills
Create, edit, synchronize, inspect, test, and publish editable draw.io diagrams. Use when the user explicitly requests draw.io/diagrams.net, needs a polished architecture, ERD, UML, sequence, C4, SysML, BPMN, network, swimlane, ML, or infrastructure diagram, wants code/IaC/SQL/OpenAPI/AsyncAPI/Protobuf converted into a diagram, or wants an existing diagram queried, reviewed, diffed, restyled, kept in sync, or made interactive. Prefer Mermaid/PlantUML elsewhere when the requested artifact is diagrams-as-code rather than an editable draw.io file.
excalidraw
agents365-ai/365-skills
Use when user requests diagrams, flowcharts, architecture charts, or visualizations. Also use proactively when explaining systems with 3+ components, complex data flows, or relationships that benefit from visual representation. Generates .excalidraw files and exports to PNG/SVG via Kroki API or locally using excalidraw-brute-export-cli.
creating-mermaid-diagrams
agents365-ai/365-skills
Generate Mermaid diagrams (.mmd) and export to PNG/SVG/PDF using mmdc CLI or Kroki API. USE THIS SKILL when user mentions diagram, flowchart, sequence diagram, class diagram, ER diagram, state machine, architecture, visualize, git graph, 画图, 架构图, 流程图, 时序图. PROACTIVELY USE when explaining ANY system with 3+ components, API flows, authentication sequences, class hierarchies, database schemas, or state machines. Supports 11+ diagram types with fully automatic layout.
plantuml-skill
agents365-ai/365-skills
Use when user requests diagrams, flowcharts, sequence diagrams, class diagrams, component diagrams, ER diagrams, architecture charts, or visualizations — including generating a diagram from existing source code, or rendering/extracting PlantUML embedded in a Markdown file to images (e.g. preparing docs for Confluence/Notion). Also use proactively when explaining systems with 3+ components, APIs, data flows, or class hierarchies. Generates .puml files and exports to PNG/SVG via Kroki API (no local install required).
tldraw-skill
agents365-ai/365-skills
Use when user requests diagrams, flowcharts, architecture charts, or visualizations. Also use proactively when explaining systems with 3+ components, complex data flows, or relationships that benefit from visual representation. Generates .tldr JSON files and exports to PNG/SVG locally using @kitschpatrol/tldraw-cli.
paper-fetch
agents365-ai/365-skills
Use whenever the user wants to obtain, download, or fetch a paper's PDF — given a DOI, an arXiv id, a paper title, a citation, or a list of DOIs. Trigger on phrases like "download this paper", "find the PDF for [DOI]", "grab me the [Nature/bioRxiv/arXiv] paper on X", "get the open-access version", "I need this article", or any bulk/batch paper download request, even when the user doesn't explicitly say "PDF" or "DOI". Resolves via Unpaywall → Semantic Scholar → arXiv → PubMed Central → bioRxiv/medRxiv → publisher direct (institutional opt-in) → Sci-Hub mirrors as last-resort fallback.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.