Command Palette

Search for a command to run...

Назад к скиллам
скилл № 87480

investigate-stable-counts-failure

Investigate a stable counts validation failure for a state supervision or incarceration period table by identifying which fields changed and why. Use when a…

БесплатноБез исполняемых скриптов
Recidivizот Recidiviz★ 48 звёзд на GitHub

Установить investigate-stable-counts-failure в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Skill: Investigate Stable Counts Validation Failure

Overview

Diagnose a stable counts validation failure for a state entity table (state_supervision_period or state_incarceration_period). The goal is to identify which fields changed, when the change started, and why — tracing the cause to either a code change (new ingest column, changed mapping) or a data event (raw data re-export, new column from the state partner).

This skill is investigate-only. Do not propose code fixes or open PRs unless explicitly asked.

Inputs

You need two things to start:

  • state_code — e.g. US_NC, US_ID. Never investigate ME or CA data without explicit user approval.
  • target_table_name — one of state_supervision_period or state_incarceration_period.

If either is missing, ASK the user before proceeding.

Step 1: Run the change-detection script

Run the helper script to get a month-by-month overview and per-field change rates:

uv run python -m recidiviz.tools.ingest.investigations.stable_counts_change_detection \
    --project-id recidiviz-staging \
    --state-code <STATE_CODE> \
    --entity <state_supervision_period|state_incarceration_period>

The script outputs two tables:

  • Month Overview: total period count per month, distinct people, and month-over-month change % (entries exceeding ±25% are flagged with **).
  • Field Change Rates: for each field, the % of periods where it differs from the previous period for the same person, filtered to fields that exceed 15% in at least one month.

Use --field-threshold 10 to lower the filter, --lookback-months 24 to widen the window, or --output-csv /tmp/out.csv to save the full data for further analysis.

Note on ~100% rates in early months: Months that predate the state's onboarding in our system will show ~100% change rates for all fields — this is expected (those periods have no prior period to compare against). Focus on the months where the state has been actively sending daily data.

Step 2: Identify the anomalous months and driving fields

Look for months where the Month Overview flags a ** change or where the Field Change Rates show a sudden spike above recent baseline. Key signals:

  • A sudden spike in a month that was previously stable (baseline ~10-20%, spike to 50-90%) is a strong indicator of a data event.
  • A persistent elevation starting at a particular month often means a code change was deployed around then.
  • A field with a high change rate AND zero change in the raw_text counterpart (e.g., change_in_termination_reason is high but change_in_termination_reason_raw_text is 0) means the enum was re-computed from unchanged raw text — look for normalization logic changes rather than raw data changes.
  • A mass spike in distinct_people in a single month (e.g., 3× the normal number of people getting new period starts in one month) usually means a large-scale raw data re-export or new column addition triggered period splits for the entire active population.

Step 3: Find the ingest view(s) for the entity

Locate the ingest view(s) that produce the target entity:

find recidiviz/ingest/direct/regions/<state_code_lower>/ \
  -name "view_supervision_period*.py" -o -name "view_incarceration_period*.py"

Read the view to understand:

  • Which raw tables it queries (look for {raw_table_name} or {raw_table_name@ALL_WITH_DELETED} references)
  • What fields are selected and which raw columns they map to
  • Whether the view uses @ALL_WITH_DELETED — if so, every raw row (including non-meaningful field changes) creates a new period split. This makes the view sensitive to any column addition in the raw data.

Also read any shared SQL fragment files referenced from the view (e.g., us_nc_view_query_fragments.py).

Step 4: Check raw data YAML configs for column additions

For each raw table used by the ingest view, read its YAML config:

recidiviz/ingest/direct/regions/<state_code_lower>/raw_data/us_<xx>_<table_name>.yaml

Scan the update_history entries for each column. The most common cause of stable counts failures is a new column being added to the state's file (indicated by update_type: ADDITION). When a new column arrives:

  • If the ingest view uses @ALL_WITH_DELETED, every active record in the file gets a new update_datetime, creating a period split for every person currently on supervision.
  • The date in update_datetime of the ADDITION entry is the date the state partner started sending the column — cross-reference this with the anomalous month from Step 2.
grep -A 4 "update_type: ADDITION" recidiviz/ingest/direct/regions/<state_code_lower>/raw_data/us_<xx>_<table_name>.yaml

Step 5: Check recent git history

Look for recent commits touching the state's ingest files that might explain the change:

git log --oneline --since="<3 months ago>" -- recidiviz/ingest/direct/r
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл investigate-stable-counts-failure?

Investigate a stable counts validation failure for a state supervision or incarceration period table by identifying which fields changed and why. Use when a stable counts validation is failing or has recently failed for a state entity (e.g. "why is the NC stable counts failing", "investigate stable counts for US_ID supervision periods", "dig into the stable counts failure for supervision periods").

Как установить скилл investigate-stable-counts-failure?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл investigate-stable-counts-failure запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить investigate-stable-counts-failure с