This file is the canonical agent context for the Tuva repository. Agents must read and follow it for all Tuva work, including work performed from separate git worktrees. Keep workflow details here rather than duplicating them in local Codex skills or nested agent files.
- The Tuva Project is an open-source healthcare data model and analytics framework built with dbt and SQL.
- It transforms raw healthcare data, including claims, clinical, eligibility, and
pharmacy data, into a standardized model used for:
- Risk adjustment, including CMS-HCC.
- Quality measures, including HEDIS-oriented marts.
- Cost and utilization analytics.
- Clinical and population health analytics.
- The docs site under
docs/is a Docusaurus project hosted by Netlify atwww.thetuvaproject.com. It documents the package and includes data dictionaries generated from model YAML metadata.
- Input Layer (
models/input_layer):- Defines the contract user data must conform to before package processing.
- Users map raw data to this contract in their own dbt project; Tuva refs those input models.
- Claims Preprocessing (
models/claims_preprocessing):- Normalizes claims and runs service category and encounter grouping logic.
- Core Data Model (
models/core):- Cleaned claims and clinical outputs expected to remain relatively stable.
- Treat breaking changes carefully and make them explicit in issues, PRs, and release labels.
- Data Marts (
models/data_martsand other marts outside input/core/preprocessing):- Advanced marts for measures, groupers, risk models, analytics, and derived outputs.
- When changing mart behavior or schema, update SQL, YAML descriptions/tests, and any docs/data dictionary source affected by the change.
- Terminology, value sets, and data assets (
seeds/):- Top-level package seed CSVs are primarily definitions or headers.
- Larger underlying terminology/value-set content is loaded from public object storage through seed hooks and version vars.
- Data asset changes must preserve cross-warehouse loading behavior.
- Use local DuckDB for development unless the user explicitly asks for another warehouse.
- Run dbt from
integration_testsusing local profiles from~/.dbtorDBT_PROFILES_DIR. - Prefer
scripts/dbt-localfor local dbt commands. - Set
TUVA_DBT_PROFILEorDBT_PROFILEonly when local profile selection is needed. - Keep
integration_tests/dbt_project.ymlonprofile: defaultbefore pushing. - Treat
integration_tests/profiles/*as CI-only configuration, not local runbooks. - Treat
.github/workflows/*as CI pipeline definitions, not local runbooks. - Keep
.github/workflows/create-release.ymlintact unless the task explicitly targets release automation. - Never merge to
main; the user reviews and merges PRs.
- Do not modify
integration_tests/seeds/*without explicit user approval. - For local validation, use the integration test defaults:
use_synthetic_data: truesynthetic_data_size: small
- For data model, data mart, seed, terminology, or value-set work, validate against the shipped synthetic data on local DuckDB.
- If a change appears to require new synthetic columns or synthetic data rows,
stop and ask for explicit generation requirements before editing
integration_tests/seeds/*. - Seed feature or bug work in top-level
seeds/*is allowed when requested, but must be validated throughintegration_testsand local DuckDB before PR.
Use this workflow for normal Tuva issue work, especially when the user points to a GitHub issue or asks the agent to create one.
- Issue creation:
- If the user asks the agent to create an issue, create it in
tuva-health/tuva. - Include title, problem statement, acceptance criteria, constraints, validation expectations, and one release-note label.
- If acceptance criteria or the release-note label are ambiguous, ask the user. If a conservative default is clear, choose it and record the assumption in the issue.
- If the user asks the agent to create an issue, create it in
- Planning:
- Read the issue body and comments.
- Inspect the relevant repo context.
- Produce a concise implementation plan before creating a worktree or making code changes.
- Branch and worktree:
- After the plan is accepted, run
scripts/start-issue-worktree <issue-number> [slug]. - The helper creates or reuses a GitHub-linked branch named
codex/issue-<n>-<slug>fromorigin/main. - The helper creates or reuses a local worktree under
/Users/aaronneiderhiser/code/tuva-worktrees/issue-<n>-<slug>. - All implementation happens in that worktree. Do not reuse the main checkout for issue implementation.
- After the plan is accepted, run
- Implementation:
- Keep changes focused on the issue acceptance criteria.
- Preserve cross-warehouse SQL portability.
- Update docs and YAML metadata when model behavior, schema, or user-facing fields change.
- PR:
- Rebase or update from
origin/mainbefore pushing when needed. - Push the linked branch and open a PR to
main. - The PR body must include summary, validation, release-note label, and
Closes #<issue-number>. - Mirror the issue release-note label onto the PR.
- Rebase or update from
- CI:
- PR open still triggers the default Snowflake
dbt run. - After PR creation, post
/ci snowflake dbt seed dbt run. - Monitor checks, fix failures in the same worktree, push, and continue until the relevant checks pass.
- Leave merge to the user.
- PR open still triggers the default Snowflake
scripts/start-dev-branch <topic> remains available for older non-issue flows,
but issue-linked worktrees are preferred.
Use exactly one release-note disposition on each issue and PR:
breaking-changeenhancementbugdocsterminologyconnectorignore-for-release
Optional version labels such as v0.18.0 may be used for triage, but they do not
drive release note categories.
Release behavior:
.github/workflows/create-release.ymlcreates a draft release when the package version changes indbt_project.ymlonmain.- GitHub generated release notes are built from merged PRs between tags.
.github/release.ymlgroups those notes by PR labels.- Because release notes are PR-label based, mirror the issue release-note label onto the PR.
- Use
Closes #<issue-number>in PR bodies so merge closes the issue and keeps issue-to-release traceability.
Standard dbt commands:
scripts/dbt-local depsscripts/dbt-local debugscripts/dbt-local build --select <selector>scripts/dbt-local build --full-refresh
Validation expectations by change type:
- Docs changes under
docs/**:cd docs && npm cicd docs && npm run build
- Models, marts, macros, seeds, terminology, or value sets:
scripts/dbt-local deps- Run the narrowest useful
scripts/dbt-local build --select <selector>. - Run
scripts/dbt-local build --full-refreshbefore PR.
- CI workflow changes:
- Validate workflow YAML and available local workflow linting tools.
- Confirm PR-open default remains
run-snowflake. - Confirm
/ci run|build[-warehouse]mappings still behave as documented.
dbt seed, dbt run, and dbt build may require internet access because some
seed and value-set content is loaded from public object storage.
- Default on PR open: Snowflake-only
dbt run. - Comment commands on PRs:
/ci runrunsdbt runacross all supported warehouses./ci run-<warehouse>runsdbt runon one warehouse./ci buildrunsdbt build --full-refreshacross all supported warehouses./ci build-<warehouse>runsdbt build --full-refreshon one warehouse./ci snowflake dbt seed dbt runruns Snowflake seed followed by Snowflake run.
- Supported warehouses:
snowflake,bigquery,databricks,fabric,redshift,duckdb. - If a PR changes seed/config files that require a full refresh, use a seed-refreshing CI command before run/test-only commands.
- Write SQL in general-purpose, cross-warehouse style.
- Tuva must run on:
- Snowflake
- Databricks
- BigQuery
- Microsoft Fabric
- Redshift
- DuckDB
- Prefer existing Tuva macros and package patterns over warehouse-specific SQL.
Use this for PRs that do not trigger CI because they originate outside the Tuva GitHub org.
Invocation:
tuva-dev/
task: outside-pr <pr-number>
Deterministic flow:
- Sync local
mainto cleanorigin/main. - Fetch source PR refs and prefer
pull/<pr-number>/mergeso validation runs in clean-main merge context. - Run local validation in DuckDB with
scripts/dbt-local depsandscripts/dbt-local build --full-refresh. - If local validation fails, stop and report failures. Do not create a bridge PR.
- If local validation passes, push a bridge branch named
codex/outside-pr-<pr-number>-ci-<timestamp>. - Open a new PR to
mainwith title prefix[outside-pr <pr-number>]and body linking the source PR. - Monitor CI checks until all required checks are green; if any fail, troubleshoot, fix, push, and continue until green.
Use scripts/outside-pr-bridge <pr-number> to execute this flow.
If a user message starts with tuva-dev/, treat it as a request to run this Tuva
workflow for a feature, bug, issue, or outside PR task.
Preferred user format:
tuva-dev/
task: <what to build or fix>
acceptance:
- <check 1>
- <check 2>
constraints:
- <optional guardrails>
Fallback parsing rules:
- If only one sentence is provided after
tuva-dev/, treat it as the task. - If the task references an existing issue, follow the issue-first worktree workflow.
- If acceptance is missing and no issue exists, infer concise acceptance criteria and record them in the issue or PR.
For each task, report:
- Issue and PR URLs when created.
- Branch and worktree path.
- What changed and why.
- Local validation commands run and key outcomes.
- CI commands/check status when run.
- Any blockers, assumptions, or required user decisions.