suggesting-path-cleaning-rules
What it does
This skill explains PostHog's weekly suggestions for grouping similar page addresses and how to review them. It is for teams who want to see suggested rules before anything changes their reports.
When to use it
- βWhen you want to see the automatic page-address suggestions for your team.
- βWhen you want to review and apply the suggested rules.
- βWhen you need to check whether the suggestion check is working.
Skill link
https://github.com/PostHog/posthog/blob/master/products/web_analytics/skills/suggesting-path-cleaning-rules/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βCan you look at the path cleaning suggestions PostHog made for our site and explain which ones are worth applying?β
5 new skills a week. 1 minute to read.
How it works
PostHog samples real page addresses each week, asks an AI model for grouping rules, and checks each rule against the team's own data. The agent reviews the suggestions, and they are applied only when a person decides to.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Suggesting path-cleaning rules
Many teams never configure path cleaning, so their Web analytics breakdowns fragment across
thousands of near-identical URLs. This feature proactively suggests cleaning rules for the
web-analytics precompute cohort: weekly, for each team, it samples real paths, asks the LLM for
{regex, alias} rules, validates them against the team's own paths, and stores them for review.
It only suggests β it never auto-applies. Applying rewrites historical numbers in every cleaned
chart, so that stays a human decision (the existing settings UI, or the --apply flag below after
review). To hand-author or directly apply rules, use the managing-path-cleaning-rules skill.
Architecture
- Core:
products/web_analytics/backend/path_cleaning_suggestions/service.pysample_pathnames/count_distinct_pathnamesβ top$pathnameby views via HogQL.call_llm_for_rulesβ one-shot call through the LLM gateway (get_llm_client(product="web_analytics", team_id=...), modelWEB_ANALYTICS_PATH_CLEANING_SUGGESTIONS_MODEL, defaultclaude-haiku-4-5).validate_and_annotate_rulesβ compiles each regex with re2 (the engine ClickHousereplaceRegexpAlluses) and test-applies it to the sampled paths. Rules that don't compile or match nothing are dropped; survivors get a denseorder, amatch_count, and in-memory before/afterexamples(printed by the management command, never stored β health-issue payloads are readable with justhealth_issue:readand must not leak real paths). This is the skill's "test before saving" step, automated.generate_suggestions_for_teamβ orchestrates the above with gating (see below); pure generation, no storage.apply_suggestions_to_teamβ merges rules intopath_cleaning_filters, never overwrites (dedupes by regex, continuesorder).
- Storage: a
path_cleaning_suggestionshealth issue (HealthIssue, severityinfo) β no dedicated model. One active issue per team (hash_keys=[]);payloadcarriesrules,model,sampled_path_count,distinct_path_count. Applying (or hand-configuring rules) resolves the issue on the next check run; dismissal is the health-issuedismissedflag. - Schedule:
PathCleaningSuggestionsCheck(products/web_analytics/backend/temporal/health_checks/path_cleaning_suggestions.py), a health check on the shared health-check framework, weekly (Mon 06:23 UTC), small sequential batches because each eligible team costs an LLM call. Teams with an existing active suggestion are re-emitted without a fresh LLM round trip. - Cohort:
WEB_ANALYTICS_PATH_CLEANING_SUGGESTIONS_TEAM_IDS, defaulting to the precompute enrollment listWEB_ANALYTICS_LAZY_PRECOMPUTE_TEAM_IDS.
Gating (why a team is skipped)
generate_suggestions_for_team returns a status:
skipped_inactiveβ team sent no$pageviewwithinvisited_within_days(default 30); we only suggest for teams actively using web analytics. Bypass with--ignore-visit-gate.skipped_configuredβ team already has path cleaning rules (override withinclude_configured).skipped_low_cardinalityβ fewer distinct paths thanmin_distinct_paths(default 50); cleaning adds no value, so we don't spend tokens.skipped_no_pathsβ no pageviews in the window.generatedβ rules produced (may be an empty list if paths are already clean; empty generations are never stored, so they can't shadow an actionable suggestion).errorβ sampling/LLM failed; captured per-team, never aborts the cohort sweep.
How users see and apply suggestions
- Settings banner:
PathCleaningSuggestionsBanneron/settings/project#path_cleaningshows the latestsuggestedrow as regex β alias previews with match counts; "Apply all" (project admins only) merges the rules, the close button dismisses. Driven bypathCleaningSuggestionsLogic. - Onboarding step:
OnboardingWebAnalyticsPathCleaningStep(stepKeypath_cleaning) surfaces the same banner during Web analytics onboarding. - API (
products/web_analytics/backend/api/web_analytics_path_cleaning_suggestions.py):POST /api/projects/:id/web_analytics_path_cleaning_suggestions/generate/produces and stores a fresh suggestion on demand;GET .../{issue_id}/preview/applies the rules to a fresh sample of the team's top paths and returns before/after pairs (read scope, computed on demand, never store
FAQ
Does PostHog apply the suggestions automatically?
No. It only suggests rules, because applying them rewrites the numbers in charts from the past.
Who applies the rules?
A person applies them, either in the settings screen or with the apply option after reviewing them.
Can I write my own rules instead?
Yes. A separate skill covers writing, testing and applying rules by hand.
Details
Original description by the author
Runs and reasons about the automated AI health check that suggests path-cleaning rules for web-analytics teams. Use when asked to generate path-cleaning suggestions for a team or cohort, to run the suggestion check, to review/apply AI-suggested rules, to inspect path_cleaning_suggestions health issues, or to extend the suggestion pipeline. Covers the suggest_path_cleaning_rules management command, the path_cleaning_suggestions health check, the cohort gating (precompute teams), and how suggestions are validated against real paths before storage. For hand-authoring or applying rules directly, u
repo: PostHog/posthog
Popularity
- GitHub stars
- 41k
- Ranking position
- #6977
- License
- β
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
depot-ci
41kHelps your agent set up and run Depot CI workflows, a GitHub Actions alternative, including migrating existing workflows and reading run logs.
depot-container-builds
41kHelps your agent build Docker images on Depot's remote builders, including multi-platform images, pushing to registries, and fixing build failures.
depot-github-runners
41kHelps your agent move GitHub Actions jobs to Depot-managed runners, choosing runner sizes and labels, and troubleshooting runner setup issues.
editing-agents-md
41kHelps your agent decide whether a rule belongs in an AGENTS.md or CLAUDE.md file, and write it so it sticks without bloating the file.
Similar skills
gitcrawl
394kLets your agent search a saved archive of GitHub issues and pull requests, group duplicates, and check their current status on GitHub.
slacrawl
394kLets your agent search and count messages in a local Slack archive, check how fresh that archive is, and refresh it when needed.
goplaces
394kHelps your agent search for places, get their details and reviews, and resolve place names using Google Places, with JSON output for scripts.