跳到主内容
智客 ZICQ

技能库 智客分类:Agent 工作流 browser-preview

Browser Preview

预览面板和iframe诊断:注册,端口,路径,空白屏幕.

4579 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

预览面板和iframe诊断:注册,端口,路径,空白屏幕.

何时用

官方 description 未单独写出 Use when。按规范,代理会在用户任务与这段 description 的关键词匹配时激活本技能。

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Browser Preview、What is the Preview Panel、⚠️ CRITICAL: Never Tell Users to Access localhost、⚠️ Static Assets Must Use Relative Paths、⚠️ Do NOT Browse Filesystem to Debug Previews、Step-by-Step: Diagnosing Preview Issues。 其中含规范建议的小节:分步指令。

文件分析

文件分析:这是一份仅含 SKILL.md 的指令型技能,代理激活后整份正文进入上下文。

官方 description(原文)

Preview panel and iframe diagnostics: registry, ports, paths, blank screens.

Browser PreviewWhat is the Preview Panel⚠️ CRITICAL: Never Tell Users to Access localhost⚠️ Static Assets Must Use Relative Paths⚠️ Do NOT Browse Filesystem to Debug PreviewsStep-by-Step: Diagnosing Preview IssuesStep 1: Read the registry (running services)Step 2: Branch based on registry stateStep 3: Registry has entries — verify and fixStep 4: No running services — check history first, then scan workspaceQuick ReferenceWhat You Cannot Do

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
browser-preview
description
Preview panel and iframe diagnostics: registry, ports, paths, blank screens.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「browser-preview」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-d048e230af2bace1-Browser-Preview.html
请存为 .cursor/skills/browser-preview/SKILL.md 或 .claude/skills/browser-preview/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/starchild-ai-agent/official-skills' --list

npx skills add 'https://github.com/starchild-ai-agent/official-skills' --skill 'browser-preview'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: browser-preview version: 1.1.2 description: | Preview panel and iframe diagnostics: registry, ports, paths, blank screens. Use when a preview tab is broken or missing (e.g. white screen, tab disappeared, 404 on assets, preview not loading, list running services). metadata: starchild: emoji: "🌐" skillKey: browser-preview user-invocable: true disable-model-invocation: false --- # Browser Preview You already know `preview_serve` and `preview_stop`. This skill fills the gap: what happens **after** preview_serve returns a URL — how the user actually sees it. ## What is the Preview Panel The frontend has a right-side panel with two tabs: **Files** and **Preview**. The Preview tab renders preview URLs inside an iframe. When you call `preview_serve`, the frontend automatically opens a Preview tab loading that URL. (Jobs are now managed in a standalone modal accessible from the left sidebar, not in the right panel.) Key facts: - Each `preview_serve` call creates one Preview tab - URL format: `https:///preview/{id}/` - Preview panel has a **⋮ menu** (top-right) showing "RUNNING SERVICES" list - Preview tab can be **closed by the user** without stopping the backend service - Backend service stopping → Preview tab shows an error page ## ⚠️ CRITICAL: Never Tell Users to Access localhost **The user's browser CANNOT access `localhost` or `127.0.0.1`.** These addresses point to the server container, not the user's machine. The preview architecture uses a **reverse proxy**: ``` User's Browser → https:///preview/{id}/path → (reverse proxy) → 127.0.0.1:{port}/path ``` Rules: - **NEVER** tell the user to visit `http://localhost:{port}` or `http://127.0.0.1:{port}` — they cannot reach it - **ALWAYS** direct users to the preview URL: `/preview/{id}/` (or the full URL `https:///preview/{id}/`) - `curl http://localhost:{port}` is for **your own server-side diagnostics only** — never suggest it to the user as a way to "test" the preview - When a preview is running, tell the user: "Check the Preview panel, or refresh the Preview panel" - If you need to give the user a URL, use the `url` field returned by `preview_serve` (format: `/preview/{id}/`) ## ⚠️ Static Assets Must Use Relative Paths Because previews are served under `/preview/{id}/`, **absolute paths in HTML/JS/CSS will break**. The reverse proxy strips the `/preview/{id}` prefix before forwarding to the backend, but the browser resolves absolute paths from the domain root. Example of the problem: ```html ``` Common patterns to fix: | Broken (absolute) | Fixed (relative) | |---|---| | `"/static/app.js"` | `"static/app.js"` or `"./static/app.js"` | | `"/api/users"` | `"api/users"` or `"./api/users"` | | `"/images/logo.png"` | `"images/logo.png"` or `"./images/logo.png"` | | `url('/fonts/x.woff')` | `url('./fonts/x.woff')` | | `fetch('/data.json')` | `fetch('data.json')` | **Check ALL places** where paths appear: 1. HTML `src`, `href` attributes 2. JavaScript `fetch()`, `XMLHttpRequest`, dynamic imports 3. CSS `url()` references 4. JavaScript string literals (e.g., `'/static/'` in template strings or concatenation) 5. Framework config files (e.g., `publicPath`, `base`, `assetPrefix`) ⚠️ Be thorough — it's common to fix CSS `url()` but miss JS string literals like `'/static/'` (with single quotes). Search for ALL occurrences of absolute paths across all file types. ## ⚠️ Do NOT Browse Filesystem to Debug Previews **Never** look at workspace directories like `preview/`, `output/`, or random folders to understand preview state. Those are user data, not preview service state. The **only** sources of truth: 1. Registry file: `/data/previews.json` (running services) 2. History file: `/data/preview_history.json` (all past services) 3. `preview_serve` / `preview_stop` tools 4. Port checks via `curl` (server-side only, for your diagnostics) Do NOT use `ls`/`find` on workspace directories to diagnose preview issues. Do NOT call unrelated tools like `list_scheduled_tasks`. Stay focused. ## Step-by-Step: Diagnosing Preview Issues When a user reports any Preview panel problem, follow this exact sequence: ### Step 1: Read the registry (running services) ```bash cat /data/previews.json 2>/dev/null || echo "NO_REGISTRY" ``` ⚠️ Your bash CWD is `/data/workspace/`. The registry is at `/data/previews.json` (absolute path, one level up). Always use the absolute path. JSON structure: ```json { "previews": [ {"id": "f343befc", "title": "My App", "dir": "/data/workspace/my-project", "command": "npm run dev", "port": 9080, "is_builtin": false} ] } ``` ### Step 2: Branch based on registry state **If registry has entries** → Go to Step 3 (verify services) **If registry is empty or missing** → Go to Step 4 (check history) ### Step 3: Registry has entries — verify and fix For each preview in the registry, check if the port is responding **server-side** (this is your diagnostic, not for the user): ```bash curl -s -o /dev/null -w "%{http_code}" http://localhost:{port} ``` **If port responds (200):** - The service IS running. Tell the user: - "You have a running service: {title}" - "Click the ⋮ menu at the top-right of the Preview panel, then click it in the RUNNING SERVICES list to reopen" - Preview URL: `/preview/{id}/` - **If user says the ⋮ menu is empty or doesn't show the service** → frontend lost sync. Fix by recreating: `preview_stop(id)` then `preview_serve(dir, title, command)` using the info from the registry. This forces the frontend to re-register the tab. **If port does NOT respond:** - Process crashed but registry entry remains. Recreate: ``` preview_stop(id="{id}") preview_serve(dir="{dir}", title="{title}", command="{command}") ``` ### Step 4: No running services — check history first, then scan workspace When there are no running services, use a **two-tier lookup** to find projects the user can preview: #### Tier 1: Read preview history (preferred — fast and accurate) ```bash cat /data/preview_history.json 2>/dev/null || echo "NO_HISTORY" ``` JSON structure: ```json { "history": [ { "id": "f343befc", "title": "Trading System", "dir": "/data/workspace/my-project", "command": "python main.py", "port": 8000, "is_builtin": false, "created_at": 1709100000.0, "last_started_at": 1709200000.0 } ] } ``` History entries are **never removed by `preview_stop`** — they persist across restarts. Entries are automatically pruned only when the project directory no longer exists. **If history has entries:** - List all history entries to the user with title, directory, and last started time - Ask which one they want to restart - Call `preview_serve` with the `dir`, `title`, and `command` from the history entry **If user says a project is missing from history** → fall through to Tier 2. #### Tier 2: Scan workspace (fallback — when history is empty or incomplete) ```bash find /data/workspace -maxdepth 2 \( -name "package.json" -o -name "index.html" -o -name "*.html" -o -name "app.py" -o -name "main.py" -o -name "vite.config.*" \) -not -path "*/node_modules/*" -not -path "*/skills/*" -not -path "*/memory/*" -not -path "*/prompt/*" -not -path "*/.git/*" 2>/dev/null ``` Then: 1. List discovered projects with brief descriptions 2. Ask the user which one to preview 3. Call `preview_serve` with the appropriate directory **Don't just say "no services running" and stop.** Always check history first, then scan, and offer options. ## Quick Reference | User says | You do | |-----------|--------| | "tab disappeared" / "tab 不见了" | Step 1 → 2 → 3 or 4 | | "blank page" / "白屏" | Check port (server-side), if dead → recreate; if alive → check for absolute path issues | | "not updating" / "内容没更新" | Suggest refresh button in Preview tab, or recreate preview | | "port conflict" / "端口冲突" | `preview_stop` old → `preview_serve` new | | "can't see service" / "⋮ menu empty" | `preview_stop` + `preview_serve` to force re-register | | "where's my project" / "what did I build" | Read `/data/preview_history.json` and list entries | | "resource load failed" / "JS/CSS 404" | Check for absolute paths (`/static/`, `/api/`), fix to relative paths | ## What You Cannot Do - Cannot directly open/close/refresh Preview tabs (frontend UI) - Cannot force-refresh the iframe - Cannot read what the iframe displays When you can't do something, tell the user the manual action (e.g., "click refresh in Preview tab"). If manual action doesn't work, recreate the preview with `preview_stop` + `preview_serve`. ## Common Mistakes to Avoid 1. ❌ Telling user to "visit http://localhost:18791/" — user cannot access localhost 2. ❌ Saying "refresh the page at localhost" — meaningless to the user 3. ❌ Only fixing CSS `url()` paths but missing JS string literals with absolute paths 4. ❌ Forgetting to check ALL file types (HTML, JS, CSS, config) for absolute paths 5. ✅ Always use `/preview/{id}/` as the user-facing URL 6. ✅ Always use `curl localhost:{port}` only for your own server-side diagnostics 7. ✅ After fixing paths, call `preview_stop` + `preview_serve` to restart, then tell user to check Preview panel

相关技能

Agent 工作流

Skill Creator

创造有效技能指南。 当用户想创造出新的技能(或更新现有的技能),以专业知识,工作流程,或工具集成来扩展克洛德的能力时,应该使用这种技能.

Agent 工作流

Clawdhub

使用ClawdHub CLI搜索,安装,更新并发布从taladhub.com的代理技能. 需要获取苍蝇上的新技能时使用,将安装的技能同步到最新版本或特定版本,或者发布 npm-instainddhub CLI 的新/更新的技能文件夹.

Agent 工作流

Agent Team Orchestration

管弦乐团多代理团队,任务设定周期,交接协议,审查工作流程. 使用时间: (1)建立2+特派员队伍,具有不同专业,(2)确定任务路线和生命周期(收录框_ spec_建设_审查_完成),(3)在特派员之间制定交接协议,(4)建立审查和质量关口,(5)管理特派员之间的交流和文物共享.

Agent 工作流

Superpowers

Spec-first,TDD,子代理驱动的软件开发工作流程. 当:(1)构建任何新功能或应用——触发脑暴_计划_子代理执行回路,(2)调试出一个bug或测试失败——触发系统性的根起过程,(3)用户说"让我们构建","帮助我计划","我想添加X",或"这个被打破",(4)完成一个功…