
Path Cleaning Suggestions
FreeAutomate path cleaning rule suggestions for analytics.
Free · Opens the source repo
What Path Cleaning Suggestions does
Path cleaning is crucial for web analytics, as it helps teams manage and analyze data without being overwhelmed by duplicate URLs. The Path Cleaning Suggestions skill automates the process of generating cleaning rules tailored to specific teams. By sampling real paths and utilizing an AI model, it generates regex and alias rules that are validated against the team's existing data. This ensures that the suggestions are relevant and actionable, helping teams maintain cleaner analytics without the clutter of redundant paths.
The skill operates on a weekly schedule, ensuring that teams receive timely suggestions based on the latest data. It does not automatically apply changes, which preserves historical data integrity and allows teams to review suggested rules before implementation. This is particularly important for analytics teams that need to ensure the accuracy of their reports and dashboards. Users can view suggestions through a settings banner, during onboarding, or via API calls, providing flexibility in how they manage path cleaning.
For teams that may not actively use web analytics or have already configured rules, the skill includes gating mechanisms to prevent unnecessary suggestions. This helps optimize resource usage by only suggesting rules when they can add value. The skill is designed for web analytics teams looking to streamline their data management processes and improve the clarity of their reports, making it an essential tool for effective data analysis.
When to use it
Use this skill when you need to generate path-cleaning suggestions for web analytics teams, particularly when setting up or maintaining analytics dashboards.
When not to use it
This skill is not suitable for teams that require immediate application of path cleaning rules, as it only suggests rules and does not apply them automatically.
What you can build with it
Weekly Suggestions for Active Teams
Set up the skill to automatically generate path-cleaning suggestions every week for teams that actively use web analytics.
Reviewing Suggested Rules
Use the skill to review generated path-cleaning rules in a settings banner before applying them to ensure data integrity.
Integrating with API
Leverage the API to generate and preview path-cleaning suggestions on demand, allowing for flexible management of analytics.
How to install Path Cleaning Suggestions
View source1. Install with the skills CLI
npx skills add posthog/posthog/suggesting-path-cleaning-rules --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by posthogSuggesting 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 --apply
Useful 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.
Frequently asked questions about Path Cleaning Suggestions
Similar skills
Single-Cell RNA-seq QC
Automate quality control for single-cell RNA-seq data.
Instrument Data to Allotrope Converter
Standardize lab data for seamless integration.
SQL Server Table Reconciliation
Efficiently compare SQL Server tables across instances.
Data Cleaning and Variable Screening
Streamline credit risk data preprocessing for modeling.
Arize Dataset
Manage and query Arize datasets efficiently.
Spreadsheet Management
Efficiently create, edit, and analyze spreadsheet files.
