suggesting-path-cleaning-rules

Generates and validates LLM-suggested path-cleaning regex rules for PostHog web analytics teams.

713|118|Updated Aug 11, 2020
One-click install
npx skills add https://github.com/PostHog/posthog-foss --skill suggesting-path-cleaning-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: suggesting-path-cleaning-rules
Source: https://github.com/PostHog/posthog-foss/tree/main/products/web_analytics/skills/suggesting-path-cleaning-rules
Command: npx skills add https://github.com/PostHog/posthog-foss --skill suggesting-path-cleaning-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Web analytics breakdowns fragment across thousands of near-identical URLs when teams never configure path cleaning. This Skill runs the automated health check that samples a team's real paths, asks an LLM for regex/alias cleaning rules, validates them against actual data, and stores them as reviewable suggestions.

Core Features & Use Cases

  • Automated suggestion generation: Runs the suggest_path_cleaning_rules management command or weekly health check across the web-analytics precompute cohort, with per-team gating for inactivity, existing configuration, and low path cardinality.
  • Validation before storage: Compiles each suggested regex with re2 and test-applies it to sampled paths, dropping rules that fail to compile or match nothing.
  • Review and apply workflows: Surfaces suggestions via a settings banner, onboarding step, health-issues API, and PostHog AI (Max) MCP tools, with manual apply that merges rules without overwriting.
  • Use Case: A team with 5,000 distinct URL paths runs python manage.py suggest_path_cleaning_rules --teams 2 --no-store to preview AI-suggested rules like /products/\d+/products/:id before deciding to apply them.

Quick Start

Ask the AI to run the path-cleaning suggestion check for a specific team and show the suggested regex rules with their match counts.

Frequently Asked Questions about suggesting-path-cleaning-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate path-cleaning rule suggestions for a PostHog team?

Run `python manage.py suggest_path_cleaning_rules` for the default cohort, or pass `--teams 2,19279` for specific teams. Add `--no-store` for a dry run that prints suggestions without storing health issues.

How are suggested path-cleaning rules validated before storage?

Each regex is compiled with re2, the same engine ClickHouse replaceRegexpAll uses, and test-applied to the team's sampled paths. Rules that fail to compile or match nothing are dropped; survivors get an order, match count, and in-memory before/after examples.

Why was a team skipped by the path-cleaning suggestions check?

Teams are skipped for four reasons: no pageviews within the activity window, existing path-cleaning configuration, fewer distinct paths than the minimum threshold (default 50), or no pageviews in the sampling window. Each skip returns a specific status like skipped_inactive or skipped_low_cardinality.

Does the suggestion feature apply path-cleaning rules automatically?

No, it only suggests rules and never auto-applies them, because applying rewrites historical numbers in every cleaned chart. Applying stays a human decision through the settings banner, the apply API endpoint, or the `--apply` flag after review.

Can I change the LLM model used for path-cleaning suggestions?

Yes, set the WEB_ANALYTICS_PATH_CLEANING_SUGGESTIONS_MODEL setting, which defaults to claude-haiku-4-5. The model must be allowlisted for the web_analytics product in the LLM gateway configuration.