跳到正文
Skillpedia
网站与界面(前端)41k · #6838

building-canvases

它能做什么

本技能创建和更新画布,即存放在 PostHog 内部并在安全框架中运行的小型交互式应用。适合希望在 PostHog 中使用自定义看板、文档、表单或小工具,而无需单独代码项目的人。

适用场景

  • ✓当你想要一个存放在 PostHog 内部的自定义看板、表单或文档时。
  • ✓当你需要修改或修复现有的画布应用时。
  • ✓当你想用 PostHog 数据构建一个小型可视化工具的时候。

技能链接

https://github.com/PostHog/posthog/blob/master/products/canvas/skills/building-canvases/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/PostHog/posthog/blob/master/products/canvas/skills/building-canvases/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为我做一个画布,展示我们的注册数据,并允许我选择日期范围。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会在 PostHog 内部编写画布源代码,检查其是否只使用了允许的库和声明的数据源,然后发布。PostHog 会构建画布,在新版本就绪之前,显示最近一次成功构建的版本。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Building canvases

A canvas is a client-side browser application that runs in a sandboxed iframe inside PostHog. Its source lives in PostHog — not in a repository — and you read and write it through the canvas-* tools. Never write a canvas to a local file; publishing through the tool is what saves it.

Canvas work can start from any ordinary task. A dedicated canvas mode or pre-created canvas is not required. When the user asks for a board, document, form, visualization, or small app that should live in PostHog, treat that as a canvas request and follow this skill.

This skill owns freeform canvases (standalone apps). Two other canvas kinds exist: grid canvases (widget grids, including the user's home canvas) and component canvases (reusable widgets grids place). When the target is a grid or home canvas, a placement, or a reusable widget/component, load composing-grid-canvases instead — it owns the store search → configure → fork → build ladder and the layout patch loop. Authoring a component's source still uses the implementation companions below.

Resolve the target canvas

  • If the task names a canvas id (canvas-initiated tasks do), that is the target. Do not create another.
  • Otherwise the target channel is the one the task was created in — named in the task's context (the channel_context block or the generation instructions). List that channel's canvases with canvas-list (scope with channel). If one is clearly what the request refers to — an earlier iteration of the same board or tool — build on it instead of creating a near-duplicate, and say so in your reply so the user knows where the result landed.
  • Only when nothing existing fits, create one with canvas-create in that same channel, named with a short descriptive title drawn from the request — never "Untitled canvas".
  • Never survey channels to choose a target yourself: use channel-list only to resolve a channel the USER named to its id. Its listing puts the personal #me channel first, and #me is never a default — a canvas filed there is invisible to everyone else. If the task names neither a canvas nor a channel, ask which channel to use instead of guessing.

Load the companion skills for the implementation

This skill owns canvas selection and the authoring lifecycle. The companion skills hold the implementation contracts. Load every companion that applies before writing source:

  • building-react-quill-canvases for dashboards, data boards, forms, tools, application-like state, or anything that should look native to PostHog. It owns allowed imports, Quill composition, theming, charts, loading and error states, and the date picker.
  • building-html-canvases for documents, articles, focused experiments, generative graphics, <canvas>, or WebGL work where application components add no useful structure. It owns semantic markup, direct browser APIs, animation cleanup, and non-Quill theming.
  • querying-canvas-data whenever the canvas reads PostHog data, captures events, or navigates. It owns the ph SDK, saved-insight preference, result shapes, variables, date ranges, progressive per-query loading, and declared data capabilities. Load it alongside either implementation skill when data is involved.
  • validating-and-publishing-canvases for every canvas. It owns project shape, capability declarations, validation diagnostics, guarded publishes, drafts, builds, and conflict recovery.

Mix implementation approaches when appropriate: React can own application chrome while browser graphics code owns a canvas element, or a mostly static page can mount one interactive island.

This is a judgment call, not a persisted mode — ask the user only when the choice changes a user-visible requirement you cannot infer.

Blocks

A canvas can contain premade blocks: numbers, goals, trends, top lists, funnels, retention, saved insights, live event feeds, SQL tables, filters, compare and refresh controls, and callouts. They are React components in src/blocks/ that people drag into the canvas in the desktop app, so they are part of your source. Read references/blocks.md before you change a canvas that has src/blocks/runtime.tsx.

Params

Expose the values a person may want to change as params. They can then change them in the desktop editor without a new task. Params are optional, but add them to each panel, card, or tool that has values worth changing: titles, copy, ev

常见问题

我需要自己托管应用吗?

不需要。画布源代码存储在 PostHog 中,并在那里渲染。

画布能加载我的 PostHog 数据吗?

可以。它通过内置桥接读取 PostHog 数据,并且必须声明所使用的洞察和事件。

它会覆盖别人的改动吗?

PostHog 会拒绝可能覆盖更新内容的发布,因此 AI 在再次发布之前必须先读取最新版本。

详情

作者的原始描述

Create or edit a PostHog freeform canvas — a sandboxed browser application (data board, document, form, small tool, graphics experiment) stored in PostHog and rendered by the desktop/web app. Use when a task asks to build, generate, update, or fix a standalone canvas app, or when a freeform canvas id is given as the publish target. For grid/home canvases, widget placements, or reusable components, use composing-grid-canvases instead. Covers resolving or creating the target canvas, choosing an implementation approach (React + Quill vs plain HTML/browser APIs), the read → edit → validate → publi

repo: PostHog/posthog

热度

GitHub 星标
41k
排名
#6838
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能