Builds or extends a persistent macOS local web surface with stable *.localhost URLs, loopback daemon lifecycle, launchd integration, and thin .app launchers. Covers domain ownership, Host routing, access boundaries, safe mutations, TDD, and curl-based QA.
Ships in adonis-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
把一个“本地页面”交付成可长期使用的产品入口:固定 *.localhost URL、登录后自动可用、可选 .app 启动器、真实运行验收。
此 Skill 编排已有代码与系统能力,不规定前端框架。默认优先复用现有 loopback daemon;只有证据证明生命周期、权限或故障域必须隔离时,才新增监听进程。
请求至少要包含一个持久 surface 信号:稳定 *.localhost 身份、loopback daemon/gateway、登录自启、共享 listener,或为持久本地 HTTP surface 提供唤醒/打开能力的 macOS .app launcher。只包装 https://... 公网或内网页面的 .app 不属于本 Skill。普通 dev server 上的页面/CRUD 实现不使用本 Skill;只需打开、操作或截图现有 URL 时交给 Browser/agent-browser。站点扫描与修复应交给当前环境中已安装且匹配的审计流程;不要硬路由到未验证存在的 Skill。
开始前写出以下合同:
Local Web Surface Contract
- Surface: <name>
- Canonical URL: http://<name>.localhost:<port>/
- Data owner: <repo/module>
- Transport owner: <existing daemon or new service>
- Read boundary: <what may be displayed>
- Publish boundary: <none or what may leave the machine>
- Write boundary: <none or exact mutations>
- Access/threat boundary: <trusted local user/processes, or exact authentication/authorization>
- Launcher: <none or App name>
- Done signals: <evidence selected by Change surfaces; Host/handler-only = focused tests + diff scope + curl 200/421/404>
若用户已授权自主完成,可从代码和本机状态解析这些值,不重复询问。若选择会改变数据真相源、公开范围、访问/认证边界或占用未知服务端口,先停在一个决策问题上。
先从约束推导方案:
Write boundary 非 none 时,写入必须有一个受控端口;浏览器和 Agent 不直接拼 YAML/JSON。.app 只负责唤醒/打开,不承载业务和第二份服务生命周期。.localhost 及其子域由客户端作为 loopback 特殊域处理;不要为常规 *.localhost 别名修改 /etc/hosts。实现前仍应以当前系统上的 DNS/curl 结果验证,而不是只凭规范推断。
把职责放回拥有它的 bounded context:
| 边界 | 拥有什么 | 不拥有什么 |
|---|---|---|
| Domain/Data owner | 数据模型、校验、所需 repository、内容过滤、HTML/DTO 产物 | 端口、LaunchAgent、全局 Host 表 |
| Local application | 页面 handler、应用路由、用例编排 | daemon 生命周期、其他 surface 的内部实现 |
| Loopback gateway | TCP listener、精确 Host 分发、body 上限、响应桥接 | surface 业务规则、数据文件格式 |
| Launcher | 登录自启、.app、打开 canonical URL | 第二个 server、数据写入、业务状态 |
依赖方向固定为:gateway 依赖一个窄的 value contract;data owner 不反向依赖 gateway。跨仓库集成时,传递普通 request/response 值或加载一个稳定 handler 入口,不把 domain 类和 storage 细节复制进 gateway。
高内聚体现在:一个数据变更的校验、并发和持久化都留在 repository;低耦合体现在:新增 surface 只增加 Host 映射、handler 入口和 launcher spec,不修改其他 surface 的业务分支。
先按实际 diff 选择最小验收面,不因 Skill 覆盖完整产品生命周期就默认执行所有检查:
| 变更面 | 典型改动 | 最小必需证据 |
|---|---|---|
| Host/handler-only | exact Host 映射、只读 handler、跨 surface 路由 | focused gateway/handler tests、diff scope、curl 的 canonical 200/未知 Host 421/跨 surface 404 |
| Lifecycle/launcher | listener 启动方式、LaunchAgent、installer、.app opener | 加做 plist、tracked PID、单 listener、重复安装和 launcher 参数验收 |
| UI | 页面结构、交互、响应式 | 加做合同相关的真实浏览器、Console、桌面与移动 viewport |
| Write/data | mutation、repository、文件持久化 | 加做 schema、ETag、并发、atomic write、临时 fixture 与失败路径 |
| Public projection | local/public catalog 或 sync | 加做临时 public sync 与 private/local-only 排除 |
Host/handler-only 仅在现有 listener 与生命周期不变、没有 UI/写入/发布改动时成立;不要为它重装 LaunchAgent、重复查 PID、跑双 viewport 或执行全仓验证。每轮改动后重新看 diff;一旦跨入其他行,就只补对应行的证据。仓库自身明确要求的检查仍然优先。
编辑前完成:
AGENTS.md 和架构/测试文档。git status --short;保留现有 dirty changes,禁止重置或顺手整理。Change surfaces。只有涉及 lifecycle/launcher 时,才用 lsof -nP -iTCP:<port> -sTCP:LISTEN、launchctl print、进程命令和 launcher 代码确认真实生命周期。package.json、lockfile 与本机二进制确认 Node、runner、依赖版本。.app、LaunchAgent、数据文件、writer 或发布过滤;优先扩展现有模块。在写代码前形成最小 surface 表:
| Surface | Exact Host | Owner | Reads | Writes |
|---|---|---|---|---|
| existing | existing.localhost:<port> | existing repo | existing data | existing API |
| new | new.localhost:<port> | data repo | explicit allowlist | explicit commands or none |
必须明确:
421,不能回落到默认管理页。Read boundary 涉及公开/私有内容时,必须把“本地可见”和“允许发布”写成两个独立投影;意图不明确或页面可能被他人访问时,本地 reader 默认 fail closed,只展示显式公开内容。private / local-only 只描述“不进入 public projection”,不承诺保密。loopback 服务会替调用方读取文件;同机其他账户或进程可能直接发 HTTP。Access/threat boundary 若不信任它们,必须加入真实认证/授权,或停止暴露该内容。Write boundary 非 none 时,写请求才至少检查 canonical Origin、Content-Type: application/json、应用标记 header、body 上限和 If-Match。Origin 与应用 header 主要约束浏览器写入,不是客户端身份。只在 surface 读取带发布状态的文章或文档时启用本节。不要把 public 同时当作本地读取权限和发布资格,除非用户明确要求两者完全相同。
当用户确认这是个人 loopback workspace、Access/threat boundary 允许当前本机调用者,并要求本地查看公开与私密成文时:
posts/**/*.md;接纳显式布尔 public: true 与 public: false。public === true。不要为满足本地预览去放宽发布脚本。public 的记录既不展示也不发布,并只报告相对路径和元数据错误,不返回正文。raw/、notes/、digests/)不属于文章 catalog;只有独立 surface 合同明确纳入时才读取。visibility: public | private、目录分类和规范化 tags。页面提供 all/public/private、category、tag 与搜索的组合筛选。当页面不是个人 loopback workspace、用户没有确认可显示私密内容,或访问边界不能保护敏感内容时,继续 fail closed,仅展示显式 public: true。若 public: false 代表真正机密而非发布状态,必须先加认证/授权,不能把 local-only 标签当作保护。
行为变更按 RED → GREEN → REFACTOR:
Write boundary 非 none 时覆盖强 ETag、缺 If-Match、stale revision、同进程串行、revision 重检和临时文件清理。只有不可消除的多个 OS 进程会直接写同一文件时,才增加跨进程 lock、崩溃恢复、活 owner 检查和 replacement-lock 测试。不要先写整套实现再补快照测试。每个发现的运行时 bug 先补能失败的回归测试,再改实现。
只在 Write boundary 非 none 且存储为 YAML/JSON 单文件时启用本节。repository 至少做到:
If-Match。finally 只清理自己 token 对应的 temp/lock;删除前重新核对 owner,绝不删除已被新 owner 替换的 lock。412,缺前置条件返回 428。优先交付无构建依赖的响应式页面,除非现有应用已有框架:
textContent;只有经过受控 sanitizer/安全 Markdown renderer 的 HTML 才可 innerHTML。aria-live 状态。412 明确提示 reload/retry。390x844 的移动 viewport。gateway 只监听 127.0.0.1(或明确验证过的 loopback),并把传入 header 缩到 handler 实际需要的集合。loopback/Host 隔离不等于认证;按 Access/threat boundary 对敏感读取和写入增加真实授权。body 超限时排空请求,不要销毁底层 socket;否则客户端可能收不到稳定 413。
macOS 登录服务遵守:
~/Library/LaunchAgents/<label>.plist,使用 RunAtLoad + KeepAlive。ProgramArguments 直接执行 node --import tsx <absolute-cli.ts> web;只做环境准备且最后 exec node ... 的 shell 也可保持同一 PID。不要让 LaunchAgent 只跟踪会再 spawn 子进程的 tsx CLI wrapper,否则 bootout 可能留下孤儿 listener。WorkingDirectory、logs 与 PATH 使用绝对值;plutil -lint 必须通过。.app 是薄 opener:exec <cli> open-web <surface>。每个 app 有独立 bundle ID/name,但不启动第二份 daemon。state = running、error log 无 EADDRINUSE。先按 Change surfaces 选择证据。Host/handler-only 的完整默认验收只有三项:focused gateway/handler tests;git diff --check 与范围核对;临时或既有安全 listener 上用 curl --noproxy '*' 证明 canonical Host 200、未知 Host 421、跨 surface 路由 404。这类改动默认不要求 full tests/typecheck/build、LaunchAgent 重装、PID/lsof、浏览器或 public sync。
diff 扩大后,按新增变更面补充以下检查,不机械执行无关项:
git diff --check,确认没有范围外文件、secret、临时 lock 或 fixture。plutil -lint 涉及的 plist;检查每个变更的 .app/Contents/MacOS/launcher 的 surface 参数。launchctl print gui/<uid>/<label> 显示 state = running 且有唯一 tracked PID。lsof 证明目标端口只有一个 loopback listener,且 tracked PID 就是 listener PID,而非短命 wrapper。curl --noproxy '*':每个 canonical Host 返回正确页面/API;未知 Host 421;跨 surface 路由不泄露;合同包含 body guard 时再证明超大 body 稳定 413。public:false 与合同列出的其他本地内容没有进入公共产物;若本地 reader 允许私密内容,再用 API 和浏览器分别证明它们确实进入本地列表、详情、搜索/筛选与 deep link。若 UI CRUD 已由临时 repository/handler 集成测试覆盖,真实浏览器验收可以只读;不要用“为了验收”作为改动用户数据的理由。
EADDRINUSE:先解析 tracked PID、listener PID、父子/进程组和完整命令,并搜索应用是否主动 spawn/fork/daemonize;只终止已验证属于该服务的进程。修 installer 后重复安装验证,不只手工 kill 一次。503,不暴露本地绝对路径和 stack。Origin、Host、ETag、header 与 socket 行为,不用关闭安全 guard 取巧。只在真实信号齐全时声明完成:
Local Web Surface Result
- URLs: <canonical URLs>
- Launchers: <none | apps + LaunchAgent when that change surface exists>
- Data ownership: <source of truth + only writer>
- Security boundaries: <Host/Origin/access-auth/local visibility/publication/path controls>
- Verification: <exact evidence selected by Change surfaces>
- User data touched during QA: no | <explicit details>
- UNVERIFIED: none | <blocked check and reason>
未经用户授权,不 stage、commit、push、deploy 或改写真实业务数据。
agents/openai.yaml (opens in a new tab)evals/evals.json (opens in a new tab)evals/fixtures/minimal-loopback-gateway/package.json (opens in a new tab)evals/fixtures/minimal-loopback-gateway/server.mjs (opens in a new tab)evals/fixtures/minimal-loopback-gateway/server.test.mjs (opens in a new tab)evals/trigger-eval.json (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/adonis-skills:local-web-surfacefrom adonis-skills
npx claudepluginhub adonis0123/adonis-skills --plugin adonis-skills34 skills in this plugin
/agent-dispatchPick the lightest agent setup for coding, review, drafting or design research: do it yourself, fan out 2-3 workers across local CLIs and accounts (Claude Code, Codex, Grok, Cursor), run a scoped architecture loop, or brief independent researchers; choose a cross-model reviewer and track dispatched work on a Run Board. Use when work may need delegation, or the user asks to dispatch, parallelize, run several agents or accounts, get another AI's review or independent design opinions, or check dispatched work. 中文触发:派活、并行、多开几个 agent、分给多个账号 / codex / grok、找另一个 AI 审、多方意见、派出的任务进行到哪了。Not for trivial edits, a single diff review (agentic-review-handoff) or the session list (sideby sessions); inside another named workflow, only size its workers./agentic-review-handoffValidate review findings, run auto Git review-fix-re-review loop, DecisionConsult, or DDD/cohesion review. Requires Git & review/consult intent./agent-practice-auditScore local coding-agent usage (Claude/Codex/Grok/WorkBuddy/agy) against official docs into HTML report. Triggers: agent 用法体检、实践评分. Never edits config./agent-skill-evaluationUse when comparing or trial-testing agent skills before installing — including GitHub/skills.sh URLs, 测试一下/值不值得装, package screening, and A/B artifact runs./agent-symlink-initInitialize or migrate agent-skill symlinks in any repository for Claude Code, Codex, Cursor, and Antigravity (agy) / Gemini setups. Use when a project needs `.claude/skills` linked to `.agents/skills`, `AGENTS.md` linked to `CLAUDE.md`, checks for `GEMINI.md` or `.agents/skills.json`, migration away from `.ruler`-based AI rules, or removal of legacy `sync-llm-skills` copy/sync setups. Trigger on requests about Claude, Codex, Cursor, or Antigravity (`agy`) / Gemini skill symlinks, AGENTS/CLAUDE/GEMINI rule links, `.claude/skills` setup, replacing copied skill folders with symlinks, or cleaning old ruler/sync automation./architecture-hardening-loopRun bounded architecture scan-triage-fix-review-rescan loop on explicit code scope until no evidence-backed DDD/cohesion fixes remain.Other plugins' skills for the same job