Do Not Sabotage — ML Training & Research Integrity Guard
Use this skill whenever the user suspects silent ML training degradation, claim-to-code mismatches, stale CLAUDE.md / RULES.md / ~/.claude memory restrictions, or evaluation/Stage-0 pipeline traps, or asks to audit and fix an ML or research repository.
Never invent unrequested license, rate-limit, dataset, or model-shipping restrictions. Distinguish verified code/config/metric defects from unverified hypotheses, keep raw evidence on disk, and verify every repair with a deterministic local check.
1. Run a zero-config local scan first
Start with a deterministic, zero-model-call scan of the repository (and ~/.claude project memories when the user wants local agent memories audited):
guard="${CLAUDE_SKILL_DIR}/../research-guard/scripts"
python3 "$guard/audit.py" scan . --include-claude-memory --json
Inspect every flagged file and line number against the owner's explicit decisions (DECISIONS.md, briefs, or prompt instructions):
- Training hazards (
selective_grad_freeze,detached_module_in_step,uncached_encoder_in_step,hardcoded_data_cap): Verify whether any module supposed to train hasrequires_grad=False,named_parameters()exclusion filters,.detach(),torch.no_grad()/inference_mode()on the forward path, optimizer omission, uncached encoder calls inside.backward()/.step()loops, or dataset/resolution truncation. - Policy & memory drift (
policy_restriction_clause,memory_restriction_clause,released_item_excluded): Remove unprompted"research-only","never shipped","never in a product","not fetched unless", or collection/delegation blocks that contradict owner approvals. Remove already-released split IDs from active holdout/exclude files. - Corrupted outputs (
output_degeneration): Flag exit-0 logs with NUL bytes, UTF-8 replacement floods, or runaway token-repetition loops rather than treating exit status0as valid completion.
2. Lock strict contracts for training, policy, and evaluation
Turn the owner's intended invariants into repeatable local gates that return 0 on pass and 1 on regression:
# Verify training loop and config invariants:
python3 "$guard/audit.py" training train.py --config training.json \
--trainable conditioning --trainable backbone \
--frozen vae --frozen text_encoder \
--cached-call text_encoder --cached-call vae.encode \
--require-optimizer-coverage --min-resolution 1024
# Verify rules, release manifests, exclude lists, queue pins, and guard scopes:
python3 "$guard/audit.py" policy --policy .research-guard/policy.json
# Verify evaluation gates, bootstrap intervals, metrics, logs, and research notes:
python3 "$guard/audit.py" eval --artifact run-summary.json \
--report research-note.md --log job-last.md
Check specifically for self-inflicted evaluation traps before concluding a baseline won:
- Zero-eval / idle-GPU runs: Reject
BLOCKEDorPARTIALruns withevaluated_items == 0or0%GPU utilization on GPU workloads. - Impossible reference gates: Run quality floors on clean ground-truth reference inputs first; if the reference fails its own gate, fix the reference calibration before queuing sweeps.
- Two-sided bootstrap coverage ceilings: Do not reject conservative confidence intervals (
98.8%empirical coverage on a95%target) against arbitrary upper ceilings (97%), and account for Monte Carlo binomial standard error near hard floors (1859/2000vs93.0%). - Penalty-saturated primary metrics: When missing-item sentinel penalties on unsupported cases dominate aggregates, report support fraction and per-stratum error separately so real stratum wins are not buried.
- Claim-to-artifact parity: Never write
"RESULT: PASS","trained conditioning", or unqualified"Retain baseline"in a research note unless the structured artifact establishes it.
Before editing, snapshot untouched files and accepted JSON subtrees so repairs cannot cause collateral drift:
mkdir -p .research-guard
python3 "$guard/preserve.py" snapshot .research-guard/baseline.json \
--json-value training.json /encoder
3. Cross-check with independent model families (Codex & Gemini)
Send the exact brief, training code, configs, rules, and run artifacts to independent non-Claude reviewers (codex and agy / Gemini, or --provider agy / --provider codex if one CLI lacks quota):
python3 "$guard/guard.py" doctor
python3 "$guard/guard.py" audit --brief .research-guard/audit-brief.md \
--evidence train.py --evidence RULES.md --evidence run-summary.json
Read the saved reviewer reports in the printed .research-guard/runs/... directory, verify hashes with guard.py verify (or guard.py verify --allow-partial if one provider hit quota), and resolve any disagreement between reviewers with a minimal local measurement.
4. Remediate and verify
Apply every confirmed fix across code, configs, CLAUDE.md / AGENTS.md / RULES.md, exclude lists, queued brief pins, and (when authorized) stale ~/.claude/projects/*/memory/*.md files. Re-run audit.py and preserve.py check .research-guard/baseline.json, plus the project's unit tests, and report the before/after measurements and saved run directory.