
Safe Debug
- 412 installs
- 513 repo stars
- Updated July 26, 2026
- lllllllama/ai-paper-reproduction-skill
This is a copy of safe-debug by lllllllama - installs and ranking accrue to the original listing.
safe-debug is a debugging skill that fixes failing ML paper reproduction runs without corrupting datasets, model checkpoints, or long-running GPU jobs during agent-assisted iterative debugging.
About
safe-debug is a Claude Code skill for ML researchers and engineers reproducing academic papers who need iterative debugging without destroying expensive training artifacts. The skill guides agent-assisted fixes to failing reproduction scripts, dependency mismatches, and runtime errors while enforcing safeguards around datasets, saved checkpoints, and in-flight GPU jobs. Developers reach for safe-debug when a paper reproduction stalls mid-pipeline and blind file edits or reckless reruns risk overwriting weeks of checkpoint data or relaunching costly training from scratch. It fits agent-driven debugging sessions on PyTorch or TensorFlow reproduction codebases where one wrong command can cascade into data loss.
- Guardrailed ML experiment debugging
- Checkpoint and dataset protection
- GPU job safe iteration
- Agent-friendly debug playbooks
- Reproducibility-preserving fixes
Safe Debug by the numbers
- 412 all-time installs (skills.sh)
- +11 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lllllllama/ai-paper-reproduction-skill --skill safe-debugAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 412 |
|---|---|
| repo stars | ★ 513 |
| Last updated | July 26, 2026 |
| Repository | lllllllama/ai-paper-reproduction-skill ↗ |
How do you debug ML reproductions without corrupting checkpoints?
Debug failing ML paper reproduction runs safely without corrupting datasets, checkpoints, or long GPU jobs during iterative agent-assisted fixes.
Who is it for?
ML engineers reproducing research papers with agent assistance who cannot afford checkpoint corruption or accidental dataset overwrites during debug cycles.
Skip if: Simple application bugs unrelated to ML pipelines or reproductions where destructive resets and full retraining are acceptable.
When should I use this skill?
An ML paper reproduction run fails and iterative agent fixes risk overwriting datasets, checkpoints, or restarting long GPU jobs.
What you get
Diagnosed reproduction failures with applied fixes, intact datasets, preserved checkpoints, and uninterrupted long GPU jobs.
- Debug diagnosis
- Applied fixes with preserved artifacts
Files
safe-debug
Use this as the Rigor Debug / Rigor Audit skill. The installed slug remains safe-debug for compatibility.
Use the shared operating principles in ../../references/agent-operating-principles.md; this skill should guide conservative diagnosis without blocking the model from finding the local root cause.
When to apply
- The user provides a traceback, terminal error, or concrete training or inference failure symptom.
- The user wants diagnosis, root-cause narrowing, and minimal patch suggestions before code is changed.
- The user wants a safe debug flow with explicit human approval before mutation.
When not to apply
- When the user wants a broad repository walkthrough without an active failure.
- When the task is speculative experimentation or code adaptation.
- When the user is asking for a large refactor or readability rewrite.
Clear boundaries
- Diagnose first.
- Do not modify repository code by default.
- If a patch is needed, propose the smallest fix and require explicit approval first.
- Escalate savepoint or branch creation before medium-risk or high-risk changes.
- A debug fix is not automatically a research contribution; if it changes
experiment meaning or comparability, say so explicitly.
Output expectations
debug_outputs/DIAGNOSIS.mddebug_outputs/PATCH_PLAN.mddebug_outputs/status.json
Notes
Use references/debug-policy.md, ../../references/research-rigor-principles.md, and the shared references/research-pitfall-checklist.md.
display_name: Rigor Debug / Rigor Audit
short_description: Rigor Debug / Rigor Audit mode for conservative failure diagnosis before patching.
default_prompt: Diagnose this deep learning research error conservatively. Analyze the traceback or symptom first, explain the likely cause, suggest the smallest safe fix, and do not patch code unless explicitly authorized.
Debug Policy
Default protocol
1. read the error or symptom carefully 2. diagnose without editing repository code 3. state the likely cause, evidence, and smallest safe fix 4. require explicit approval before patching
Required outputs
- diagnosis summary
- likely cause category
- conservative fix suggestions
- savepoint recommendation when change scope is medium or high
Forbidden behavior
- editing code before approval
- drifting into broad refactor work
- silently routing into exploration
#!/usr/bin/env python3
"""Conservative research debugging without automatic patching."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Dict, List
CATEGORY_RULES = [
("cuda_oom", ["cuda out of memory", "outofmemoryerror", "oom"]),
("checkpoint_mismatch", ["size mismatch", "missing key", "unexpected key", "checkpoint"]),
("distributed_issue", ["nccl", "distributed", "ddp", "rank"]),
("device_mismatch", ["expected all tensors to be on the same device", "same device"]),
("shape_mismatch", ["shape", "dimension", "size mismatch"]),
("loss_nan", ["loss is nan", "nan", "not converging"]),
("file_missing", ["filenotfounderror", "no such file", "cannot find path"]),
]
def classify_error(text: str) -> str:
lower = text.lower()
for category, signals in CATEGORY_RULES:
if any(signal in lower for signal in signals):
return category
if "traceback" in lower or "runtimeerror" in lower or "valueerror" in lower:
return "runtime_failure"
return "unknown"
def suggested_actions(category: str) -> List[str]:
mapping = {
"cuda_oom": [
"Check effective batch size, input resolution, and mixed-precision settings before patching model code.",
"Prefer a configuration-only reduction before touching architecture.",
],
"checkpoint_mismatch": [
"Verify checkpoint source, model variant, and load strictness assumptions.",
"Confirm whether the mismatch is expected before introducing compatibility code.",
],
"distributed_issue": [
"Inspect launch command, world size, and environment variables before patching training logic.",
"Reproduce with a single process when possible to narrow the issue safely.",
],
"device_mismatch": [
"Trace where tensors and modules move across CPU and GPU boundaries.",
"Prefer a minimal device-placement fix over a broad refactor.",
],
"shape_mismatch": [
"Log tensor shapes at the failing boundary without changing unrelated code paths.",
"Check config, dataset, and head dimensions before editing model internals.",
],
"loss_nan": [
"Inspect data ranges, loss inputs, mixed precision, and learning rate before changing architecture.",
"Use a shorter controlled run to confirm whether NaNs appear at startup or later.",
],
"file_missing": [
"Validate dataset, checkpoint, and config paths before editing code.",
"Prefer a path fix or documented setup correction over logic changes.",
],
"runtime_failure": [
"Trace the failing file and symbol before proposing any patch.",
"Confirm whether the failure is environment-related, config-related, or code-related.",
],
"unknown": [
"Collect the full command, stack trace, and recent code change before patching anything.",
"Narrow the failure surface with the smallest reproducible example available.",
],
}
return mapping[category]
def analyze_error(text: str) -> Dict[str, object]:
category = classify_error(text)
needs_savepoint = category in {"checkpoint_mismatch", "distributed_issue", "shape_mismatch", "loss_nan"}
return {
"category": category,
"summary": f"Detected debug category: `{category}`.",
"needs_explicit_patch_approval": True,
"needs_savepoint_before_patch": needs_savepoint,
"actions": suggested_actions(category),
"error_excerpt": "\n".join(text.splitlines()[:12]) or text,
}
def write_outputs(output_dir: Path, data: Dict[str, object]) -> None:
output_dir.mkdir(parents=True, exist_ok=True)
diagnosis = [
"# Debug Diagnosis",
"",
f"- Category: `{data['category']}`",
f"- Patch authorized: `False`",
f"- Savepoint recommended before patching: `{data['needs_savepoint_before_patch']}`",
"",
"## Error excerpt",
"",
"```text",
data["error_excerpt"],
"```",
"",
"## Conservative analysis",
"",
data["summary"],
"",
]
(output_dir / "DIAGNOSIS.md").write_text("\n".join(diagnosis), encoding="utf-8")
patch_plan = [
"# Patch Plan",
"",
"- Do not modify repository code until the researcher approves the proposed fix.",
"- Prefer the smallest configuration or path fix before touching core model logic.",
f"- Savepoint recommended: `{data['needs_savepoint_before_patch']}`",
"",
"## Suggested actions",
"",
*[f"- {item}" for item in data["actions"]],
"",
]
(output_dir / "PATCH_PLAN.md").write_text("\n".join(patch_plan), encoding="utf-8")
status = {
"schema_version": "1.0",
"status": "diagnosed",
"category": data["category"],
"patch_authorized": False,
"needs_explicit_patch_approval": data["needs_explicit_patch_approval"],
"needs_savepoint_before_patch": data["needs_savepoint_before_patch"],
"suggested_actions": data["actions"],
"outputs": {
"diagnosis": "debug_outputs/DIAGNOSIS.md",
"patch_plan": "debug_outputs/PATCH_PLAN.md",
"status": "debug_outputs/status.json",
},
}
(output_dir / "status.json").write_text(json.dumps(status, indent=2, ensure_ascii=False), encoding="utf-8")
def main() -> int:
parser = argparse.ArgumentParser(description="Conservative deep learning research debugging.")
parser.add_argument("--error-file", help="Path to a text file containing the error or symptom.")
parser.add_argument("--error-text", help="Inline error or symptom text.")
parser.add_argument("--output-dir", default="debug_outputs", help="Directory for debug outputs.")
parser.add_argument("--json", action="store_true", help="Emit JSON to stdout instead of writing files.")
args = parser.parse_args()
if not args.error_file and not args.error_text:
raise SystemExit("Provide --error-file or --error-text.")
text = args.error_text or Path(args.error_file).read_text(encoding="utf-8", errors="ignore")
data = analyze_error(text)
if args.json:
print(json.dumps(data, indent=2, ensure_ascii=False))
return 0
write_outputs(Path(args.output_dir).resolve(), data)
print(json.dumps(data, indent=2, ensure_ascii=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())
Related skills
FAQ
What does safe-debug protect during ML reproduction fixes?
safe-debug protects datasets, model checkpoints, and long-running GPU jobs from corruption or accidental overwrite while agents iteratively debug failing paper reproduction scripts. The skill prioritizes diagnostic fixes over destructive resets that would force full retraining.
When should safe-debug run instead of normal debugging?
safe-debug runs when ML paper reproduction pipelines fail and agent-assisted fixes risk overwriting checkpoint files, corrupting datasets, or killing expensive GPU training jobs. Standard unconstrained debugging is risky when reproduction artifacts took hours or days to produce.