Skip to content

konglong87/superPM / skills/pm-preview

pm-preview

Verified

产品文档实时预览 - 在浏览器中预览 docs/ 下的所有 MD 文档,文档更新时自动刷新 Use when: 需要预览产品文档、查看 PRD/BRD/MRD 等 MD 文档的渲染效果 Do NOT use when: 文档尚未生成(docs/ 为空)

Preamble (run first)

# 检查 docs/ 目录和文档数量
echo "📊 文档预览状态:"
echo ""

if [ ! -d docs ]; then
  echo "  ❌ docs/ 目录不存在"
  echo "  💡 请先执行产品流程(/pm-brainstorm → /pm-demand → ... → /pm-docs)生成文档"
  exit 0
fi

total=0
for prefix in "01-需求调研" "02-方案设计" "03-增长迭代" "04-风控管理" "05-产品战略"; do
  count=$(ls docs/$prefix/*.md 2>/dev/null | wc -l | tr -d ' ')
  if [ "$count" -gt 0 ]; then
    echo "  $prefix: $count 个文档"
    total=$((total + count))
  fi
done

# 递归统计所有 .md 文件
all=$(find docs -name "*.md" 2>/dev/null | wc -l | tr -d ' ')
echo ""
echo "  📄 总计: $all 个 MD 文档"
echo ""

if [ "$all" -eq 0 ]; then
  echo "  ❌ 没有找到任何文档"
  echo "  💡 请先执行产品流程生成文档"
fi

执行流程

步骤 1: 启动预览服务器

先从已加载的本 skill 路径确定其绝对目录(单独安装时不在项目的 skills/ 目录内),再使用 Bash 启动:

bash "<当前 pm-preview skill 所在目录>/scripts/start-preview.sh" --project-dir .

说明:

  • 服务器在随机高端口启动(49152-65535)
  • 使用 --project-dir . 将 session 持久化到 .superpm/preview/,服务器停止后文件保留;验收完毕后应删除不再需要的 session
  • 后台运行,不阻塞终端

输出示例:

{"type":"server-started","port":52341,"url":"http://localhost:52341","docs_dir":"/path/to/docs","state_dir":"/path/to/.superpm/preview/..."}

步骤 2: 告知用户打开预览

从输出中提取 url 字段,告知用户:

📄 文档预览已启动!

🌐 预览地址: {url}

在浏览器中打开上述地址,即可查看所有产品文档。

  • 左侧边栏:文档目录树
  • 右侧内容区:Markdown 渲染结果
  • 📝 文档更新时浏览器会自动刷新

步骤 3: 监控状态(可选)

如果用户需要持续预览,可以提醒:

💡 提示:

  • 预览服务器 30 分钟无活动后自动停止
  • 如需手动停止,执行:bash "<当前 pm-preview skill 所在目录>/scripts/stop-preview.sh" .superpm/preview/{session_id}
  • 执行其他 skill(如 /pm-docs)生成新文档后,浏览器会自动刷新

停止预览

用户可通过以下方式停止:

# 查找 session 目录
ls -d .superpm/preview/*/

# 停止服务器
bash "<当前 pm-preview skill 所在目录>/scripts/stop-preview.sh" .superpm/preview/{session_id}

功能特性

特性说明
实时刷新文档更新时通过 WebSocket 自动推送刷新
侧边栏导航按目录分组展示所有文档,支持折叠/展开
Markdown 渲染浏览器端渲染,支持表格、代码块、流程图
亮/暗主题跟随操作系统主题自动切换
零依赖仅使用 Node.js 内置模块,无需 npm install
自动清理30 分钟无活动自动停止,/tmp 下临时文件自动删除

注意事项

  1. 首次使用:确保 docs/ 目录下有至少一个 .md 文件
  2. 浏览器兼容:需要支持 WebSocket 的现代浏览器(Chrome/Firefox/Safari/Edge)
  3. 网络要求:Markdown 渲染和 HTML 清理库随 skill 本地提供,预览不依赖 CDN;需要本地 Node.js
  4. 端口冲突:如果随机端口被占用,服务器会自动使用其他端口
  5. 多会话:每次启动创建独立 session,可同时运行多个预览实例

常见误区 / Red Flags — STOP

误区正确做法
文档还没生成就启动预览先执行产品流程生成文档,再启动预览
预览服务器启动失败时放弃尝试 --foreground 模式查看错误信息
手动修改文档后期望即时刷新文档更新后服务器有 100ms 防抖延迟
rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).Stars: 196kUpdated Claude CodeCodexUnverifiedInstall
doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.Stars: 196kUpdated Claude CodeCodexVerifiedInstall