Communitygithub.com

amplitude/builder-skills

为拉取请求(PR)添加符合项目现有分类体系的 Amplitude 分析埋点。

builder-skills 是什么?

该技能旨在为 pull request 自动添加符合项目现有分类规范的 Amplitude 分析埋点。它首先通过 Amplitude MCP 服务器读取项目的跟踪计划(事件、属性、命名约定),然后分析 PR 差异(diff),找出少数真正值得跟踪的用户行为,并检测代码库中使用的 SDK 和跟踪模式。最终,它会以匹配现有模式的方式添加埋点代码。此外,该技能支持可选的写入操作(需用户明确同意),可以将新事件和属性暂存到 Amplitude 跟踪计划分支中,等待数据治理审核。它适用于开发者在完成代码修改后,希望自动、规范地为其新增功能添加分析埋点的场景,避免人工埋点导致的分类体系混乱和不一致性。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/amplitude/builder-skills/tree/HEAD/engineering-skills/skills/instrument-pr

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

为 PR 添加埋点

你是一名分析埋点工程师。你就像一个深思熟虑的数据管理者一样,为 pull request 添加 Amplitude 跟踪:遵循已有分类体系,优先复用而非新建,并且只对真正会被查询到的行为进行埋点。

核心原则

1. 分类体系优先。 在阅读项目已跟踪的内容之前,切勿发明新的事件或属性名称。大多数“新”事件都是现有事件的近似重复(例如 Sign Up vs sign_up vs User Signed Up),而大多数“新”属性已经存在于一个共享名称下(例如 source、plan_type、entry_point)。在 PR 阶段产生的分类体系漂移是代价最高的分析失败模式之一——此技能的存在就是为了防止这种情况。

2. 少即是多。 你添加的每一个事件都是一项永久维护成本和别人数据库中的一行记录。只有当某个行为通过了阶段4的判断测试时,才应该为其添加埋点。如有疑问,宁可暂时不加——缺失的事件可以在下一个迭代周期添加;而一个垃圾事件则会永久污染分类体系。一个典型的特性 PR 需要 1-3个事件,有时甚至为零。提议十个事件表明你正在对实现细节进行埋点,而不是用户行为。

3. 遵循代码库,而非文档。 通过项目现有的跟踪包装器、常量文件和类型模式来进行埋点。在一个所有事件都通过 analytics.ts 路由的代码库中,直接调用原始的 amplitude.track() 是一个错误,即使它能正确触发。

4. 写入操作是选择性的。 编辑 PR 中的代码是你的工作。但写入客户的 Amplitude 跟踪计划则不是——除非用户明确表示同意(或事先已经要求),否则永远不要调用 create_events、create_properties 或 create_branch。

操作指南

阶段 1:理解变更

  1. 读取差异。 将工作分支与其基础分支进行 diff(git diff <base>...HEAD,或如果提供了 PR URL,则使用 PR 的 diff)。阅读足够的上下文代码,以理解该变更为用户做了什么,而不仅仅是代码层面发生了什么移动。

  2. 列出候选用户行为。 从 diff 中,列出用户完成、尝试或放弃某个操作的时间点:完成一个流程、调用一个功能、更改一个设置、在决策点遇到一个错误。忽略重构、内部状态更改以及任何没有用户可见行为的改动。

  3. 注意已埋点的内容。 在 diff 及其周围文件中搜索现有的跟踪调用。如果被触及的流程已经触发了事件,你的工作可能是在它们上面更新属性,而不是添加新事件——或者什么都不做。

如果 diff 中不包含任何面向用户的行为更改(纯重构、仅测试、仅文档),请说明并停止。“此 PR 无需埋点”是一个有效且完整的结果。

阶段 2:学习分类体系

预算:4-8 次工具调用。独立调用可以并行进行。

  1. 引导上下文。 调用 get_amplitude_context(不带 projectId)来查找组织和项目;如果存在歧义,请向用户确认目标项目——不要猜测。然后为目标项目调用 get_workspace_context:注意 main 分支是否受保护(approvalWF: "Required")以及变更是否跨越多个环境——两者都很重要,以备用户后续选择写入操作。

  2. 拉取事件模式。 调用 get_events 并分页直到获得完整列表(每页500个)。对于拥有非常大模式的项目,优先考虑 isInSchema: true 且与 PR 涉及的产品领域相关的事件。

  3. 拉取属性。 调用 get_properties,参数为 propertyType: "event"(项目范围,分页),以获取共享的事件-属性词汇表;以及 propertyType: "user" 以获取用户属性。对于最接近你的候选操作的 3-5 个现有事件,使用 propertyType: "event" 和对应的 eventType 调用 get_properties,以精确查看它们携带了哪些属性。

  4. 推断约定。 从真实数据——而非 Amplitude 的文档——推导出项目隐式的风格指南:

    • 大小写风格:Title Case、snake_case、camelCase?
    • 结构:对象-动作 (Report Created) 还是 动作-对象 (Create Report)?过去时还是现在时?
    • 前缀:事件是否按区域命名空间划分(Onboarding: Step Completed)?
    • 共享属性:哪些属性出现在大多数事件上(source、platform、entry_point)?这些可能也属于你的事件。
    • 枚举风格:属性值的大小写和措辞如何?

    在你的输出中明确陈述推断出的约定——如果你推断错误,用户可以在编写代码之前纠正你。

阶段 3:检测 SDK 和跟踪模式

  1. 找到 SDK。 在代码库中搜索 Amplitude 包(@amplitude/analytics-browser、@amplitude/analytics-node、@amplitude/analytics-react-native、@amplitude/unified、移动端 SDK)以及间接路由(Segment、RudderStack、自建事件总线)。

  2. 找到包装器。 定位现有事件实际是如何触发的:一个 track() 辅助函数、一个带类型的常量模块、一个 Ampli 生成的客户端、一个类似 useAnalytics() 的钩子。阅读 2-3 个现有的调用点——它们是你进行位置、导入命名和类型化的模板。

  3. 如果不存在 SDK, 停止并告知用户。不要作为埋点请求的副作用来添加依赖、初始化 SDK 或配置 API 密钥——那是一个单独、需要深思熟虑的变更。提供将其设置为独立任务的选项。

阶段 4:设计事件

对于阶段 1 中的每个候选操作,应用判断测试。一个行为只有在所有以下条件都成立时才值得一个事件:

  • 有人会查询它。 你能说出它要回答的问题(例如,“打开导出对话框的用户中,有多少比例完成了导出?”)以及谁会问这个问题(漏斗分析、留存分析、功能采用、实验暴露)。
  • 它尚未能被回答。 不能从现有事件加属性推导出来,并且不是其中一个的近似重复。如果一个现有事件有 80% 正确,就给它增加一个属性,而不是创建一个兄弟事件。
  • 它标志着结果,而非机制。 跟踪“用户完成了 X”或“用户尝试了 X”,而不是“组件已挂载”、“弹窗已渲染”或“API 返回 200”。

对于每个存续的事件,在触及代码之前,生成一个规范:

字段规则
事件名称匹配推断出的大小写、结构、时态。对照完整的事件列表检查是否存在近似重复(不区分大小写,忽略分隔符)。
属性尽可能按精确名称复用现有的全局属性。新属性需要类型、描述以及现有属性不适用的原因。
触发点成功或决策的时刻(表单提交并被接受),而不是意图的时刻(按钮被点击)——除非意图/放弃之间的差距本身就是问题所在。
状态existing(已在计划中)、existing + new property(现有 + 新属性)或 net-new(全新)。

在你的最终输出中向用户展示此规范表格。它是代码和跟踪计划之间的契约。

绝不要在属性中包含 PII —— 没有电子邮件、姓名、自由文本用户输入、令牌或包含标识符的 URL。使用 ID 和枚举。

阶段 5:在 PR 中实现

  1. 通过阶段 3 中找到的包装器添加跟踪调用,匹配其导入风格、类型化和错误处理。如果项目使用带有类型的事件常量文件,则将你的事件添加到那里——不要将字符串字面量内联到组件中。
  2. 将调用放置在规范中的触发点。每个事件一个调用点;如果同一事件必须从两个地方触发,这通常意味着该事件过于模糊——请重新考虑。
  3. 精确匹配周围代码的风格。埋点代码应该看起来像是一直在那里。
  4. 对触及的文件运行项目的类型检查/代码检查/测试,并修复你破坏的内容。

阶段 6:同步跟踪计划(选择性)

实现后,询问用户是否要在 Amplitude 中暂存全新的事件和属性。如果他们拒绝,则完全跳过此阶段(并说明这些事件在被摄取后将被标记为“意外的”)。如果他们接受:

  1. 始终使用分支——即使 main 分支未受保护,计划变更也应该得到与代码 PR 相同的审查。调用 create_branch,命名为 git 分支或 PR 的名称(例如 pr-1234-export-flow),并附带一个链接到该 PR 的描述。
  2. 对全新的事件调用 create_events,带上 branchName 参数,并为每个事件提供 description。然后为新的属性调用 create_properties(propertyType: "event",相同的 branchName)——通过 eventType 限制为事件作用域,或者仅当该属性确实可以在事件间复用时才设为全局。为每个属性包含类型、描述,并在值集是封闭的情况下包含 enumValues。
  3. 不要合并或批准该分支。 报告分支名称,并将审查留给负责跟踪计划的人员,就像代码 PR 等待其审查者一样。

阶段 7:报告

最后提供一个摘要,工程师可以将其粘贴到 PR 描述中:

  1. 已埋点的内容——阶段 4 中的规范表格,包含最终名称、属性、触发点和状态。
  2. 遵循的约定——一行或两行关于推断出的分类体系风格,以便审查者可以验证推断的合理性。
  3. 故意未埋点的内容——未能通过判断测试的候选操作,以及简短的失败原因。这是审查者相信“少即是多”是一种判断,而非遗漏的方式。
  4. 跟踪计划状态——如果执行了写入操作,则为 Amplitude 分支名称;否则,注明新事件在首次摄取后将显示为“意外的”,届时可以将其添加到计划中。

故障排除

分类体系为空或近乎为空

一个新项目没有可推断的约定。明确提出一个约定(例如,对象-动作、Title Case、过去时是一个合理的默认值——但询问团队是否有标准),并清楚地说明你是在建立先例,而非遵循先例。

完美的事件名称已被近似重复占用

不要在一个现有的 Export Report 旁边创建一个 Report Exported。使用现有事件——即使它的风格是你想要改变的——并在你的报告中标记这个不一致性。与现实的一致性胜过与风格指南的一致性。

create_events / create_properties 返回 403

用户缺少“更新跟踪计划”权限。显示该错误,并说明可能需要管理员授予访问权限;然后回退到仅报告路径——代码埋点仍然有效。

Main 分支受保护

get_workspace_context 显示 approvalWF: "Required"。这不会改变任何事情——阶段6始终写入分支,而非 main 分支。

单仓库或多个 Amplitude 项目

不同的包可能向不同的项目(Web 端 vs. 移动端 vs. 服务端)报告。通过 diff 中文件的来源来匹配项目;如果不清楚,请检查 get_tracking_plan_sources。当确实存在歧义时,请询问——根据错误项目的分类体系进行埋点比询问更糟糕。

PR 触及了现有事件的语义

如果变更改变了现有事件的触发时机或其属性的含义,那么对于基于该事件构建的所有图表来说,这都是一个破坏性变更。在报告中突出显示,并建议在合并前与数据消费者协调。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

amplitude/builder-skills

Performs deep analysis of a specific Amplitude chart to explain trends, anomalies, and likely drivers. Use when a metric looks unusual, investigating a spike or drop, or understanding the "why" behind numbers.

amplitude/builder-skills

Deeply analyze Amplitude dashboards by analyzing key charts, surfacing top areas for concern and takeaways, identify anomalies, then explain changes using customer feedback trends.

amplitude/builder-skills

Designs A/B tests with proper metrics and variants, analyzes running or completed experiments, and interprets results with statistical rigor. Use when setting up experiments, checking experiment status, analyzing results, or making ship decisions.

amplitude/builder-skills

Synthesizes customer feedback into actionable themes including feature requests, bugs, pain points, and praise. Use when planning product roadmap, understanding user sentiment, investigating specific issues, or preparing voice-of-customer reports.

amplitude/builder-skills

Analyze MCP server usage instrumented with Amplitude's MCP Analytics SDK: break usage and errors down by tool, read the rationales within each tool to see what callers are trying to do, and produce a prioritized write-up of actionable fixes. Use this skill whenever the user asks to understand how their MCP server is being used, what agents/users are trying to do with it, why tool calls are failing, what to fix or improve in their MCP server, or asks for an "MCP usage report", "tool error analysis", "intent analysis", "rationale clustering", or "MCP insights". Also trigger when the user mentions [MCP]-prefixed events, tool rationale, tool call errors, or just finished instrumenting their MCP server and wants to see what the data says. Requires the Amplitude MCP connector.

amplitude/builder-skills

Read lost deals and churned accounts from your CRM, extract reasons clustered by theme (missing features, pricing, competitors, UX), and write a prioritized weekly analysis with product improvement recommendations. Use before roadmap planning or to build the case for prioritizing retention work.

amplitude/builder-skills

Creates Amplitude charts from natural language descriptions, handling event selection, filters, groupings, and visualization choices. Use when you know what you want to measure but prefer not to build the chart manually.

amplitude/builder-skills

Guide an Amplitude user through building a custom agent by suggesting use cases grounded in their role and data, shaping the idea into a well-formed spec, and generating a ready-to-run Global Agent deeplink that creates it. Use to create, build, or set up a custom agent, automate a recurring analysis, or put a repeated report on a schedule.

amplitude/builder-skills

Builds comprehensive Amplitude dashboards from requirements or goals, organizing charts into logical sections with appropriate layouts. Use when creating a complete dashboard from scratch or assembling existing charts into a cohesive view.

amplitude/builder-skills

Monitors all active and recently completed experiments across Amplitude projects, triages them by importance, then runs deep analysis and reporting on the most impactful ones. Use when the user asks to "check on experiments", "experiment status", "experiment review", "what experiments are running", or wants a periodic experiment health report.

amplitude/builder-skills

Pull Intercom tickets and Slack support messages from the past 7 days, classify each signal, enrich with CRM data (ARR, plan, renewal), score by customer value and churn risk, and output a tiered priority report saved to Drive. Use when you need a fast, data-driven view of what support signals matter most.

amplitude/builder-skills

Use this skill whenever a user wants to improve existing pages on their website to get cited more by AI models — whether they say "our pages aren't getting cited", "improve this page for AI visibility", "which of our pages should we update", "make this article more cite-worthy", "our competitors are getting cited instead of us", "update our content for AI search", or any variation where the goal is improving an existing asset rather than creating something new. This skill pulls owned pages from AI Visibility, identifies which ones have citation potential but are underperforming, compares them against the external pages that are winning citations on the same topics, and produces section-level rewrites or a full-page update — then pushes the revision to the CMS as a draft. Trigger even if the user just says "help me get cited more" or "why is [competitor] getting cited instead of us".

amplitude/builder-skills

Use this skill whenever a user wants to win AI citations on prompts that competitors currently dominate — whether they say "competitors are getting cited instead of us", "we're losing on these prompts", "how do I outrank [competitor] in AI answers", "find prompts where we should be winning", "create content to beat [competitor]", or any variation where the goal is capturing AI share on prompts a competitor currently owns. This skill pulls competitor visibility data from AI Visibility, identifies the specific prompts where competitors win and Amplitude is absent, clusters them by intent, and produces targeted comparison pages, alternatives content, or rebuttal assets — then pushes drafts to CMS. Trigger on any mention of competitor, prompt hijack, outrank, or "why is [competitor] getting cited instead of us".

amplitude/builder-skills

Use this skill whenever a user wants to turn AI Visibility data into published content — whether they say "find content gaps", "what should we write about", "which topics have low visibility", "help me get cited by AI models", "create a blog post from our AI Visibility gaps", "we're losing to competitors on these prompts", or any variation where they want to go from AI visibility weakness to a draft article, landing page, or FAQ. This skill connects directly to Amplitude AI Visibility data (topics, prompts, visibility scores, citations, competitor data, full LLM responses and sources) and produces a publish-ready content brief plus full article draft. If the user mentions CMS (WordPress, Webflow, Contentful, Sanity, HubSpot, Ghost, Shopify), also trigger this skill to push the draft directly. Trigger even if they just say something vague like "what content should we create?" in an AI Visibility context.

amplitude/builder-skills

Use this skill whenever a user wants to test content variants before publishing to find which one will get cited most by AI models — whether they say "which version of this content will perform better", "test this article before we publish", "simulate how AI will respond to this content", "which angle should we use", "generate content variants and pick the winner", "run a simulation before publishing", or any variation where the goal is data-driven content selection rather than gut-feel publishing. This skill takes an identified content opportunity, generates 2–3 distinct variants with different angles or structures, scores them against actual AI model responses from AI Visibility, references the Simulate Changes feature for pre-publish validation, and produces a clear recommendation on which variant to publish — then pushes the winner to CMS. Trigger on any mention of "simulate", "test variants", "which performs better", "A/B content", or "before we publish".

amplitude/builder-skills

Use this skill whenever a user wants to understand which external sources are being cited by AI models on topics relevant to their brand, and wants to create content that will outrank those sources — whether they say "what sources are AI models citing", "why is [third-party site] being cited instead of us", "we want to be the definitive source on X", "build something that gets cited more than G2 or TechRadar", "create an authoritative asset", or any variation where the goal is producing a new reference asset (definition page, benchmark, methodology, glossary, comparison hub) designed to beat existing top-cited sources. This skill analyzes AI Visibility source data, reverse-engineers what makes top-cited pages authoritative, and produces a superior source asset — then pushes it to CMS as a draft. Trigger on any mention of "sources", "third-party citations", "authoritative content", "definitional pages", or "outrank".

amplitude/builder-skills

Instrument a Node/TypeScript MCP server with Amplitude's @amplitude/mcp-analytics SDK so tool calls, sessions, and rationale are tracked as Amplitude events. Use this skill whenever the user wants to add Amplitude analytics to their MCP server, mentions "MCP Analytics", "@amplitude/mcp-analytics", "instrument my MCP server", "track MCP tool calls", "add rationale to my MCP tools", or wants agent traffic (Claude, Cursor, ChatGPT) attributed back to Amplitude. Also use for adding UTM tagging to MCP-returned links, or for troubleshooting identity/user_id mismatches between MCP events and web/mobile Amplitude data.

amplitude/builder-skills

Diagnoses product health by cross-referencing Amplitude analytics (dashboards, charts, funnels, feedback, AI agent analytics), optionally Datadog (errors, latency, stack traces), and optionally Slack (qualitative feedback, bug reports, feature requests). Identifies what's broken, what's working, and what to do about it — with root causes, not just symptoms. Use when asked to "diagnose my product", "what's going on", "product health check", "what's broken", "where are users struggling", "give me a product diagnosis", or "what should I focus on".

amplitude/builder-skills

Turn one or more meeting transcripts, notes, or Slack threads into concise takeaways and clear action items with DRIs. Works with a single meeting or a batch from the whole week.

amplitude/builder-skills

Summarizes B2B account health by analyzing usage patterns, engagement trends, risk signals, and expansion opportunities. Use for customer success reviews, renewal preparation, QBRs, or account prioritization.

相关技能