optimize-button-patterns
БесплатноБез исполняемых скриптовНе проверенIteratively improves the heuristic button regex patterns in lib/heuristic-patterns.ts against data/labelled-button-texts.csv. Use when labels are updated…
от duckduckgo★ 139 звёзд на GitHubОб этом скилле
Optimize Button Patterns
Improve the button patterns in lib/heuristic-patterns.ts so classifyButtonTextRegex matches the labelled dataset in data/labelled-button-texts.csv.
These patterns decide what autoconsent clicks in users' browsers, and tracker-radar-collector imports them for crawl post-processing. A pattern that moves a button between labels changes which heuristic tier handles its popup (see classifyPopup in lib/heuristic-classify.ts): an acknowledge button is clicked in tier1, an accept button only in tier2. Keep that in mind when a fix moves text between ACCEPT_PATTERNS and ACKNOWLEDGE_PATTERNS.
Prerequisites
- Confirm
data/labelled-button-texts.csvhas up-to-date labels. New rows come from tracker-radar-collector:collect-popup-button-texts.jsadds unlabelled rows andlabel-button-texts.jslabels them with an LLM (see that repo'spost-processing/README.md). If the CSV has unlabelled rows, suggest runninglabel-button-texts.jsfirst. - For label semantics, read the
classifyButtonTextLLMprompt in tracker-radar-collector'spost-processing/generate-autoconsent-rules/detection.js. That prompt is the source of truth for labels; do not duplicate it here. - If a label looks wrong, fix the row in the CSV rather than bending patterns to fit it (see AGENTS.md).
Success criteria
Stop when all three are met:
- Zero false positives (occurrence-weighted total across labels, including rows labelled
otherpredicted as a button type) - Per-label weighted coverage > 90% for each of
settings,accept,reject, andacknowledge(otheris excluded from optimization) - Pattern consolidation: merge literal clusters into regexes where safe; dedupe exact duplicates
npm run test:lib enforces criteria 1 and 2 (tests-wtr/heuristics/button-classification-accuracy.test.ts), so it must pass before you finish.
Benchmark
Run after every batch of edits:
npm run benchmark-buttons -- --top 25
The output has the totals (weighted false positives, weighted misses) and, per label, the row and occurrence-weighted correct rate, the false-positive count, and the top false positives and misses sorted by occurrences, formatted as [label -> predicted] "text" (xN). A label passes when its weighted rate is above 90%. Check all four labels every iteration. Use --top <n> for longer example lists.
Count patterns before and after with:
npx ts-node -e "import * as p from './lib/heuristic-patterns'; for (const [k, v] of Object.entries(p)) console.log(k, v.length)"
Run loop
Max ~10 iterations. Each iteration:
1. Measure
Run the benchmark. Record each label's weighted rate (and which labels are below 90%), weighted false positives, and pattern counts.
2. Fix false positives first
For each false positive (predicted as a label, but the ground truth is a different label):
- Find the matching pattern in
lib/heuristic-patterns.ts(grep the cleaned text; remember the classification order: reject → settings → accept → acknowledge). - Fix by removing the pattern, moving it to the correct list, narrowing it with
^...$anchors, or adding aBUTTON_NEVER_MATCH_PATTERNSguard. - Re-run the benchmark. Do not add new coverage patterns while false positives remain.
3. Improve coverage
While any label is below 90%, prioritize the labels furthest below (by the gap in weighted correct count: weighted support minus weighted correct).
Each iteration, take the top 15–25 misses by occurrences from under-target labels only.
For each miss:
- Add the smallest pattern that fixes it in the correct list (
REJECT_PATTERNS,SETTINGS_PATTERNS,ACCEPT_PATTERNSorACKNOWLEDGE_PATTERNS, keeping the per-language sub-lists for reject). - Prefer extending an existing regex over adding a literal string.
- Run the collision check (below) before keeping it.
- Re-run the benchmark after each batch. False positives must not increase, and no label's rate may drop below its previous value.
4. Merge patterns
Once false positives are 0 and every label is above 90%:
- Remove exact duplicate literals within the same list.
- Replace clusters of 3+ similar literals with one anchored alternation regex, e.g.
/^(alles accepteren|accepteer alles|alles akzeptieren)$/i. - Re-run the benchmark to confirm there is no regression.
5. Verify and report
Run npm run test:lib and npm run lint, then report using the output template at the end of this file.
Pattern authoring rules
- Edit the button lists in
lib/heuristic-patterns.tsonly. Do not changeDETECT_PATTERNS/DETECT_NEVER_MATCH_PATTERNSor the classification code inlib/heuristic-classify.tsas part of this loop. - Classification order: reject → settings → accept → acknowledge → other (see
classifyButtonTextRegex). Patterns are matched againstcleanButtonTextoutput (lowercased, punctuation and emoji stripped, whitespace collapsed). - Essential/necessar
Установить optimize-button-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл optimize-button-patterns?
Iteratively improves the heuristic button regex patterns in lib/heuristic-patterns.ts against data/labelled-button-texts.csv. Use when labels are updated, benchmark coverage is low, or the user asks to optimize/fix button pattern regexes. Targets zero false positives and ≥90% weighted coverage per label (settings, accept, reject, acknowledge).
Как установить скилл optimize-button-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл optimize-button-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic