Suggesting Path Cleaning Rules
PostHogOfficialPublished by PostHog
- Skill
- Workflow
- Data and AI
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill manages an automated pipeline that samples web analytics path data to generate, validate, and suggest regex-based cleaning rules. By identifying fragmented URLs, it helps teams consolidate their analytics data without manual regex authoring. The process includes LLM-based rule generation, validation against real path data using re2, and storage as actionable health issues. It emphasizes human-in-the-loop decision-making by requiring explicit approval before applying any rules to historical data.
What it does
- Samples top-viewed pathnames to identify fragmentation.
- Uses an LLM to generate regex-based cleaning rules and aliases.
- Validates generated rules against real path data to ensure compilation and effectiveness.
- Stores suggestions as actionable health issues for team review.
- Provides management commands to trigger generation, dry-run, or apply rules.
- Integrates with UI banners and onboarding flows to surface suggestions to users.
When to use it
- When web analytics data is fragmented across thousands of near-identical URLs.
- When you need to generate path-cleaning rules for a specific team or cohort.
- When you want to review AI-suggested cleaning rules before applying them.
- When you need to inspect or resolve path-cleaning health issues.
- When you want to extend the automated suggestion pipeline for web analytics.
Advantages
- Reduces manual effort in writing and testing complex regex rules.
- Ensures rules are validated against actual traffic before being suggested.
- Prevents accidental data modification by keeping application as a manual human decision.
- Provides clear visibility into potential data consolidation through preview functionality.
- Integrates seamlessly with existing health-check and project-settings frameworks.
Usage examples
- “Generate path-cleaning suggestions for team 19279.”
- The system will sample paths for team 19279, generate regex rules, validate them, and store them as an active health issue for review.
- “Apply the suggested path-cleaning rules for my project.”
- The system will merge the validated rules into the project's path_cleaning_filters and resolve the associated health issue.
- “Run a dry run of path cleaning suggestions for all eligible teams.”
- The system will perform the analysis and print the suggested rules to the console without storing any data or modifying project settings.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/posthog/suggesting-path-cleaning-rules/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip suggesting-path-cleaning-rules.zip -d .agents/skills
Documentation by PostHog
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 stored — this backs the banner's "Preview on your paths" modal);POST .../{issue_id}/apply/merges the rules and resolves the issue (project admin only — the same gate the team API puts onpath_cleaning_filters). Listing and dismissing go through the generic health-issues API (GET /api/projects/:id/health_issues/?kind=path_cleaning_suggestions&status=active&dismissed=false,PATCH .../health_issues/{id}/with{"dismissed": true}).Health page: the check renders on
/web/healthalongside the other web-analytics checks, with remediation guidance for humans and agents.PostHog AI (Max): generate/apply are exposed as MCP tools in
products/web_analytics/mcp/tools.yaml(web-analytics-path-cleaning-suggestions-{generate,apply}), so a user can ask Max to suggest path-cleaning rules and apply them conversationally. Apply isdestructive(it changes historical chart numbers), so the MCP confirmation gate applies.
Running it
# Default cohort, print suggestions, store health issues:
python manage.py suggest_path_cleaning_rules
# Specific teams, dry run (nothing stored):
python manage.py suggest_path_cleaning_rules --teams 2,19279 --no-store
# Generate AND apply for one reviewed team (merges, never overwrites):
python manage.py suggest_path_cleaning_rules --teams 2 --applyUseful flags: --days (lookback), --limit (top-N paths sampled), --min-distinct-paths,
--include-configured, --no-store, --apply.
The health check can also be triggered per team from the health-issues refresh endpoint or the
admin UI, like any other health check.
Reviewing suggestions
Read a team's active suggestion:
HealthIssue.objects.filter(team_id=team_id, kind="path_cleaning_suggestions", status="active").first()Each rule in payload["rules"] carries regex, alias, order, reason, and match_count —
that's what to show a human deciding whether to apply. Before/after examples on real paths are only
printed by the management command at generation time; they are deliberately kept out of the stored
payload.
Extending
Adding a surfacing channel (in-app notification, settings banner, onboarding wizard step): read the team's active
path_cleaning_suggestionshealth issue and render itspayload["rules"]. Keep apply manual.Changing the model: it must be allowlisted for the
web_analyticsproduct inservices/llm-gateway/src/llm_gateway/products/config.py.The agentic alternative — a
signals-scout-web-analytics-path-cleaningscout — is sketched in the design notes; prefer the dedicated job for the precompute cohort because it targets that exact cohort and surfaces structured, validated rows rather than Signals-inbox findings.
Files
- ATTRIBUTION.mdAdded by AutoGineer879 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md7.8 KiB
ATTRIBUTION.md
Attribution
This folder is an unmodified copy of the Agent Skill "suggesting-path-cleaning-rules", distributed by AutoGineer (https://autogineer.com/agent-skills).
Commit: a5d30e775d092e16e198f7b582f1f66dac2cee45
Published by: PostHog (https://github.com/PostHog)
Publisher: PostHog (https://github.com/PostHog)
Licence: MIT License (https://github.com/PostHog/skills/blob/a5d30e775d092e16e198f7b582f1f66dac2cee45/LICENSE)
Licence evidence: repository licence LICENSE
Retrieved: 2026-11-07
The skill's own files are unmodified copies. AutoGineer is not affiliated with or endorsed by the author or the publisher.
Files added by AutoGineer
ATTRIBUTION.md: this file, written by AutoGineer
LICENSE: copied from LICENSE
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Python
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/omnibus/suggesting-path-cleaning-rules · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download suggesting-path-cleaning-rules.zip