关于 tabctl
tabctl 是用于检查和分析浏览器标签页的技能,也可通过 GraphQL 按需执行定向修改。它优先采用只读检查,并为会话操作设置安全限制。
主要功能
- 01通过 GraphQL 查询标签页状态
- 02分析重复或过期标签页
- 03将页面内容提取为 Markdown
- 04检查元素属性
- 05定向修改标签页和分组
适用场景
- 01查看浏览器窗口中的标签页和分组
- 02查找重复或过期标签页
- 03读取多个标签页的页面内容
- 04整理选定标签页并分组
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ ekroon/ tabctl --skill tabctl安装后在 Claude Code 中输入/tabctl确认已加载。
详细介绍
标签控制
使用 tabctl 安全地检查和分析标签页,并且仅在收到请求时执行有针对性的 GraphQL 变更。
公共浏览器 API
浏览器状态现在仅通过 GraphQL 提供:
tabctl query '<GRAPHQL>'tabctl schematabctl pingtabctl history
不要使用已移除的旧版浏览器子命令,例如 list、open、close、inspect、report、screenshot、archive 或 undo。
探索
tabctl schema
tabctl help
tabctl help query
读取示例
# Windows, tabs, and groups
tabctl query '{ windows { windowId focused groups { groupId title } tabs { tabId title url groupTitle } } }'
# Paginated tabs
tabctl query '{ tabs(limit: 20, offset: 0) { total hasMore items { tabId title url } } }'
# Analyze duplicate/stale tabs
tabctl query '{ analyze(windowId: 123, staleDays: 30) { totalTabs duplicateTabs staleTabs } }'
# Inspect page metadata
tabctl query 'query { inspectTabs(tabIds: [456], signals: ["page-meta"]) { entries { tabId signals { name valueJson } } } }'
# Inspect selectors with typed attrs and filters
tabctl query 'query { inspectTabs(windowId: 123, selectors: [{ name: "prices", selector: ".price", attr: "text", all: true, text: "$", textMode: "contains" }, { name: "submit_visible", selector: "#submit", attr: "visible" }, { name: "submit_style", selector: "#submit", attr: "styles", styleProps: ["color", "background-color"] }, { name: "item_count", selector: ".item", attr: "count" }, { name: "email_value", selector: "input[type=email]", attr: "value" }, { name: "tos_checked", selector: "input[name=terms]", attr: "checked" }]) { entries { tabId url signals { name valueJson } } } }'
# Read page content as Markdown
tabctl query 'query { readTabs(windowId: 123, extract: true, maxChars: 30000) { entries { tabId title url markdown chars truncated extracted cached status emptyReason diagnostics { source sourceHtmlChars sourceTextChars documentReadyState truncatedHtml cachedAt cacheAgeMs } error } } }'
# Build reports
tabctl query '{ reportTabs(windowId: 123) { entries { tabId title url description } } }'
# Capture screenshots
tabctl query 'query { captureScreenshots(tabIds: [456], mode: "viewport") { entries { tabId tiles { index width height } } } }'
只读提取说明
readTabs使用 Kreuzberg 预处理将主框架 HTML 转换为 Markdown。请检查每个标签页的status、emptyReason、diagnostics和error;缓存回退使用有界的配置文件本地打开标签页缓存,该缓存会在读取成功、活动标签页切换以及活动页面静止时刷新,并在诊断信息中报告status: CACHED、cached: true和缓存来源。readTabsv1 不会遍历跨域 iframe 或 shadow DOM;对于不可脚本化的 URL,会返回status: UNSUPPORTED_URL。inspectTabs的选择器属性现在包括html、value、count、box、styles、visible、enabled和checked。visible表示元素已渲染,且不是display:none、visibility:hidden或opacity:0。enabled表示元素未被禁用,且aria-disabled != "true"。- 对于表单控件,
checked使用input.checked;否则使用aria-checked == "true"。
变更示例
# Open tabs in a new grouped window
tabctl query 'mutation { openTabs(urls: ["https://example.com"], group: "Research", newWindow: true) { windowId groupId tabs { tabId url } } }'
# Group and window changes
tabctl query 'mutation { updateGroup(groupId: 99, title: "Inbox", color: "blue") { groupId title color } }'
tabctl query 'mutation { assignToGroup(tabIds: [456], groupTitle: "Inbox") { groupId title } }'
tabctl query 'mutation { ungroupTabs(tabIds: [456]) { tabId groupId } }'
tabctl query 'mutation { moveGroup(groupId: 99, newWindow: true) { movedToWindowId movedTabs } }'
tabctl query 'mutation { mergeWindows(fromWindowId: 200, toWindowId: 123, closeSource: true, confirm: true) { movedTabs sourceClosed } }'
# Tab changes
tabctl query 'mutation { focusTab(tabId: 456) { success } }'
tabctl query 'mutation { refreshTabs(tabIds: [456]) { refreshedTabs } }'
tabctl query 'mutation { moveTab(tabIds: [456], windowId: 123, index: 0) { movedTabs } }'
# Destructive actions with undo support
tabctl query 'mutation { closeTabs(tabIds: [456], confirm: true) { txid closedTabs } }'
tabctl query 'mutation { archiveTabs(windowId: 123) { txid archivedTabs } }'
tabctl query 'mutation { deduplicateTabs(windowId: 123, confirm: true) { txid closedTabs } }'
tabctl query 'mutation { undoAction(latest: true) { txid summary } }'
# Extension reload
tabctl query 'mutation { reloadExtension { reloading } }'
安全
- 除非用户明确要求进行更改,否则优先使用只读 GraphQL 查询。
- 限定变更范围并确保可撤销;如有
txid值,请一并提供。 - 未经明确指定目标或确认,绝不要对用户的整个浏览会话运行破坏性工作流。
- 遵守策略:受保护的标签页不会包含在查询和变更结果中。
- 仅在需要视觉上下文时使用截图。
便捷命令
tabctl ping
tabctl history --limit 10
使用 ping 检查连接和版本状态,并使用 history 查找撤销事务。
故障排除
tabctl ping --json是标准的运行时健康检查。tabctl doctor --fix可修复本地配置文件连接和同步偏差。TABCTL_AUTO_SYNC_MODE=release-like tabctl query '{ tabs { total } }'会在类似本地发布的测试期间强制执行运行时同步行为。
评论
支持 Markdown