Lint Sync lint-sync
Add missing LINT.IfChange(...) / LINT.ThenChange(...) guards to enums in C++/Java and XML to keep them in sync. Trigger this skill ONLY when a contributor explicitly asks to add lint guards or synchronize enums using LINT guards.
- Our test
- 6/10
- tested Dec 6, 2026
- GitHub stars
- 26k
- chromium/chromium
- Added by
- 0
- members
- Updated
- Dec 6
- commit 8cf236c
- Content
- 4 files
- 1 script · 16 KB
- License
- BSD 3-Clause
- free to use
What our test found
The skill gives detailed, safety-conscious enum synchronization and guard-placement instructions, but relies on external Chromium workflows and has notable candidate-discovery limitations.
Limits spotted
- Core workflows reference scripts and documents outside the skill folder, so it cannot operate standalone.
- Candidate discovery yields only pairs with at least four enums, potentially missing smaller valid batches.
- Source lookup is heuristic and searches only chrome and components, risking missed or incorrect matches.
- The autonomous protocol proceeds through submission without an explicit user-confirmation gate.
name: lint-sync description: Add missing LINT.IfChange(...) / LINT.ThenChange(...) guards to enums in C++/Java and XML to keep them in sync. Trigger this skill ONLY when a contributor explicitly asks to add lint guards or synchronize enums using LINT guards.
Code Health: Lint Sync Guards
Identify enums in the codebase that are persisted to logs (e.g., recorded in enums.xml) but are missing the LINT.IfChange(...) and LINT.ThenChange(...) guards that enforce synchronization between the source code and the XML metadata.
Overview
When developers modify an enum in C++ or Java but forget to update the corresponding entry in enums.xml, it breaks downstream metrics pipelines. Adding IfThisThenThat lint guards prevents this by generating Gerrit warnings if one side is modified without the other. Act as an expert Chromium contributor to add these missing guards.
Goal: Add LINT.IfChange/ThenChange sync guards to enums in C++/Java and XML files to enforce synchronization.
Workflow
[!IMPORTANT] Execution Protocol: Execute all steps continuously in one autonomous run, without skipping steps or pausing between files or steps. Stop only at explicitask_questiongates or documented interactive stops. Userg(ripgrep) for searches.
Step 1: Workspace Preparation
Run the workspace preparation script:
python3 agents/projects/code-health/hub/scripts/prepare_workspace.py --stash- If the script outputs
(stashed local changes), inform the user. - If the script exits non-zero, stop and report the error instead of continuing on a dirty or diverged tree.
Step 2: Discovery & Batch Selection
Follow the workflow.
Step 3: Refactoring & Implementation
Process the candidates by handling them one file at a time, and applying modifications inside each file one enum at a time (rather than refactoring all files or enums at once). This ensures stability and allows for precise verification. Process all files and enums sequentially within the same run, without pausing for user confirmation between edits, then proceed directly to Step 4. Refer to for sync guard syntax rules and examples before making replacements.
- Process Enum: For each enum in the list:
- Sync Verification: Delegate to a `self` subagent (
invoke_subagent,TypeName="self",Role="Enum Sync Verifier") with this exact prompt (or, if subagents are unavailable, follow these instructions inline): > "Compare the enum<EnumName>in<SourcePath>with its metadata entry > in<XMLPath>. Verify that all valid enum entries in the source have > corresponding<int value="..." label="...">entries in the XML. > IMPORTANT: Ignore/skip sentinel values likekMaxValue,kCount, >COUNT, orNUM_ENTRIESin the comparison; they are not expected to be > in the XML. Return 'SYNCED' or a concise list of missing entries that > need to be added to the XML. Ensure any suggested labels reflect the > enum constant name and any suggested <summary> tags are concise > descriptions of the enum's purpose." - Fix & Proceed: If the subagent returns missing entries, add them to the XML file before proceeding with the guards. Only append missing entries to the XML. Never modify existing names or values in either file. Do not shift the numeric values of an enum. When adding new values to the XML enum, check the format of the existing `<int>` entries and ensure new entries match that format. Labels added to the XML MUST be concise (matching the enum constant name) and any <summary> tags MUST be brief descriptions of what the enum tracks.
- Source:
- Append-Only Logging Comment: Check if the enum's preceding comment already contains a warning about append-only histogram logging. If it does not, add the standard Chromium metric comment:
// These values are persisted to logs. Entries should not be renumbered and numeric values should never be reused. - Clean up legacy sync comments (CRITICAL): Search the enum's preceding comments for manual synchronization reminders (e.g.,
// Please keep in sync with...or// Always keep this enum in sync with...). Remove ONLY the specific sentence or line referencing the manual synchronization. Preserve all other parts of the comment (e.g., descriptions of what the enum represents, renumbering warnings, or usage instructions). If the entire comment block only contains a sync reminder, the whole block may be removed. - Add
// LINT.IfChange(<SourceName>)immediately before the enum definition. - Add
// LINT.ThenChange(<XML Path>:<XmlName>)immediately after the enum. - XML:
- Add the
<!-- LINT.IfChange(<XmlName>) -->immediately before the<enum>tag. - Add
<!-- LINT.ThenChange(<Source Path>:<SourceName>) -->immediately after the</enum>tag. - Handling Mismatched Names: If the name in the Source file (
SourceName) differs from the name in the XML file (XmlName), ensure the correct name is used in each respectiveIfChangeandThenChangetag as shown in the Syntax Rules.
- Iterate: Once the enum is fully synced and verified, move to the next one in the list and repeat. Do not attempt to batch multiple enums in a single file-write operation to ensure accuracy. Once all enums have been processed, proceed immediately to Step 4: Formatting & Automated Review.
Step 4: Formatting & Automated Review
- Format & Lint: Run
python3 agents/projects/code-health/hub/scripts/format_and_lint.py(must exit 0). - Automated Review: Follow , passing as
<SKILL_SPECIFIC_CLEANUP_RULES>.
Step 5: Verification
Follow the workflow.
Step 6: Submission
1. Prepare Commit Message
Ensure the full [lint-sync][LSC] <Title> subject is at most 72 characters (use a short file name or shorten the title if needed), and generate ../commit:
python3 agents/projects/code-health/hub/scripts/prepare_commit_message.py \
--skill lint-sync \
--title "Add missing LINT guards in <FileName>" \
--description - \
--out-commit ../commit <<'EOF'
Add IfThisThenThat lint guards to keep source enums in <SourceFilePath>
synchronized with enums.xml: <EnumNamesList>.
EOF2. Validate Commit File
python3 agents/projects/code-health/hub/scripts/prepare_commit_message.py \
--skill lint-sync \
--validate ../commitIf validation fails, fix the commit title or description and re-run Steps 1–2 until validation exits 0.
3. Submit CL
Invoke the workflow, passing:
- Branch Name:
lint-sync-<EnumName> - Commit File:
../commit