AgentSkillsCN

shared-utils-audit

审计embuild-analyses博客文章组件,检查是否正确使用了embuild-analyses/src/lib中的共享工具(路径工具、地理工具、地图工具、NIS融合工具、名称工具、新闻工具)。当审查分析组件是否存在重复的basePath/geo/NIS/新闻/日期逻辑,或在各篇文章中统一工具使用时,使用此技能。

SKILL.md
--- frontmatter
name: shared-utils-audit
description: Audit embuild-analyses blog post components for proper use of shared utilities in embuild-analyses/src/lib (path-utils, geo-utils, map-utils, nis-fusion-utils, name-utils, press-utils). Use when reviewing analysis components for duplicated basePath/geo/NIS/press/date logic or when standardizing util usage across posts.

Shared Utils Audit

Overview

Run a repeatable audit that flags analysis components likely duplicating shared utility logic, then guide replacement with the canonical helpers.

Quick Start

Run the audit script and review findings:

bash
python3 .github/skills/shared-utils-audit/scripts/audit_shared_utils.py

Workflow

  1. Run the audit against the analysis components (default target: embuild-analyses/src/components/analyses).
  2. Review each finding and decide whether to replace custom logic with a shared helper.
  3. Refactor the component or move novel logic into embuild-analyses/src/lib if it should become shared.
  4. Re-run the audit after refactors to confirm findings are resolved.

What The Script Flags

The audit uses regex heuristics and may produce false positives. It only flags patterns; confirm intent before changing code.

  • path-utils: window.location.pathname, NEXT_PUBLIC_BASE_PATH, or '/data-blog' without @/lib/path-utils import.
  • nis-fusion-utils: padStart(5, "0") without @/lib/nis-fusion-utils import.
  • geo-utils: manual arrondissement/province maps (new Map(ARRONDISSEMENTS|PROVINCES) or provinceByArrondissement / regionByProvince), even if geo-utils is imported.
  • press-utils: Intl.DateTimeFormat("nl-BE") without @/lib/press-utils import.

Manual Checks (Not Covered By Script)

  • map-utils: look for hand-rolled municipality-to-arrondissement aggregation or region/province expansion that should use aggregateMunicipalityToArrondissement or expandGeoToMunicipalities.
  • name-utils: look for custom municipality name casing logic that should use formatMunicipalityName.

Script Options

bash
python3 .github/skills/shared-utils-audit/scripts/audit_shared_utils.py \
  --target embuild-analyses/src/components/analyses \
  --format json \
  --max-matches 3

Run the built-in self-test:

bash
python3 .github/skills/shared-utils-audit/scripts/audit_shared_utils.py --self-test

Output Interpretation

Each file with findings lists the imported shared utils, the rule id/description, and matching lines with line numbers. Use the rule id to locate the intended shared helper in embuild-analyses/src/lib.