pp-clarity
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePP Clarity — Printing Press CLI
PP Clarity — Printing Press CLI
Prerequisites: Install the CLI
前提条件:安装CLI
This skill drives the binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:
clarity-pp-cli- Install via the Printing Press installer:
bash
npx -y @mvanhorn/printing-press install clarity --cli-only - Verify:
clarity-pp-cli --version - Ensure (or
$GOPATH/bin) is on$HOME/go/bin.$PATH
If the install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.23+):
npxbash
go install github.com/mvanhorn/printing-press-library/library/other/clarity/cmd/clarity-pp-cli@latestIf reports "command not found" after install, the install step did not put the binary on . Do not proceed with skill commands until verification succeeds.
--version$PATHMicrosoft Clarity's client API is made of JavaScript calls and HTML attributes, so this CLI treats it as an instrumentation assistant instead of a fake REST wrapper. It can fetch the public tag script, render copy-safe snippets, and audit local HTML for the calls Microsoft documents.
本技能基于二进制文件运行。在调用本技能的任何命令之前,必须确认CLI已安装。如果未安装,请先执行以下步骤:
clarity-pp-cli- 通过Printing Press安装程序安装:
bash
npx -y @mvanhorn/printing-press install clarity --cli-only - 验证安装:
clarity-pp-cli --version - 确保(或
$GOPATH/bin)已添加到$HOME/go/bin环境变量中。$PATH
如果安装失败(无Node环境、离线等情况),可以改用Go直接安装(要求Go 1.23及以上版本):
npxbash
go install github.com/mvanhorn/printing-press-library/library/other/clarity/cmd/clarity-pp-cli@latest如果安装后执行提示“command not found”,说明安装程序未将二进制文件添加到中。请在验证成功前不要执行本技能的命令。
--version$PATHMicrosoft Clarity的客户端API由JavaScript调用和HTML属性组成,因此本CLI工具作为埋点助手,而非模拟REST包装器。它可以获取公开的标签脚本、生成可直接复制使用的代码片段,并审核本地HTML文件中是否包含Microsoft官方文档中提到的调用。
When to Use This CLI
何时使用本CLI工具
Use this CLI when you need to add, review, or explain Microsoft Clarity browser instrumentation. It is strongest for generating snippets and auditing local HTML; it is not a replacement for the Clarity dashboard.
当你需要添加、检查或解释Microsoft Clarity浏览器埋点代码时,可以使用本CLI工具。它最擅长生成代码片段和审核本地HTML文件;但它不能替代Clarity控制台。
When Not to Use This CLI
何时不使用本CLI工具
Do not activate this CLI for requests that require creating, updating, deleting, publishing, commenting, upvoting, inviting, ordering, sending messages, booking, purchasing, or changing remote state. This printed CLI exposes read-only commands for inspection, export, sync, and analysis.
请勿在需要创建、更新、删除、发布、评论、点赞、邀请、下单、发送消息、预订、购买或更改远程状态的请求中使用本CLI工具。本CLI仅提供用于检查、导出、同步和分析的只读命令。
Unique Capabilities
独特功能
These capabilities aren't available in any other tool for this API.
这些功能是其他同类型API工具所不具备的。
Instrumentation authoring
埋点代码编写
-
— Render a complete Clarity tracking snippet for a project ID, plus focused snippets for every documented client API call.
snippet installUse this when adding Clarity to a site or handing implementation-ready code to another agent.bashclarity-pp-cli snippet install abc123 --format html
-
— 为指定项目ID生成完整的Clarity跟踪代码片段,同时为每个已文档化的客户端API调用生成针对性的代码片段。
snippet install当你需要为网站添加Clarity埋点,或向其他Agent提供可直接实现的代码时使用此命令。bashclarity-pp-cli snippet install abc123 --format html
Instrumentation review
埋点代码审核
-
— Inspect an HTML file for a Clarity tag script, masking attributes, and common window.clarity client API calls.
audit htmlUse this before shipping page changes that are supposed to include Clarity instrumentation.bashclarity-pp-cli audit html ./index.html --json --select found_project_id,calls
-
— 检查HTML文件中是否包含Clarity标签脚本、掩码属性以及常见的window.clarity客户端API调用。
audit html当你准备上线包含Clarity埋点的页面变更前,使用此命令进行检查。bashclarity-pp-cli audit html ./index.html --json --select found_project_id,calls
Command Reference
命令参考
tag — Inspect the Microsoft Clarity tracking tag script
- — Fetch the Clarity tracking tag script for a project ID
clarity-pp-cli tag <project_id>
Hand-written commands
- — Render the tracking snippet for a Clarity project ID
clarity-pp-cli snippet install - — Render the Cookie consent client API call
clarity-pp-cli snippet consent - — Render the custom identifiers client API call
clarity-pp-cli snippet identify - — Render the custom tags client API call
clarity-pp-cli snippet set - — Render the custom event client API call
clarity-pp-cli snippet event - — Render the session-priority client API call
clarity-pp-cli snippet upgrade - — Render Clarity mask or unmask HTML attributes
clarity-pp-cli snippet mask - — Check an HTML file for a Clarity install snippet and client API calls
clarity-pp-cli audit html - — Fetch Microsoft Clarity Data Export API live insights
clarity-pp-cli insights live
tag — 查看Microsoft Clarity跟踪标签脚本
- — 获取指定项目ID的Clarity跟踪标签脚本
clarity-pp-cli tag <project_id>
手动编写的命令
- — 为Clarity项目ID生成跟踪代码片段
clarity-pp-cli snippet install - — 生成Cookie授权客户端API调用代码
clarity-pp-cli snippet consent - — 生成自定义标识符客户端API调用代码
clarity-pp-cli snippet identify - — 生成自定义标签客户端API调用代码
clarity-pp-cli snippet set - — 生成自定义事件客户端API调用代码
clarity-pp-cli snippet event - — 生成会话优先级客户端API调用代码
clarity-pp-cli snippet upgrade - — 生成Clarity掩码或取消掩码HTML属性代码
clarity-pp-cli snippet mask - — 检查HTML文件中是否包含Clarity安装代码片段和客户端API调用
clarity-pp-cli audit html - — 获取Microsoft Clarity数据导出API的实时洞察数据
clarity-pp-cli insights live
Finding the right command
查找合适的命令
When you know what you want to do but not which command does it, ask the CLI directly:
bash
clarity-pp-cli which "<capability in your own words>"which02--help当你知道要执行的操作但不知道对应的命令时,可以直接询问CLI:
bash
clarity-pp-cli which "<用你自己的语言描述功能>"which02--helpRecipes
使用示例
Install Clarity
安装Clarity
bash
clarity-pp-cli snippet install abc123 --format htmlProduces the tracking snippet that belongs in the page head.
bash
clarity-pp-cli snippet install abc123 --format html生成可添加到页面头部的跟踪代码片段。
Add a custom event
添加自定义事件
bash
clarity-pp-cli snippet event newsletterSignupProduces the documented event call for a named user action.
bash
clarity-pp-cli snippet event newsletterSignup生成针对指定用户操作的已文档化事件调用代码。
Audit only high-gravity fields
仅审核关键字段
bash
clarity-pp-cli audit html ./index.html --json --select found_project_id,calls,mask_count,unmask_countNarrows audit output for agent consumption.
bash
clarity-pp-cli audit html ./index.html --json --select found_project_id,calls,mask_count,unmask_count缩小审核输出范围,方便Agent处理。
Auth Setup
认证设置
Client-side snippet commands only need the public Clarity project ID.
For Data Export API reads, set a token in the environment. Do not paste token values into chat or commit them to files:
bash
export PP_CLARITY_API_TOKEN="..."
clarity-pp-cli insights live --days 1 --dimension OS --jsonFor local agent testing, prefer the local token file:
bash
mkdir -p ~/.config/clarity-pp-cli
printf '%s' 'YOUR_TOKEN_HERE' > ~/.config/clarity-pp-cli/api-token
chmod 600 ~/.config/clarity-pp-cli/api-tokenThe command also accepts , , or .
MICROSOFT_CLARITY_API_TOKENCLARITY_API_TOKENPP_CLARITY_API_TOKEN_FILERun to verify setup.
clarity-pp-cli doctor客户端代码片段命令仅需公开的Clarity项目ID。
对于数据导出API的读取操作,需要在环境变量中设置令牌。请勿将令牌值粘贴到聊天中或提交到文件:
bash
export PP_CLARITY_API_TOKEN="..."
clarity-pp-cli insights live --days 1 --dimension OS --json对于本地Agent测试,建议使用本地令牌文件:
bash
mkdir -p ~/.config/clarity-pp-cli
printf '%s' 'YOUR_TOKEN_HERE' > ~/.config/clarity-pp-cli/api-token
chmod 600 ~/.config/clarity-pp-cli/api-token该命令也支持、或环境变量。
MICROSOFT_CLARITY_API_TOKENCLARITY_API_TOKENPP_CLARITY_API_TOKEN_FILE执行验证设置是否正确。
clarity-pp-cli doctorAgent Mode
Agent模式
Add to any command. Expands to: .
--agent--json --compact --no-input --no-color --yes-
Pipeable — JSON on stdout, errors on stderr
-
Filterable —keeps a subset of fields. Dotted paths descend into nested structures; arrays traverse element-wise. Critical for keeping context small on verbose APIs:
--selectbashclarity-pp-cli tag mock-value --agent --select id,name,status -
Previewable —shows the request without sending
--dry-run -
Offline-friendly — sync/search commands can use the local SQLite store when available
-
Non-interactive — never prompts, every input is a flag
-
Read-only — do not use this CLI for create, update, delete, publish, comment, upvote, invite, order, send, or other mutating requests
在任何命令后添加参数。该参数等价于:。
--agent--json --compact --no-input --no-color --yes-
可管道传输 — 标准输出为JSON,错误信息输出到标准错误
-
可过滤 —参数保留指定字段子集。点路径可深入嵌套结构;数组会遍历每个元素。这在处理冗长API时对缩小上下文范围至关重要:
--selectbashclarity-pp-cli tag mock-value --agent --select id,name,status -
可预览 —参数显示请求内容但不发送
--dry-run -
离线友好 — 同步/搜索命令在本地SQLite存储可用时可使用该存储
-
非交互式 — 从不提示用户,所有输入均通过标志参数提供
-
只读 — 请勿使用本CLI执行创建、更新、删除、发布、评论、点赞、邀请、下单、发送或其他会修改状态的请求
Response envelope
响应包
Commands that read from the local store or the API wrap output in a provenance envelope:
json
{
"meta": {"source": "live" | "local", "synced_at": "...", "reason": "..."},
"results": <data>
}Parse for data and to know whether it's live or local. A human-readable summary is printed to stderr only when stdout is a terminal — piped/agent consumers get pure JSON on stdout.
.results.meta.sourceN results (live)从本地存储或API读取数据的命令会将输出包装在来源信息包中:
json
{
"meta": {"source": "live" | "local", "synced_at": "...", "reason": "..."},
"results": <data>
}解析获取数据,通过判断数据是实时还是本地的。只有当标准输出为终端时,才会向标准错误输出人类可读的摘要;管道/Agent消费者仅会在标准输出获取纯JSON内容。
.results.meta.sourceN results (live)Agent Feedback
Agent反馈
When you (or the agent) notice something off about this CLI, record it:
clarity-pp-cli feedback "the --since flag is inclusive but docs say exclusive"
clarity-pp-cli feedback --stdin < notes.txt
clarity-pp-cli feedback list --json --limit 10Entries are stored locally at . They are never POSTed unless is set AND either is passed or . Default behavior is local-only.
~/.clarity-pp-cli/feedback.jsonlCLARITY_CLIENT_FEEDBACK_ENDPOINT--sendCLARITY_CLIENT_FEEDBACK_AUTO_SEND=trueWrite what surprised you, not a bug report. Short, specific, one line: that is the part that compounds.
当你(或Agent)发现本CLI存在问题时,可以记录反馈:
clarity-pp-cli feedback "the --since flag is inclusive but docs say exclusive"
clarity-pp-cli feedback --stdin < notes.txt
clarity-pp-cli feedback list --json --limit 10反馈条目会存储在本地文件中。除非设置了且传递了参数或设置了,否则反馈不会被POST发送。默认行为仅存储在本地。
~/.clarity-pp-cli/feedback.jsonlCLARITY_CLIENT_FEEDBACK_ENDPOINT--sendCLARITY_CLIENT_FEEDBACK_AUTO_SEND=true请记录让你感到意外的内容,而非正式的错误报告。简短、具体、单行描述:这样的反馈更有价值。
Output Delivery
输出交付
Every command accepts . The output goes to the named sink in addition to (or instead of) stdout, so agents can route command results without hand-piping. Three sinks are supported:
--deliver <sink>| Sink | Effect |
|---|---|
| Default; write to stdout only |
| Atomically write output to |
| POST the output body to the URL ( |
Unknown schemes are refused with a structured error naming the supported set. Webhook failures return non-zero and log the URL + HTTP status on stderr.
每个命令都支持参数。输出会发送到指定的目标,同时(或替代)标准输出,因此Agent无需手动管道即可路由命令结果。支持三种目标:
--deliver <sink>| 目标 | 效果 |
|---|---|
| 默认值;仅输出到标准输出 |
| 原子性地将输出写入 |
| 将输出体POST到指定URL(当使用 |
不支持的协议会返回结构化错误,并列出支持的协议类型。Webhook失败时会返回非零退出码,并在标准错误中记录URL和HTTP状态码。
Named Profiles
命名配置文件
A profile is a saved set of flag values, reused across invocations. Use it when a scheduled agent calls the same command every run with the same configuration - HeyGen's "Beacon" pattern.
clarity-pp-cli profile save briefing --json
clarity-pp-cli --profile briefing tag mock-value
clarity-pp-cli profile list --json
clarity-pp-cli profile show briefing
clarity-pp-cli profile delete briefing --yesExplicit flags always win over profile values; profile values win over defaults. lists all available profiles under so introspecting agents discover them at runtime.
agent-contextavailable_profiles配置文件是一组保存的标志值,可在多次调用中复用。当定时Agent每次运行都使用相同配置调用同一命令时,可以使用此功能——即HeyGen的“Beacon”模式。
clarity-pp-cli profile save briefing --json
clarity-pp-cli --profile briefing tag mock-value
clarity-pp-cli profile list --json
clarity-pp-cli profile show briefing
clarity-pp-cli profile delete briefing --yes显式标志始终优先于配置文件中的值;配置文件值优先于默认值。会在下列出所有可用配置文件,以便自省Agent在运行时发现它们。
agent-contextavailable_profilesExit Codes
退出码
| Code | Meaning |
|---|---|
| 0 | Success |
| 2 | Usage error (wrong arguments) |
| 3 | Resource not found |
| 5 | API error (upstream issue) |
| 7 | Rate limited (wait and retry) |
| 10 | Config error |
| 代码 | 含义 |
|---|---|
| 0 | 成功 |
| 2 | 使用错误(参数错误) |
| 3 | 资源未找到 |
| 5 | API错误(上游问题) |
| 7 | 速率限制(等待后重试) |
| 10 | 配置错误 |
Argument Parsing
参数解析
Parse :
$ARGUMENTS- Empty, , or
help→ show--helpoutputclarity-pp-cli --help - Starts with → ends with
install→ MCP installation; otherwise → see Prerequisites abovemcp - Anything else → Direct Use (execute as CLI command with )
--agent
解析的规则:
$ARGUMENTS- 为空、或
help→ 显示--help输出clarity-pp-cli --help - 以开头 → 若结尾为
install→ 安装MCP;否则 → 参见上方的前提条件部分mcp - 其他情况 → 直接使用(以标志执行CLI命令)
--agent
MCP Server Installation
MCP服务器安装
- Install the MCP server:
bash
go install github.com/mvanhorn/printing-press-library/library/marketing/clarity/cmd/clarity-pp-mcp@latest - Register with Claude Code:
bash
claude mcp add clarity-pp-mcp -- clarity-pp-mcp - Verify:
claude mcp list
- 安装MCP服务器:
bash
go install github.com/mvanhorn/printing-press-library/library/marketing/clarity/cmd/clarity-pp-mcp@latest - 注册到Claude Code:
bash
claude mcp add clarity-pp-mcp -- clarity-pp-mcp - 验证:
claude mcp list
Direct Use
直接使用
- Check if installed: If not found, offer to install (see Prerequisites at the top of this skill).
which clarity-pp-cli - Match the user query to the best command from the Unique Capabilities and Command Reference above.
- Execute with the flag:
--agentbashclarity-pp-cli <command> [subcommand] [args] --agent - If ambiguous, drill into subcommand help: .
clarity-pp-cli <command> --help
- 检查是否已安装:如果未找到,提供安装选项(参见顶部前提条件部分)。
which clarity-pp-cli - 将用户查询与上方“独特功能”和“命令参考”中的最佳匹配命令对应。
- 使用标志执行命令:
--agentbashclarity-pp-cli <command> [subcommand] [args] --agent - 如果存在歧义,查看子命令帮助:。
clarity-pp-cli <command> --help