pollen-view-structure
БесплатноБез исполняемых скриптовНе проверенUse this skill when a user wants to structure BigQuery views into the standard Pollen view pattern. All Pollen analysis is in the research/notebooks/policy…
от Recidiviz★ 48 звёзд на GitHubОб этом скилле
Pollen View Structure Skill
Converts SQL queries (from notebooks, .sql files, or provided directly) into the standard
Pollen view structure. Before writing any files, read
recidiviz/research/notebooks/policy/CLAUDE.md
for the full file templates and naming conventions.
Step 1: Gather Inputs
Use AskUserQuestion to determine the SQL source, then ask remaining details in prose:
AskUserQuestion(questions=[{
"question": "Where is the SQL coming from?",
"header": "SQL source",
"options": [
{"label": "Existing notebook", "description": "Extract SQL cells from a .ipynb file"},
{"label": "Existing .sql files", "description": "Migrate from a queries/ folder"},
{"label": "Provide directly", "description": "I'll describe or paste the SQL"},
],
"multiSelect": True
}])
Then ask (in prose) for anything not already provided:
- Prefix — e.g.
us_co_aet,us_ar_paa - Folder path — where
{state_code}/{policy_project}/views/should be created (e.g.recidiviz/research/notebooks/policy/us_co/aet/views/) - File path(s) — notebook and/or .sql directory path(s), if applicable
Step 2: Extract View Candidates
If the source includes Existing notebook:
Read the notebook JSON. Find cells containing SQL (SELECT, FROM, WITH, JOIN):
read_gbq(...)calls with embedded SQL- Variables assigned to SQL strings (
query = """SELECT ...""") - Repeated CTEs — good candidates for dedicated views
Present candidates with cell index, 1-sentence description, and suggested view name:
Found 4 potential views:
[Cell 3] compartment_sessions — Incarceration sessions joined to person IDs
[Cell 7] credits — Credit records with decoded credit type descriptions
[Cell 12] programs — Program enrollments with decoded status columns
[Cell 19] session_outcomes — Aggregates disciplinaries and earned time per session
Which would you like to promote? (say "all", list specific ones, or adjust)
Wait for confirmation before proceeding.
If the source includes existing .sql files, copy the queries into {prefix}_views/ with appropriate renaming and editing.
If the source includes provide directly, ask the user to describe their desired functionality and draw on existing queries to translate that intention into queries.
Step 3: Suggest Parameters
Scan each view's SQL for hardcoded values worth extracting as named constants:
| Pattern | Example | Suggested name |
|---|---|---|
| Date literals | >= '2012-01-01' |
_START_DATE |
| Year thresholds | >= 2018 |
_START_YEAR |
| Score/rating cutoffs | >= '2023-01-01' |
_RATING_CUTOFF_DATE |
| State codes | = 'US_CO' |
leave as-is |
| Domain filter strings | = 'INCARCERATION' |
leave as-is |
Present suggestions and wait for approval:
Found 2 values to potentially extract:
[compartment_sessions] L42: `>= '2012-01-01'`
Suggested: _START_DATE = '2012-01-01' → used as >= '{_START_DATE}'
Reason: AET enactment year — likely adjusted for sensitivity analysis
[ratings] L19: `>= '2023-01-01'`
Suggested: _RATING_CUTOFF_DATE = '2023-01-01' → used as >= '{_RATING_CUTOFF_DATE}'
Reason: Rating coding changed in 2022 — this date may need adjustment
Which would you like to extract? (say "all", list specific ones, or "none")
Step 4: Write Files
Before writing, fetch the author's GitHub handle to populate the description warning:
gh api user --jq .login
Create:
{state_code}/{policy_project}/views/__init__.py— empty (if it doesn't already exist)- One
.pyper view — follow the individual view file template inCLAUDE.md, substituting the actual GitHub handle into theWARNING: ... don't use without review from <github-handle>line
SQL formatting: strip leading/trailing blank lines, preserve -- inline comments, indent
consistently (2 or 4 spaces) within the triple-quoted string.
Project ID: use {project_id} in plain-string queries, {{project_id}} in f-string queries
(see CLAUDE.md for details).
Step 5: Consistency Check + Compile
Verify before running:
- Every view file has
VIEW_BUILDER = SimpleBigQueryViewBuilder(...)at top level -
description=__doc__(not a hardcoded string) in every builder -
__init__.pyexists in theviews/folder - Views with extracted constants use
f"""..."""and correct SQL quoting - No hardcoded
recidiviz-staging.— use{project_id}.or{{project_id}}.
Fix any failures, then verify views compile:
uv run python -m recidiviz.tools.pollen.refresh_scratch_views \
--project_id recidiviz-staging \
--state_code {STATE_CODE} \
--policy_project {policy_project}
If the run fails:
- Minor errors (import typo, wrong constant name, missing comma, SQL syntax issues): fix directly and re-run.
- Logic issues: flag to the user with th
Установить pollen-view-structure в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл pollen-view-structure?
Use this skill when a user wants to structure BigQuery views into the standard Pollen view pattern. All Pollen analysis is in the research/notebooks/policy folder -- do not apply this skill outside that folder. Triggers include: "structure my views", "create view files", "pull views from my notebook", "set up the view folder structure", "make my SQL into view builders", or any request to convert notebook SQL or .sql files into the SimpleBigQueryViewBuilder pattern used by policy analysis work.
Как установить скилл pollen-view-structure?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл pollen-view-structure запускает скрипты?
Нет, скилл состоит только из инструкций (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