authoring-data-quality-checks
Skill này làm gì
Skill này thêm các bài kiểm tra tự động vào các bảng và view dữ liệu của bạn, chẳng hạn kiểm tra một cột không bao giờ trống. Nó dành cho người muốn phát hiện dữ liệu xấu trước khi nó đến được báo cáo.
Khi nào nên dùng
- ✓Khi bạn muốn kiểm tra một bảng hoặc view xem có giá trị trống, trùng lặp hoặc tham chiếu bị thiếu không.
- ✓Khi bạn cần xác nhận một bảng được làm mới trong một khoảng thời gian nhất định.
- ✓Khi bạn muốn thêm một kiểm tra tùy chỉnh viết bằng HogQL cho một quy tắc kinh doanh.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/data_quality/skills/authoring-data-quality-checks/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm kiểm tra để đảm bảo không có đơn hàng nào trong bảng đơn hàng của tôi có ID khách hàng trống.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Mỗi kiểm tra là một khẳng định nhỏ đếm số dòng không đạt. Nó đạt khi không tìm thấy dòng nào, tương tự như một bài kiểm thử dbt, và chỉ có số đếm cùng truy vấn được lưu.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Authoring data quality checks
A check is one assertion about one warehouse table, view, or HogQL catalog metric. It compiles to a
count-only HogQL query and passes when it finds zero failing rows, like dbt test. Failing rows are
never stored; only counts and the compiled query are, so to see the offending rows you re-run the
stored query yourself.
row_count is the exception. It passes when the observed count is within its configured min/max
bounds, so its failed_row_count comes back null and its stored query returns that single count,
not offending rows. Read the observed count to judge it rather than looking for matched rows.
Reads go through SQL (system.information_schema.data_quality_*); writes and runs go through the
data-quality MCP tools.
Before you write anything: look
Two queries save you from the two most common mistakes — duplicating a check, and checking a column that doesn't exist.
-- What is already covered?
SELECT name, subject_name, column_name, check_type, config, severity, last_status
FROM system.information_schema.data_quality_checks
WHERE subject_name = 'orders'
-- What columns are there, and what do they mean?
SELECT column_name, data_type, description
FROM system.information_schema.columns
WHERE table_name = 'orders'
Re-creating a byte-identical check is a harmless no-op — checks are keyed by a fingerprint of the subject, type, column, and config, so an identical create upserts. A near-duplicate is not harmless: it doubles the noise for whoever reads the results. If an existing check's assertion is close but wrong, edit the existing check. Updates preserve its identity and history; the subject stays fixed by the URL. An edit that duplicates another check's assertion is rejected.
Choosing checks
Aim for a handful that would actually catch a real regression, not blanket coverage. A model with twenty checks nobody reads is worse than three that fail meaningfully.
Reach for these first, in roughly this order:
not_nullon the columns downstream joins and filters depend on. The single highest-value check. A null join key silently drops rows.uniqueon whatever the model claims is its grain. Ifordersis one row per order, say so.relationshipson foreign keys. Catches the join that quietly stopped matching after an upstream change.accepted_valueson status and category columns whose downstream logic branches on them.freshnesson the timestamp column of anything that syncs. Catches a dead pipeline, which no row-level check will.row_countbounds when you know the plausible range. Good for catching a truncated sync.custom_sqlonly when nothing above expresses the invariant — e.g. cross-column arithmetic (select 1 from orders where total != subtotal + tax). Every row it returns counts as a failure.
Call posthog:data-quality-check-types for each type's exact config schema rather than guessing.
One tool set covers every kind of subject. Call posthog:data-quality-subjects for the tables,
views and metrics you can read, then pass the subject_type and id it gives you as
subject_type and subject_uuid in posthog:data-quality-check-create. Only a subject marked
editable can carry a check; the others can still be the target of a relationships check. After that a check is
addressed by its own id: -update, -delete, -run and -results take no subject.
Checks on PostHog tables
events, persons and groups take checks like any other subject: pass
subject_type: "posthog_table" with the id posthog:data-quality-subjects gives you. Every check
type works on them, and relationships can point at one as its target too.
These tables are large, so consider lookback_hours before you author a check on one. It bounds
the rows the check reads by the table's own time column: timestamp on events, and created_at
on persons and groups, which is when each was first seen rather than when it last changed.
Without it the check reads the whole table, which is allowed and sometimes what you want -- an
unbounded unique on events.uuid says something a windowed one cannot. A check that runs out of
ClickHouse's execution budget reports errored with the message; adding a window is usually the fix.
On a relationships check, lookback_hours bounds the rows it checks and to_lookback_hours
bounds the rows it looks for a match among. Set the second one carefully: a narrow t
Câu hỏi thường gặp
Các dòng xấu có được lưu ở đâu không?
Không. Chỉ có số đếm và truy vấn đã biên dịch được lưu, nên bạn tự chạy lại truy vấn để xem các dòng vi phạm.
Skill có tạo kiểm tra trùng lặp không?
Skill xem các kiểm tra hiện có trước, và tạo lại một kiểm tra giống hệt sẽ không gây hại.
Kiểm tra số lượng dòng làm gì?
Nó đạt khi số lượng dòng nằm trong giới hạn tối thiểu và tối đa bạn đặt.
Chi tiết
Mô tả gốc của tác giả
Adds and runs data quality checks (dbt-test style assertions) on a project's warehouse tables and saved-query views, and HogQL catalog metrics: not-null, uniqueness, accepted values, referential integrity, row-count bounds, freshness, and custom HogQL. Metrics support custom SQL checks only. Use when asked to test a model, validate a view, check for nulls or duplicates, add data quality checks, find out why a number looks wrong, or judge whether a warehouse table is trustworthy before using it in an analysis. To describe what data *means* (metrics, certifications, joins), see setting-up-data-c
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6854
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.