Catalog
JimLiu/baoyu-danger-x-to-markdown

JimLiu

baoyu-danger-x-to-markdown

Converts X (Twitter) tweets and articles to markdown with YAML front matter. Uses reverse-engineered API requiring user consent. Use when user mentions "X to markdown", "tweet to markdown", "save tweet", or provides x.com/twitter.com URLs for conversion.

NewUpdated Nov 3, 2026

X to Markdown

Tweets/threads → markdown with YAML front matter; X Articles → full content.

User Input Tools

When this skill prompts the user, follow this tool-selection rule (priority order):

  1. Prefer built-in user-input tools exposed by the current agent runtime — e.g., AskUserQuestion, request_user_input, clarify, ask_user, or any equivalent.
  2. Fallback: if no such tool exists, emit a numbered plain-text message and ask the user to reply with the chosen number/answer for each question.
  3. Batching: if the tool supports multiple questions per call, combine all applicable questions into a single call; if only single-question, ask them one at a time in priority order.

Concrete AskUserQuestion references below are examples — substitute the local equivalent in other runtimes.

Script Directory

  1. {baseDir} = this SKILL.md's directory; script = {baseDir}/scripts/main.ts
  2. ${BUN_X} = bun if installed; else npx -y bun if npx available; else suggest installing bun
  1. Read the consent file:
    • macOS: ~/Library/Application\ Support/baoyu-skills/x-to-markdown/consent.json
    • Linux: ~/.local/share/baoyu-skills/x-to-markdown/consent.json
  2. accepted: true and disclaimerVersion: "1.0" → print Warning: Using reverse-engineered X API. Accepted on: <acceptedAt> and proceed.
  3. Missing or version mismatch → show this disclaimer and ask "Yes, I accept" | "No, I decline":
    DISCLAIMER
    
    This tool uses a reverse-engineered X API, NOT official.
    
    Risks:
    - May break if X changes API
    - No guarantees or support
    - Possible account restrictions
    - Use at your own risk
    
    Accept terms and continue?
    
  4. Accept → write the consent file:
    {
      "version": 1,
      "accepted": true,
      "acceptedAt": "<ISO timestamp>",
      "disclaimerVersion": "1.0"
    }
    
  5. Decline → output "User declined. Exiting." and stop.

Preferences (EXTEND.md)

First one found wins:

Priority Path Scope
1 .baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md Project
2 ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md XDG
3 $HOME/.baoyu-skills/baoyu-danger-x-to-markdown/EXTEND.md User home

Found → read and apply. Not found → BLOCKING first-time setup: ask the questions in references/config/first-time-setup.md (Media, Output, Save — all in one call) before any conversion, write EXTEND.md at the chosen location, confirm "Preferences saved to [path]", then continue. Never create EXTEND.md with defaults without asking.

Key Default Values
download_media ask ask (prompt each time) / 1 (always) / 0 (never)
default_output_dir empty (= ./x-to-markdown/) path or empty

Value priority: CLI arguments (--download-media, -o) → EXTEND.md → skill defaults.

Usage

${BUN_X} {baseDir}/scripts/main.ts <url>
${BUN_X} {baseDir}/scripts/main.ts <url> -o output.md
${BUN_X} {baseDir}/scripts/main.ts <url> --download-media
${BUN_X} {baseDir}/scripts/main.ts <url> --json
Option Description
<url> Tweet or article URL
-o <path> Output path
--json JSON output
--download-media Download images/videos to local imgs/ and videos/ next to the markdown, rewrite links to local relative paths
--login Refresh cookies only

Supported URLs: https://x.com/<user>/status/<id>, https://twitter.com/<user>/status/<id>, https://x.com/i/article/<id>

Output

---
url: "https://x.com/user/status/123"
author: "Name (@user)"
tweetCount: 3
coverImage: "https://pbs.twimg.com/media/example.jpg"
---

Content...

File structure: x-to-markdown/{username}/{tweet-id}/{content-slug}.md

Media Download

By EXTEND.md download_media: 1 → run with --download-media; 0 → run without; ask (default):

  1. Run without --download-media → markdown saved
  2. Check it for remote media (https:// image/video links); none → done, no prompt
  3. Otherwise ask (header "Media", question "Download N images/videos to local files?"): "Yes" — download to local directories / "No" — keep remote URLs
  4. Yes → rerun with --download-media (overwrites markdown with localized links)

Authentication

  1. Environment variables (preferred): X_AUTH_TOKEN, X_CT0
  2. Chrome login (fallback): auto-opens Chrome, caches cookies locally

Extension Support

Custom configurations via EXTEND.md — see Preferences above.

Files20
20 files · 123.5 KB

Select a file to preview

Overall Score

76/100

Grade

B

Good

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

74

Quality

82

Clarity

75

Completeness

72

Summary

A TypeScript skill that converts X (Twitter) tweets and articles to markdown with YAML front matter using a reverse-engineered X API. The skill reads .env files and environment variables for authentication (X_AUTH_TOKEN, X_CT0), requires explicit user consent before operation, and supports media downloading with local file caching. It implements comprehensive error handling and scope boundaries but accesses credentials and external APIs.

Static Analysis Findings

1 finding

Patterns detected by deterministic static analysis before AI scoring. Hover over any finding code for detailed information and remediation guidance.

Credential Exposure
SEC-020Direct .env File Access19x in 4 files

Direct .env file access

scripts/http.ts.env2x
scripts/graphql.ts.env6x
scripts/cookies.ts.env4x

Detected Capabilities

environment variable read (X_AUTH_TOKEN, X_CT0, X_USER_AGENT, X_BEARER_TOKEN)file read (.env, cookie files, consent files)file write (markdown, media, cookies, consent)HTTP requests (X API, media downloads)Chrome DevTools Protocol integration (cookie harvesting)directory creation and traversalJSON parsing and generationregular expression matchingprocess execution (execSync for WSL detection)

Trigger Keywords

Phrases that agents use to match this skill to user intent.

x to markdowntweet to markdownsave tweetconvert articletwitter archivex.com urlthread export

Risk Signals

WARNING

SEC-020: Direct .env file access (inferred from buildInlineCookiesFromEnv reading process.env.X_AUTH_TOKEN, X_CT0, X_GUEST_TOKEN, X_TWID)

scripts/cookies.ts:63-74, scripts/http.ts
WARNING

Multiple .env references across cookie loading, HTTP header building, and GraphQL modules indicate pattern of environment variable credential access

scripts/cookies.ts, scripts/http.ts, scripts/graphql.ts, scripts/paths.ts
INFO

Chrome DevTools Protocol integration launches browser to harvest X cookies automatically — this is expected for OAuth-like flows but broadens runtime surface

scripts/cookies.ts:130-175 (fetchXCookiesViaCdp)
INFO

Media download functionality fetches remote URLs and writes to local filesystem — scoped to output directory but could accumulate data

scripts/media-localizer.ts:1-250
INFO

Reverse-engineered API with explicit disclaimer and consent workflow — legitimate use case with user awareness

SKILL.md (Consent Requirement), scripts/main.ts:269-289

Referenced Domains

External domains referenced in skill content, detected by static analysis.

${url.display_url}abs.twimg.comgithub.compbs.twimg.comtwitter.comvideo.twimg.comx.com

Use Cases

  • `X to markdown conversion`
  • Save tweets as markdown
  • Archive articles from X
  • Download tweet threads
  • Extract tweet content locally
  • Convert X articles with media
  • Build tweet archives

Quality Notes

  • ✓ Excellent consent flow: users must accept disclaimer before any API access. Consent state is persisted and validated. Clear documentation of risks (API breakage, account restrictions).
  • ✓ Comprehensive error handling across all modules (cookies, API calls, file I/O, media downloads). Graceful fallback to defaults when features unavailable.
  • ✓ Well-structured configuration system: EXTEND.md preferences with fallback to user home or project scope. First-time setup prompts for media handling and output directory.
  • ✓ Extensive media handling: respects Content-Type headers, falls back to extension detection, handles Twitter video/image URLs specially (high-res URL rewrites), localizes links.
  • ✓ Strong scope boundaries: output directory defaults to ./x-to-markdown/{username}/{tweet-id}/ unless overridden. Media downloads scoped to adjacent imgs/ and videos/ directories.
  • ✓ Support for both tweets and articles with different parsing strategies. Handles threads, quoted tweets, referenced tweets with inline fetches.
  • ✓ Cookie management: prefers env vars, falls back to file cache, then browser-based login via CDP. Does not embed secrets in code.
  • ✗ .env file reading pattern flagged 19 times but context shows this is legitimate: code reads environment variables (not direct .env file access via fs), which is standard practice for passing credentials to CLI tools.
  • ✗ Reverse-engineered API is fragile — skill acknowledges this in disclaimer but conversion may break if X changes endpoints or response format.
  • ✗ Media localization requires downloading external files — potential bandwidth/storage implications if misused.
  • ✗ Browser-based cookie harvesting via Chrome DevTools Protocol requires user interaction and implicit browser launch — could be surprising if user is unaware.
Model: claude-haiku-4-5-20251001Analyzed: Nov 3, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

  1. v1.1

    Content updated

    ✦ AIStreamlines documentation: condenses script path resolution, consent flow, and preferences setup into numbered lists; moves first-time setup questions to separate file reference.

    2026-11-03

    LATEST
  2. v1.0

    2026-07-12

    View This VersionInitial version

Use JimLiu/baoyu-danger-x-to-markdown in your dev environment

Command Palette

Search for a command to run...