Histogram cleanup

From nwjs/chromium.src · View interactive version

Histogram cleanup is an AI agent skill from the GitHub repository nwjs/chromium.src. Identify and safely remove expired Chromium histograms (dead metrics/technical debt). Use this skill when a contributor asks to clean up metrics, fix code health issues related to histograms, remove obsolete code, or work on a histogram cleanup task.

How to use this skill

Skill file

Code Health: Histogram Cleanup

Identify and safely remove "dead code" associated with expired histograms. This

includes removing the recording calls in C++/Java, cleaning up the metadata in

histograms.xml, and addressing any dependent tests.

Overview

Expired histograms that are not intentionally kept for diagnostics represent

technical debt. Act as an expert Chromium contributor specializing in Metrics to

clean up these resources while ensuring no test regressions occur.

Goal: Remove expired Chromium histograms (dead metrics) from XML files and

all code recording sites.

Relevant Resources & Style Guides

XML examples)

analysis_guidelines.md (Safety checks and

effort estimation)

existing trackers)

(Identify expired histograms)

automated_review.md

Scope & Proactivity

Do NOT suggest removing random additional histograms across the file or

component just because they are expired.

exact same recording logic, helper methods, or calculated variables (e.g.,

co-located in the same helper function or branching from the same condition)

as the target histogram, their removal MAY be bundled into the same cleanup

plan IF AND ONLY IF:

1. Expiry Verification: Confirm in histograms.xml that the co-located

histograms are also expired and lack the <expired_intentionally> tag.

2. Safety Verification: Perform the same safety checks (no test

dependencies, no external repo references) for each bundled histogram.

3. Atomic Benefit: Removing them together cleanly eliminates shared

boilerplate (e.g., timer calculations, string building, parameter passing)

that would otherwise be left as dead or awkward code.

helper methods, or calculated variables like timers) that is directly related

to the histogram(s) being removed, include its removal in the cleanup plan.

Present these as part of the primary task, not as separate "proactive

suggestions."

Workflow

[!IMPORTANT] Execution Protocol: Execute all steps sequentially one by

one. Do not skip any step. Do not use edit-code or grep. Use rg

(ripgrep) for searches.

Step 1: Workspace Preparation

Follow the workspace preparation steps in

workspace_preparation.md to ensure

a clean and updated environment.

Step 2: Discovery & Batch Selection

Follow the

Discovery & Batch Selection

workflow.

Step 3: Deep Dive & Safety Analysis

  1. Comprehensive Analysis: Delegate the entire deep dive to the

generalist sub-agent with this exact prompt:

> "Read references/analysis_guidelines.md and follow the 'Generalist Deep

> Dive Prompt' instructions for the histogram <HistogramName>. ALL

> read-only discovery (including rg and cs) is pre-authorized; DO NOT ask

> for permission. Assume rg is available in the environment."

  1. Present Findings & Evaluate Confidence: Evaluate the Confidence Score

returned by the generalist.

Proceeding with cleanup based on this plan: [Removal Plan Summary]." Output

this message, then proceed directly to the Refactoring & Implementation

phase. Do NOT ask for permission.

user using ask_user (type='choice'):

My confidence for this cleanup is [X]/10 because [Justification]. Shall I

proceed with the cleanup diff?"

cleanup changes"

phase.

[Justification]. An alternate expired histogram will be found." Immediately

restart the workflow from the Discovery & Batch Selection phase to

identify a different candidate. Ensure the same histogram is not selected

again in this session.

Step 4: Refactoring & Implementation

Process the changes file by file, and apply modifications inside each file

one recording call at a time (rather than refactoring all files or recording

calls at once). This ensures stability and allows for precise verification.

  1. Apply Changes: Make the changes directly. Apply the code modifications

for the candidate histogram. When removing recording calls, carefully check

if the string literal spans multiple lines and ensure the entire multi-line

statement is cleanly removed. Search for dot-less versions of the name to

ensure related constants are also removed. Check for and update any

references to the histogram in code comments as well. For each removal,

ensure no orphaned references (e.g., unused variables or methods) remain in

the codebase. Each individual change must have a corresponding 'What & Why'

explanation provided to the user.

Step 5: Validation

  1. Linting & Formatting:

python3 tools/metrics/histograms/validate_format.py to validate all

metadata changes. Address any errors that are reported.

code. Address any errors that are reported.

  1. Mandatory Final Review: Follow the

Automated Review Protocol to delegate a

final review of the patch to the generalist sub-agent. Proceed to the

Verification phase only after the review returns PASS.

Step 6: Verification

Follow the Verification workflow.

Step 7: Submission

  1. Bug Tracking:

references/bug_discovery.md using the <HistogramName> and

<ExpiryDate> from the candidate.

and a Bug ID is resolved (or the user has chosen to skip).

  1. Upload Pipeline:

OBSOLETE_HISTOGRAM[<HistogramName>]=expired.

OBSOLETE_HISTOGRAM[<HistogramName>]=<reason>.

following context variables to the workflow:

<Write a concise description of the removed expired histogram (<HistogramName>, expired <ExpiryDate>) and any cleaned-up recording calls, enums, or dead code.>\n\n<customObsoletionMessage>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.