login-cdp

Use when user says "login", "登录", "fix expired sessions", "refresh login", or needs to re-authenticate CDP browser sessions for any platform. Auto-detects expired platforms and guides interactive re-login via MCP browser tools. Triggers: "login", "登录", "CDP login", "refresh login", "expired session", "re-authenticate"

10 stars

Best use case

login-cdp is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when user says "login", "登录", "fix expired sessions", "refresh login", or needs to re-authenticate CDP browser sessions for any platform. Auto-detects expired platforms and guides interactive re-login via MCP browser tools. Triggers: "login", "登录", "CDP login", "refresh login", "expired session", "re-authenticate"

Teams using login-cdp should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/login-cdp/SKILL.md --create-dirs "https://raw.githubusercontent.com/dongzhuoyao/tao-research-skills/main/skills/devenv/login-cdp/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/login-cdp/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How login-cdp Compares

Feature / Agentlogin-cdpStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when user says "login", "登录", "fix expired sessions", "refresh login", or needs to re-authenticate CDP browser sessions for any platform. Auto-detects expired platforms and guides interactive re-login via MCP browser tools. Triggers: "login", "登录", "CDP login", "refresh login", "expired session", "re-authenticate"

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# CDP Platform Login

Auto-detect expired CDP browser sessions and re-authenticate interactively via MCP browser tools. Supports multiple CDP ports for multi-account setups.

## When to Use

- Sessions on RedNote, Twitter, LinkedIn, Weibo, etc. have expired and need re-login
- Multi-account CDP setup needs re-authentication on a specific port (9222 vs 9223)
- Chrome MCP / Playwright MCP returns login pages instead of expected content
- User asks to "login", "登录", or "refresh sessions" before running a scraping/posting workflow

## Prerequisites

- Chrome running with `--remote-debugging-port=<port>`
- MCP browser tools available (Playwright MCP or Chrome MCP)

## CDP Port Configuration

Two CDP ports, two independent Chrome instances, each with its own login sessions:

| Port | Account | Session Directory | Purpose |
|------|---------|-------------------|---------|
| 9222 | Account 1 (default) | `$HOME/chrome-debug-v2` | General browsing, Twitter scraping, posting |
| 9223 | Account 2 | `$HOME/chrome-debug2` | RedNote publishing (secondary account) |

Startup commands:
```bash
# Account 1 — CDP 9222 — Session: ~/chrome-debug-v2
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9222 \
  --user-data-dir="$HOME/chrome-debug-v2"

# Account 2 — CDP 9223 — Session: ~/.chrome-cdp/rednote-account2
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9223 \
  --user-data-dir="$HOME/chrome-debug2"
```

Quick check:
```bash
curl -s --noproxy '*' http://127.0.0.1:9222/json/version  # Account 1
curl -s --noproxy '*' http://127.0.0.1:9223/json/version  # Account 2

# Check which Chrome instances are running and their session directories
ps aux | grep "[G]oogle Chrome" | grep -v "Helper\|GPU\|Renderer" | grep -o 'user-data-dir=[^ ]*'
```

## Arguments

| Arg | Default | Description |
|-----|---------|-------------|
| `--port` | `9222` | CDP port to check/fix |
| platform names | `rednote, twitter` | Comma-separated or space-separated platform names |

Examples:
- `/login-cdp` — check rednote + twitter on port 9222
- `/login-cdp twitter` — check only twitter
- `/login-cdp --port 9223 rednote` — check rednote on port 9223

## Flow

### Step 0: Verify CDP is Running

```bash
curl -s --noproxy '*' http://127.0.0.1:<port>/json/version
```

If connection refused → **print the exact Chrome startup command as a fenced bash block for the user to paste into their own terminal**, then STOP. Do NOT try to run it yourself — Chrome must be launched from the user's shell so it stays attached to their session.

Format the output like this (fill in the port/profile that matches the request):

```
CDP <port> is not running. Paste this into your terminal:

​```bash
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=<port> \
  --user-data-dir="$HOME/<profile-dir>"
​```

Then re-run /login-cdp.
```

Port → profile mapping: 9222 → `chrome-debug-v2`, 9223 → `chrome-debug2`.

If CDP is reachable, also check which `--user-data-dir` is being used:
```bash
ps aux | grep "[G]oogle Chrome" | grep -v "Helper\|GPU\|Renderer\|Utility\|Plugin" | grep -o 'user-data-dir=[^ ]*'
```

Report: "CDP <port> running, profile: <user-data-dir>"

### Step 1: Detect Expired Sessions

Check login status by navigating to each platform's check URL.

For each platform:
1. Navigate to the platform's `check_url` via MCP browser tools
2. Take a screenshot or snapshot
3. If redirected to a login page (URL contains "login", "flow/login", or page shows sign-in form) → **expired**
4. If page shows logged-in content (dashboard, feed, profile, account name) → **healthy**
5. **Close the tab immediately** after checking

If all healthy → "All platforms healthy, nothing to do." → STOP.

### Step 2: Present Expired Platforms

```
CDP <port> (<user-data-dir>)

Expired sessions:
  1. RedNote Creator — expired
  2. Twitter/X — expired

Healthy:
  ✓ (none)

Which to fix? (e.g., "1,2" or "all")
```

### Step 3: Sequential Login Loop

For each selected platform:

**a) Open login page** via MCP browser tools.

**b) Notify user:**
- "Opened [platform] login page in Chrome (CDP <port>). Please log in, then say 'done'."
- For QR-code platforms: add "Requires QR code scanning — check your Chrome window."

**c) Wait** for user to say "done", "ok", or "next".

**d) Verify** — navigate to check_url again, confirm logged-in state.

**e) Handle failure** — "Still not logged in. Try again or skip?"

**f) Close tab** — ALWAYS close after each platform.

### Step 4: Summary

```
Login refresh complete (CDP <port>):
  ✓ RedNote Creator — logged in
  ✗ Twitter/X — still expired
```

## Platform Reference

| Platform | Display Name | Check URL | Login URL | QR? |
|----------|-------------|-----------|-----------|-----|
| rednote | RedNote Creator | https://creator.xiaohongshu.com/publish/publish | https://creator.xiaohongshu.com/login | No |
| rednote_www | RedNote Web | https://www.xiaohongshu.com/explore | https://www.xiaohongshu.com/explore | No |
| twitter | Twitter/X | https://x.com/home | https://x.com/i/flow/login | No |
| weibo | Weibo | https://weibo.com | https://weibo.com/login.php | No |
| linkedin | LinkedIn | https://www.linkedin.com/feed | https://www.linkedin.com/login | No |
| wechat_mp | WeChat MP | https://mp.weixin.qq.com/cgi-bin/home | https://mp.weixin.qq.com | Yes |
| bilibili | Bilibili | https://www.bilibili.com/ | https://passport.bilibili.com/login | Yes |
| youtube | YouTube | https://www.youtube.com/ | https://accounts.google.com | No |
| youtube_studio | YouTube Studio | https://studio.youtube.com/ | https://accounts.google.com | No |
| bilibili_creator | Bilibili Creator | https://member.bilibili.com/platform/home | https://passport.bilibili.com/login | Yes |

## MCP Tool Selection

This skill works with either MCP browser tool:
- **Chrome MCP** (`chrome-devtools-mcp`) — connects to existing CDP Chrome via `--browserUrl`
- **Playwright MCP** (`@playwright/mcp`) — needs `--cdp-endpoint` to connect to existing Chrome

Prefer whichever is configured to connect to the target CDP port. If both available, use Chrome MCP (it connects to CDP by default).

## Key Rules

- **Always verify CDP is running first** (Step 0) — don't assume
- **Never launch Chrome yourself** — if CDP is down, print the startup command as a copy-paste bash block and stop. The user runs it in their own terminal.
- **Report the user-data-dir** — so user knows which Chrome profile is being checked
- **No hardcoded selectors** — read snapshots/screenshots to identify login state
- **Always close tabs** — CDP tabs accumulate
- **Sequential only** — one platform at a time
- **Use `--noproxy '*'`** for all curl commands to localhost — machine may have proxy configured

## Anti-Patterns

| Anti-Pattern | What goes wrong | Fix |
|--------------|-----------------|-----|
| Launching Chrome via the assistant's own Bash | Chrome detaches from user's terminal session, may not pick up keychain/GUI | Print the startup command and stop; user pastes into their own terminal |
| Skipping Step 0 (CDP reachability check) | Later MCP calls fail with cryptic errors | Always `curl http://127.0.0.1:<port>/json/version` first |
| Hardcoding DOM selectors to detect login state | Selectors break on every platform UI update | Use snapshot/screenshot heuristics (URL + visible text) |
| Leaving check tabs open | Tabs accumulate, slowing CDP and leaking state | Close after every check (Step 1 step 5, Step 3 step f) |
| Parallel login across platforms | User can only authenticate in one tab at a time, QR codes overlap | Sequential loop only |
| Curl to localhost without `--noproxy '*'` | System proxy intercepts loopback, false negatives | Add `--noproxy '*'` to every loopback curl |
| Silently falling back to WebFetch when CDP is down | Hides the real failure; scrapes wrong (logged-out) view | Stop and surface the failure; print startup command |

## See Also

- `tmux` — Companion shell setup; tmux pane is where the user pastes the Chrome startup command
- `claude-code-config` — Global Chrome CDP configuration (ports, profiles)
- `github-cli` — Authenticate `gh` in a similar interactive way for GitHub flows
- `fail-fast-ml-engineering` — Same "no silent fallbacks" discipline applied here (fail loudly when CDP is down)

Related Skills

ml-ablation-design

10
from dongzhuoyao/tao-research-skills

Use when designing ablation studies to compare model components, loss functions, or architectural choices. Covers synthetic data experiments, variant loops, production metrics, and W&B grouping. Triggers: "ablation", "ablation study", "variant comparison", "controlled experiment", "synthetic data experiment"

gpu-training-acceleration

10
from dongzhuoyao/tao-research-skills

Use when optimizing PyTorch training speed or memory on CUDA GPUs — global flags, torch.compile, fused optimizers, mixed precision, gradient checkpointing, kernel fusion, memory layout, or latent-space training. Applies to any PyTorch training workload. Triggers: "torch.compile", "TF32", "fused optimizer", "mixed precision", "bf16", "fp16", "gradient checkpointing", "Triton kernel", "CUDA flags", "GPU slow", "GPU memory"

genai-evaluation-metrics

10
from dongzhuoyao/tao-research-skills

Use when evaluating generative models — choosing metrics (FID, IS, KID, sFID, FDD, FVD, PRDC, LPIPS, SSIM, AuthPct, Vendi), setting up online or offline evaluation, feature extractor selection, distributed computation, memory management during sampling. Triggers: "FID", "IS", "KID", "inception score", "frechet", "LPIPS", "SSIM", "evaluation metrics", "generative evaluation", "FVD"

youtube-wiki

10
from dongzhuoyao/tao-research-skills

Use when reading a YouTube video (especially an AI/ML interview, podcast, or technical talk) and producing a faithful, timestamped wiki entry the user can return to weeks later. Fetches the transcript via yt-dlp, sections by chapters or LLM-detected topics, summarizes per-section with parallel subagents, preserves verbatim quotes with speaker attribution, and runs a coverage test against the raw transcript. Triggers: "youtube wiki", "video wiki", "summarize this youtube", "watch this interview", "read this talk", "digest this video", "https://youtu.be/", "https://www.youtube.com/watch"

pdf-reader

10
from dongzhuoyao/tao-research-skills

Use when reading PDF papers, reports, or long documents where text, figures, and tables must all be captured and chunk-summarized without truncation. Converts PDF to a markdown + paper_content.json workspace, extracts figures and tables as standalone files, then delegates to arxiv-latex-reader's progressive two-layer reading (section index + on-demand deep reads). Triggers: "read pdf", "pdf to markdown", "summarize pdf", "pdf paper", "extract figures from pdf", "extract tables from pdf", "marker pdf", "pymupdf", "docling", "paper digest", "pdf reader"

insert-wiki

10
from dongzhuoyao/tao-research-skills

Use when capturing a single URL (X tweet, LinkedIn post, HN thread, short blog, news article, GitHub gist or issue) as a small persistent markdown entry the user can re-read later for motivation or grep across future sessions. Verbatim body + author + tags + a one-line "Why I saved this" hook. Writes to docs/wikis/YYYY-MM-DD-<slug>.md. WebFetch by default; CDP via Playwright MCP for login-walled hosts (x.com, twitter.com, linkedin.com). Redirects YouTube / arXiv / GitHub repo URLs to their specialized skills. Triggers: "insert wiki", "add to wiki", "insert this", "save this tweet", "capture this post", "add this to my wiki", "remember this link", "https://x.com/", "https://twitter.com/", "https://linkedin.com/posts/"

idea-feasibility

10
from dongzhuoyao/tao-research-skills

Use when evaluating whether a research or product idea is actually feasible — buildable, evaluable, and de-risked by available checkpoints, code, datasets, and GPU budget. Normalizes the idea, gathers primary-source evidence (arXiv, GitHub, project pages, model hosts), scores it against four mandatory hard gates, and emits a verdict + falsifiable MVP. Triggers: "idea feasibility", "is this idea feasible", "feasibility check", "can we do this", "is this practical", "worth pursuing", "评估想法可行性", "可行性分析", "这个 idea 能做吗", "这个想法靠谱吗"

idea-explore

10
from dongzhuoyao/tao-research-skills

Use when proposing new research ideas grounded in a seed paper or method — surfaces the gaps that the citation cone hasn't filled, the drawbacks the community already complains about in the official repo's GitHub issues, and the adjacent angles the literature suggests. Orchestrates followup-analysis (already-done exclusion), GitHub-issue mining (known drawbacks), and academic-deep-research (adjacent literature) into a ranked candidate-ideas report. Triggers: "idea explore", "idea-explore", "propose ideas", "explore ideas", "new directions", "research gaps", "what's missing", "build on this paper", "探索想法", "提出新想法", "研究空白"

idea-box

10
from dongzhuoyao/tao-research-skills

Use when promoting an idea from a fleeting thought into a tracked artifact with a lifecycle. Defines a per-idea on-disk directory (./idea_box/<slug>/) and a hard-gated state machine (explored → feasible/blocked → building → built/killed) that the existing reader/evaluator skills (idea-feasibility, ml-ablation-design, academic-deep-research, followup-analysis, arxiv-latex-reader, pdf-reader, github-reader, blog-reader) plug into. Public repo ships only the convention; idea data lives in the user's private idea-box repo. Triggers: "idea box", "idea-box", "new idea", "advance idea", "list ideas", "kill idea", "想法箱", "新想法", "推进想法", "列出想法"

github-reader

10
from dongzhuoyao/tao-research-skills

Use when reading a GitHub repository (especially a research code release with an accompanying paper) and producing a faithful digest that covers the implementation logic, the main insight, and the key reported results. Research-first with graceful fallback for non-paper repos. Handles arXiv link detection and delegates paper reading to arxiv-latex-reader / pdf-reader. Triggers: "read repo", "read this github", "analyze github", "digest repo", "github reader", "extract from github", "summarize this codebase", "read this code", "https://github.com/"

blog-reader

10
from dongzhuoyao/tao-research-skills

Use when reading a long technical blog post (ML research, engineering deep-dives, Distill/Lil'Log-style posts) and producing a faithful, figure-aware summary. Handles context-over-limit via section-based chunking, captures important figures via multimodal Read, and runs a coverage test to catch missing information. Triggers: "read this blog", "summarize this post", "read blog", "digest this article", "long blog post", "read this article", "blog summary", "distill post", "summarize url", "chunk and summarize"

arxiv-latex-reader

10
from dongzhuoyao/tao-research-skills

Use when reading large arxiv papers without context overflow. Progressive two-layer reading: index all sections (~2k tokens), then deep-read on demand. Never truncates. Triggers: "read paper", "paper sections", "section index", "progressive reading", "paper_content.json", "section summary"