chrome-tab-killer
chrome-tab-killer Skill
Language: Respond in the same language as the user (中文提问则中文回答).
Identification is fully automated (CDP or AppleScript). Closing requires a confirmation gate (show proposed list → user confirms) unless the user explicitly authorizes a one-shot close.
Prerequisites
| Item | Required for |
|---|---|
| Google Chrome (macOS) | AppleScript path |
Chrome with --remote-debugging-port=9222 |
Full CDP enumeration + optional chrome://discards/ automation |
| Automation permission | System Settings → Privacy & Security → Automation: allow Terminal/Cursor to control Google Chrome |
Execution Flow
Step 0 · Detect Language
Use the same language as the user for all output.
Step 1 · Enumerate Tabs (Automated)
Path A — CDP (preferred)
-
Ensure Chrome was started with remote debugging, e.g.:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222Or add to a shortcut / shell profile for daily use.
-
List targets (agent runs, no user UI):
curl -s http://127.0.0.1:9222/json/listParse JSON: each
type: "page"entry hasid,title,url,webSocketDebuggerUrl. -
Count tabs and build a table of
title,url,targetId.
Path B — AppleScript (fallback when CDP unavailable)
Run the bundled script (use absolute path to the skill’s scripts/ folder):
osascript /path/to/skills/chrome-tab-killer/scripts/list-chrome-tabs.applescript
Output format: windowIndex\ttabIndex\ttitle\turl per line.
Limitation: No per-tab memory from discards; tell the user that full automation quality needs CDP.
Step 2 · Classify Candidates (Heuristics, Automated)
Apply rules without asking the user to paste anything:
| Class | Rule (examples) |
|---|---|
| Crash / error | Title contains Aw, Snap!, Page Unresponsive, 无法访问此网站, ERR_, This site can’t be reached, etc. |
| Duplicate URL | Same normalized URL appears in more than one tab (keep one). |
| Low activity (conservative) | Only when user enables aggressive mode in prompt; optional CDP discards data (see below). |
Default conservative: recommend closing crash/error and duplicate URL only.
Step 3 · Optional — chrome://discards/ via CDP (SHOULD / best-effort)
Only if CDP is connected:
- Attach to a page target via WebSocket,
Page.navigatetochrome://discards/. - After load,
Runtime.evaluateor DOM query to read table rows (memory, last active, discard eligibility).
If parsing fails (Chrome update broke DOM): stop and continue with Step 2 data only (json/list + heuristics). Do not ask the user to open or paste the page.
Step 4 · Default Dry-Run Report
Output Markdown:
- Total tab count
- Table of all tabs (title, url, targetId or W/T index)
- Candidates with reason (crash / duplicate / aggressive-only)
- No closes in this step unless user already requested execution
Step 5 · Close (After Confirmation Only)
Do not close until the user explicitly confirms the list or gives a clear one-shot order (“关闭上表中的候选标签”).
Option A — CDP Target.closeTarget
Send over the target’s debugger WebSocket (same session as CDP):
{"id":1,"method":"Target.closeTarget","params":{"targetId":"<id from json/list>"}}
Use the webSocketDebuggerUrl from the matching list entry, or a shared browser WebSocket if documented for your Chrome version.
Option B — AppleScript
Close by window/tab index:
osascript scripts/close-chrome-tab.applescript <windowIndex> <tabIndex>
Close by URL (often easier to align with CDP url):
osascript scripts/close-tab-by-url.applescript 'https://example.com/path'
Safety
| Rule | Behavior |
|---|---|
| Default | Analysis + dry-run only |
| Close | Only after explicit user confirmation or one-shot authorized command |
| Irreversible | Warn that closed tabs cannot be restored by this skill |
Scripts (macOS)
See scripts/README.md for osascript usage and Automation permissions.
Example
User: “用 chrome-tab-killer 分析一下标签”
Agent:
curl -s http://127.0.0.1:9222/json/list(or AppleScript if connection refused)- Classify crash titles and duplicate URLs
- Print dry-run report
- Ask: “是否关闭以上候选?” → only if yes, run
Target.closeTargetorosascript…
Error Handling
| Situation | Action |
|---|---|
| Connection refused on :9222 | Fall back to AppleScript list; state that CDP is off |
| AppleScript denied | Tell user to enable Automation for Google Chrome |
| discards parse fails | Skip discards; continue with json/list heuristics |
More from wghust/stark-skills
google-news-seo
Google News Diagnostic Engine — audit and optimize news articles for Google News SEO. Determines Layer 1 index eligibility and Layer 2 ranking competitiveness. Includes NewsArticle Schema review, AI content compliance checks, publisher trust detection, author authority scoring, freshness analysis, topic cluster compatibility, Top Stories detection, competitor gap analysis, and Google E-E-A-T scanning with structured report generation. Use when asked about Google News SEO, why a site is not indexed in Google News, why articles don't rank, NewsArticle Schema optimization, how AI content can get into Google News, or running an EEAT scan / audit. 检查和优化新闻文章的 Google News SEO,包括双层诊断引擎(Layer 1 索引准入 / Layer 2 排名竞争)、NewsArticle Schema 审查与修复、AI 生成内容合规性检查、发布者信任度检测、作者权威性评分、新鲜度分析、话题聚类兼容性、Top Stories 检测、竞争对手差距分析,以及 Google E-E-A-T 全维度扫描。
23openspec-design
Extends OpenSpec with design asset integration. Use when the user asks to "run openspec-design", "enhance openspec design", or "apply openspec-design". When invoked, updates the project's openspec/AGENTS.md to extend the proposal flow with Figma MCP, design asset directory, and design-map.md.
16insight-pdf
Generates professional corporate/business report PDFs from text or Markdown via HTML. Uses ECharts for advanced visualizations (heatmaps, radar, gauge, sankey), rich design system (gradient covers, stat cards, callout boxes, progress bars, timelines), and professional typography. Use when the user wants enterprise-quality report PDFs with modern data storytelling.
16nextjs-debug
Diagnose and fix Next.js project startup, compilation, and runtime errors by analyzing logs and project source code. Use when the user reports a Next.js startup error, compilation failure, hydration mismatch, module not found, Server/Client boundary violation, environment variable issue, or port conflict. Also triggers on "next dev fails", "next build error", "Turbopack error", "use client missing", "module not found", "Cannot find module", "hydration failed". 诊断并修复 Next.js 项目启动、编译和运行时错误。当用户粘贴启动日志、描述 Next.js 报错、询问"启动失败"、"编译报错"、"模块找不到"、"Server Component 报错"、"hydration 错误"、"环境变量不生效"时使用。
14c4-interactive-html
|
13mac-wash
|
12