model-tests
Skill3 starsChanged 31 days agoMITView on GitHub
Designs and reviews tests for analytical model behavior and data contracts. Use when adding generic, singular, unit, relationship, key, accepted-value, or expression tests; when investigating missing, redundant, or misplaced model-test coverage; when translating a modeled risk into a test; or when build-model needs tests for a model.
In this repository24 other files it gives its agents.
- analytics-requirementsSkill
- api-pipelineSkill
- bi-modelSkill
- build-modelSkill
- data-model-reviewSkill
- data-profileSkill
- data-quality-investigationSkill
- dbt-healthSkill
- explain-data-codeSkill
- freshness-investigationSkill
- incremental-modelSkill
- metric-definitionSkill
- migration-planSkill
- model-documentationSkill
- project-profileSkill
- pr-reviewSkill
- refactor-modelSkill
- rename-modelSkill
- semantic-layerSkill
- source-setupSkill
- sql-reviewSkill
- trace-lineageSkill
- validate-dbtSkill
- yaml-maintenanceSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 8 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Add or review tests for model keys, relationships, allowed values, expressions, business rules, or transformation behavior.
- Very specific: line 18
When build-model reaches its testing step, perform this discovery automatically.
- Distinctive: line 19
Do not use for source-level tests, prose documentation, or YAML-only reorganization unless those domains are independently triggered.
- Very specific: line 23
Read .ae/exercise.json when present and honor its mode, constraints, rubric, allowed tools, and artifacts.
- Distinctive: line 33
Before editing a failing test, classify the failing rows from the documentation.
- Distinctive: line 45
Use the least complex demonstrated test form: built-in generic, installed package or project macro, singular SQL, then unit test when …
- Distinctive: line 47
Add relationship tests only when the intended referential rule and null policy are known.
- Distinctive: line 48
Keep tests at the model whose contract they protect.
- Very specific: line 51
If composing with build-model, return tests, protected risks, paths, and any unresolved contract gate.
- Distinctive: line 77
Read singular tests as assertions: zero returned rows must mean success.
- Distinctive: line 85
Use synthetic fixtures only.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- Generated by scripts/build_targets.py from src/skills. Edit the source and rebuild; changes made here are overwritten. -->Self-contained install.
<skill-dir>is the directory holding this file: substitute its absolute path in the commands below and run them from the repository root. Read<skill-dir>/references/operating-rules.mdbefore acting; it holds the toolkit's always-on rules, which this install cannot load on its own. This install has no safety hooks, so the approvals those rules describe rest on you and the agent rather than on an enforced gate.
Model Tests
Turn demonstrated model risks and contracts into the smallest tests that would detect them.
When to use
- Add or review tests for model keys, relationships, allowed values, expressions, business rules, or transformation behavior.
- Identify missing, redundant, contradictory, brittle, or incorrectly scoped model-test coverage.
- Translate grain, join, null, enumeration, and regression risks into generic, singular, or unit tests.
- When
build-modelreaches its testing step, perform this discovery automatically; users do not need to invoke another skill. - Do not use for source-level tests, prose documentation, or YAML-only reorganization unless those domains are independently triggered.
Mode and conventions
Read .ae/exercise.json when present and honor its mode, constraints, rubric, allowed tools, and artifacts. Otherwise use a user-requested mode; if none is requested, silently use Work.
- Work: design evidence-backed tests and make only authorized changes.
- Learn: expose risks through a hint ladder and let the learner author the tests.
- Assessment: evaluate submitted tests against the stated rubric without supplying replacements or editing them.
Read .ae/project.yml first and treat human edits as authoritative. If absent, run python3 "<skill-dir>/scripts/infer_conventions.py" <project-root> --json and inspect neighboring model YAML, singular tests, unit tests, packages, and macros. Infer test syntax, placement, arguments, severity, naming, and key defaults from repository evidence. Apply strong conventions silently, state weak assumptions, ask about genuine splits, and label defaults when evidence is absent.
Fixing a failing test
Before editing a failing test, classify the failing rows from the documentation.
- Exempt: the documentation says the value never applies to those rows. Scoping the test to the rows it applies to is ordinary work.
- Late: the value applies but has not arrived. Wording such as "until", "pending", "not yet", "once X ships", a ticket number, or a named owner of the gap means late, not exempt, and so does a column described as required for a downstream use. A known upstream gap is a defect with an owner, not a documented exception.
For late rows the test is right. A where filter, severity: warn, a placeholder coalesced into the column, or a description rewritten around the gap all hide rows the consumer needs. Change nothing; name the rows, the gap's owner, and who is hurt, and ask how to proceed. That is the complete answer, even when the request says to make the build green or to fix it the same way as another test.
Procedure
- State the model grain, candidate key, joins, filters, transformations, and documented contract from local artifacts.
- Inventory existing tests and distinguish what each actually proves from what its name suggests.
- Rank concrete failure risks by impact and likelihood. Add a test only when its failing rows and protected behavior can be stated.
- Use the least complex demonstrated test form: built-in generic, installed package or project macro, singular SQL, then unit test when fixture-level transformation behavior is the subject.
- Attach key tests only to a key the model logic can support, and always test the grain the model states. This holds when the request names other tests: "not_null on every column" or "add docs and tests" adds to the grain test rather than replacing it, so add the grain test alongside and list it. For composite grain, follow the repository's established combination test or singular-test pattern; when there is none, use
dbt_utils.unique_combination_of_columnsif dbt_utils is installed, otherwise a singular test returning grain combinations that occur more than once. Auniquetest on a row identifier does not prove a composite grain. - Add relationship tests only when the intended referential rule and null policy are known. Do not turn optional relationships into false failures.
- Keep tests at the model whose contract they protect; do not duplicate upstream checks unless this model can reintroduce the defect.
- Confirm macros, packages, fixtures, refs, sources, and columns referenced by each proposed test exist locally.
- Apply explicitly requested, reversible test additions and edits in project-owned YAML, SQL, or synthetic fixtures without asking for a second approval. Preview and ask before deleting tests, weakening an established contract, or expanding beyond the requested model.
- If composing with
build-model, return tests, protected risks, paths, and any unresolved contract gate; do not redo source setup, model SQL, documentation, or structural YAML cleanup.
Evidence required
For every proposed test, cite the SQL, contract, requirement, incident, or downstream use establishing the invariant. State the expected failing rows or fixture behavior and why the chosen model is the correct boundary. Report convention counts when available and mark warehouse-dependent assumptions unverified.
Failure modes
- Adding
uniquebecause a column looks like an ID without establishing model grain. - Treating
not_nullplusuniqueas proof of business correctness. - Testing optional relationships as mandatory or ignoring accepted null semantics.
- Calling values that are late or missing "legitimately null" so a failing test can be scoped green.
- Duplicating upstream tests that cannot fail because of this model's logic.
- Introducing a package macro or test syntax absent from project dependencies.
- Writing a singular test whose passing condition is reversed or whose scope is unbounded.
- Confusing test YAML placement with structural YAML maintenance.
- Running dbt or querying a warehouse instead of reporting execution as unverified.
Output contract
For ordinary creation or editing, return # Model Tests with: Changed; Why each test exists; Verified; Remaining uncertainty. Name the model grain and the risk protected by each test. Use formal severity and evidence findings only when reviewing coverage or reporting a material risk.
Verification
- Statically validate each model, column, macro, package, fixture,
ref, andsourcereference. - Confirm generic-test argument syntax matches the repository's dbt version and examples.
- Read singular tests as assertions: zero returned rows must mean success.
- Confirm tests are capable of failing for the stated defect and are not exact duplicates.
- Parse proposed YAML and SQL with available local static tools.
- Propose the smallest
dbt testordbt build --selectcommand without running it.
Safety/privacy
- Local Basic only: use local files and static local tools; never call MCP, execute dbt, or contact a warehouse.
- Use synthetic fixtures only; never copy raw production rows, PII, credentials, or sensitive values into tests.
- New files may be created and must be listed.
- Explicitly requested reversible test edits may proceed; deletion, contract weakening, and scope expansion require preview, blast radius, and approval.
- In Assessment mode, perform read-only evaluation.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

