domain-knowledge-constraints-trap

domain-knowledge-constraints-trap is a skill for Claude Code, Codex from topprismdata/cultivating-ml-agent. It costs 85 tokens per session (2,842 once invoked), scanned A, original, MIT.

A warning about filtering machine-learning data using seemingly sensible rules from the real-world domain.

In plain words
What is it for?
Use it when considering medical, physical, or logical constraints, especially after validation scores fall or training and test data diverge.
Why use it?
Rules about what data should be possible can change the training distribution and make predictions worse.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when considering medical, physical, or logical constraints, especially after validation scores fall or training and test data diverge.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add topprismdata/cultivating-ml-agent --skill domain-knowledge-constraints-trap
Clone the repo
git clone --depth 1 https://github.com/topprismdata/cultivating-ml-agent

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for domain-knowledge-constraints-trap

README.md
[![agentmods](https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap/github.svg)](https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap)
Your own site
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for domain-knowledge-constraints-trap

Your own site · 80×15
<a href="https://agentmods.dev/skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap"><img src="https://agentmods.dev/badge/skills/topprismdata/cultivating-ml-agent/domain-knowledge-constraints-trap.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 85 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,842 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00085 $0.02842
Opus 5 $0.00043 $0.01421
Sonnet 5 $0.00017 $0.00568
Haiku 4.5 $0.00009 $0.00284

Measured 12d ago against content hash 31c513d291e8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

domain-knowledge-constraints-trap scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/examples/domain-knowledge-constraints-trap/SKILL.md · 342 lines

How it starts

The opening of the file, as written. The whole thing — 342 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Domain Knowledge Constraints Trap

Problem

Applying domain knowledge "constraints" or "rules" to filter training data can seem like a good idea for improving model quality, but often destroys model performance by changing the data distribution and removing valuable information.

Real Case: Adding 4 medical constraints to heart disease prediction:

  • Expected: Improve model with medical domain knowledge
  • Actual: CV AUC dropped from 0.970 to 0.943 (-2.8%)
  • Root cause: Adversarial AUC changed from 0.501 → 0.661 (distribution shift)

Context / Trigger Conditions

Use this skill when:

  • Working on ML projects with domain experts providing "rules"
  • Considering filtering data based on physical/medical/logical constraints
  • Adversarial validation shows train/test distribution change after filtering
  • CV score decreases after adding "reasonable" constraints

Symptoms:

  • Domain experts say "this data point is impossible"
  • Filtering "anomalies" or "outliers" based on domain rules
  • CV score drops after adding constraints
  • Train/test distributions become different (adversarial AUC ≠ 0.5)

Common Trap Examples:

  • Medical: "Heart rate can't exceed 220 - age" → Removes valid extreme cases
  • Physical: "Temperature can't be negative" → Removes sensor errors AND valid extremes
  • Business: "Customer can't spend >$10K/month" → Removes high-value outliers
  • Temporal: "Events can't happen in the future" → Removes data entry errors AND valid edge cases

Solution

Step 1: Quantify Distribution Impact

Before applying constraints, check adversarial validation:

from sklearn.model_selection import StratifiedKFold
import lightgbm as lgb
from sklearn.metrics import roc_auc_score

def check_adversarial_auc(train_df, test_df, features):
    """Check if train/test distributions are similar"""
    adv_train = train_df[features].copy()
    adv_train['is_test'] = 0

    adv_test = test_df[features].copy()
    adv_test['is_test'] = 1

    adv_combined = pd.concat([adv_train, adv_test], axis=0)

    # Train classifier to distinguish train vs test
    skf = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
    oof_pred = np.zeros(len(adv_combined))

    for tr, val in skf.split(adv_combined, adv_combined['is_test']):
        train_data = lgb.Dataset(adv_combined.iloc[tr][features],
                                  label=adv_combined.iloc[tr]['is_test'])
        val_data = lgb.Dataset(adv_combined.iloc[val][features],
                                label=adv_combined.iloc[val]['is_test'])

        model = lgb.train({'objective': 'binary', 'verbosity': -1},
                          train_data, num_boost_round=100,
                          valid_sets=[val_data],
                          callbacks=[lgb.early_stopping(stopping_rounds=10)])

        oof_pred[val] = model.predict(adv_combined.iloc[val][features])

    auc = roc_auc_score(adv_combined['is_test'], oof_pred)
    return auc

# Before constraints
auc_before = check_adversarial_auc(train, test, features)
print(f"Adversarial AUC (before): {auc_before:.5f}")
# Output: 0.50111 ≈ 0.5 (distributions are similar) ✅

Read the full file on GitHub · 342 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 342 lines · 85 tokens per session scan A 31c513d291e8

Subscribe to this mod's changes

domain-knowledge-constraints-trap is a skill published in the GitHub repository topprismdata/cultivating-ml-agent (5 stars, last pushed 15d ago), licensed MIT. It adds 85 tokens to every session and 2,842 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

huggingface-hub

Hugging Face Hub CLI (hf) — search, download, and upload models and datasets, manage repos, query datasets with SQL, deploy inference endpoints, manage Spaces and buckets.

braxtonROSE4/zorro-agent · 43 tokens

tensorboard

Visualize training metrics, debug models with histograms, compare experiments, visualize model graphs, and profile performance with TensorBoard - Google's ML visualization toolkit.

davila7/claude-code-templates · 32 tokens

mlflow

Track ML experiments, manage model registry with versioning, deploy models to production, and reproduce experiments with MLflow - framework-agnostic ML lifecycle platform.

davila7/claude-code-templates · 33 tokens

datachain-knowledge

Use whenever datasets, cloud storage buckets, or data pipelines are mentioned — creating, saving, querying, listing, exploring, deleting, or processing data in S3, GCS, Azure Blob, or local storage. Also use when running any script that may create datasets as a side effect. Maintains a knowledge base at dc-knowledge/…

datachain-ai/datachain · 104 tokens

prompt-scanner

A scanner for text sent to an AI agent, looking for prompt injection and jailbreak attempts. Prompt injection is text that tries to override an agent's instructions; a jailbreak tries to bypass its safety limits.

alibaba/anolisa · 103 tokens

install-openviking-memory

Install and configure the OpenViking long-term memory plugin for OpenClaw via natural conversation. Once installed, the plugin automatically captures facts from chats and recalls relevant context before each reply (auto-capture + auto-recall, cross-session). Covers prerequisites, install through OpenClaw's plugin…

volcengine/OpenViking · 191 tokens