Use when Track and visualize ML training experiments with Trackio. Use when logging metrics during training (Python API), firing alerts for training diagnostics, or retrieving/analyzing logged metrics (CLI). Supports real-time dashboard visualization, alerts with webhooks, HF Space syncing, and JSON output for automation.
Installs into .claude/skills of the current project.
Are you the author of Huggingface Trackio?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/harmitx7-huggingface-trackio)
---
name: huggingface-trackio
description: "Use when Track and visualize ML training experiments with Trackio. Use when logging metrics during training (Python API), firing alerts for training diagnostics, or retrieving/analyzing logged metrics (CLI). Supports real-time dashboard visualization, alerts with webhooks, HF Space syncing, and JSON output for automation."
version: 6.0.0
last-updated: 2026-09-29
tools: Read, Grep, Glob, Bash, Edit, Write
scripts-binding:
- .agent/scripts/lint_runner.js
- .agent/scripts/verify_all.js
---
# Trackio - Experiment Tracking for ML Training
## Activation Boundaries
- **Activate when:** Use when Track and visualize ML training experiments with Trackio. Use when logging metrics during training (Python API), firing alerts for training diagnostics, or retrieving/analyzing logged metrics (CLI). Supports real-time dashboard visualization, alerts with webhooks, HF Space syncing, and JSON output for automation.
- **DO NOT activate when:** The task falls outside the `huggingface-trackio` domain or is managed by a different dedicated specialist agent.
## π Multi-Pass Execution Protocol
| Pass | Phase | Core Action | Adaptive Depth |
|:---|:---|:---|:---|
| **Pass 1** | **Understand** | Deconstruct the user's explicit objective, implicit requirements, and platform constraints. | Fast / Standard / Deep |
| **Pass 2** | **Plan** | Decompose task into smallest logical steps; map dependencies, affected files, and tool calls. | Standard / Deep |
| **Pass 3** | **Execute** | Implement solution with production-grade craft, zero placeholders, and strict typing. | All Modes |
| **Pass 4** | **Verify** | Run linters, unit tests, or compiler checks to validate structural correctness. | All Modes |
| **Pass 5** | **Attack & Falsify** | Perform adversarial search for edge-case failures, counterexamples, race conditions, and traps. | Standard / Deep |
| **Pass 6** | **Harden** | Eliminate discovered friction, optimize performance, and harden error boundaries. | Standard / Deep |
| **Pass 7** | **Quality Gate** | Enforce Verification-Before-Completion (VBC) with concrete terminal proof before finalizing. | All Modes |
Trackio is an experiment tracking library for logging and visualizing ML training metrics. It syncs to Hugging Face Spaces for real-time monitoring dashboards.
---
## Mandatory Pre-Flight Context Inspection
Before generating trackio integration code, you MUST inspect:
1. **Privacy Requirements:** Check if the codebase handles proprietary data. Auto-created Spaces are **public by default**. You must explicitly pass `private=True` unless the user confirms public is okay.
2. **Framework Context:** Determine if the user is writing a custom PyTorch loop, using HF Trainer, or using TRL (`report_to="trackio"`).
---
## Socratic Gate (Before Implementation)
Before adding `trackio` to an existing training script, ask:
1. Should the resulting dashboard Space be `private=True` or `public`?
2. Do you want to configure Slack/Discord webhooks for training failure alerts?
---
## Verification-Before-Completion (VBC)
Before concluding your task, you MUST verify:
1. `trackio.init()` is called *before* any `trackio.log()` or `trackio.alert()` calls.
2. If running autonomously, verify the metrics are flowing by polling `trackio list projects --json`.
---
## Three Interfaces
| Task | Interface | Reference |
|------|-----------|-----------|
| **Logging metrics** during training | Python API | [references/logging_metrics.md](references/logging_metrics.md) |
| **Firing alerts** for training diagnostics | Python API | [references/alerts.md](references/alerts.md) |
| **Retrieving metrics & alerts** after/during training | CLI | [references/retrieving_metrics.md](references/retrieving_metrics.md) |
## When to Use Each
### Python API β Logging
Use `import trackio` in your training scripts to log metrics:
- Initialize tracking with `trackio.init()`
- Log metrics with `trackio.log()` or use TRL's `report_to="trackio"`
- Finalize with `trackio.finish()`
**Key concept**: For remote/cloud training, pass `space_id` β metrics sync to a Space dashboard so they persist after the instance terminates. Auto-created Spaces are **public by default** β pass `private=True` if the metrics should not be public.
β See [references/logging_metrics.md](references/logging_metrics.md) for setup, TRL integration, and configuration options.
### Python API β Alerts
Insert `trackio.alert()` calls in training code to flag important events β like inserting print statements for debugging, but structured and queryable:
- `trackio.alert(title="...", level=trackio.AlertLevel.WARN)` β fire an alert
- Three severity levels: `INFO`, `WARN`, `ERROR`
- Alerts are printed to terminal, stored in the database, shown in the dashboard, and optionally sent to webhooks (Slack/Discord)
**Key concept for LLM agents**: Alerts are the primary mechanism for autonomous experiment iteration. An agent should insert alerts into training code for diagnostic conditions (loss spikes, NaN gradients, low accuracy, training stalls). Since alerts are printed to the terminal, an agent that is watching the training script's output will see them automatically. For background or detached runs, the agent can poll via CLI instead.
β See [references/alerts.md](references/alerts.md) for the full alerts API, webhook setup, and autonomous agent workflows.
### CLI β Retrieving
Use the `trackio` command to query logged metrics and alerts:
- `trackio list projects/runs/metrics` β discover what's available
- `trackio get project/run/metric` β retrieve summaries and values
- `trackio list alerts --project <name> --json` β retrieve alerts
- `trackio show` β launch the dashboard
- `trackio sync` β sync to HF Space
**Key concept**: Add `--json` for programmatic output suitable for automation and LLM agents.
β See [references/retrieving_metrics.md](references/retrieving_metrics.md) for all commands, workflows, and JSON output formats.
## Minimal Logging Setup
```python
import trackio
# Spaces are PUBLIC by default (good for shareable dashboards);
# pass private=True if the metrics should not be public
trackio.init(project="my-project", space_id="username/trackio", private=True)
trackio.log({"loss": 0.1, "accuracy": 0.9})
trackio.log({"loss": 0.09, "accuracy": 0.91})
trackio.finish()
```
### Minimal Retrieval
```bash
trackio list projects --json
trackio get metric --project my-project --run my-run --metric loss --json
```
## Autonomous ML Experiment Workflow
When running experiments autonomously as an LLM agent, the recommended workflow is:
1. **Set up training with alerts** β insert `trackio.alert()` calls for diagnostic conditions
2. **Launch training** β run the script in the background
3. **Poll for alerts** β use `trackio list alerts --project <name> --json --since <timestamp>` to check for new alerts
4. **Read metrics** β use `trackio get metric ...` to inspect specific values
5. **Iterate** β based on alerts and metrics, stop the run, adjust hyperparameters, and launch a new run
```python
import trackio
trackio.init(project="my-project", config={"lr": 1e-4})
for step in range(num_steps):
loss = train_step()
trackio.log({"loss": loss, "step": step})
if step > 100 and loss > 5.0:
trackio.alert(
title="Loss divergence",
text=f"Loss {loss:.4f} still high after {step} steps",
level=trackio.AlertLevel.ERROR,
)
if step > 0 and abs(loss) < 1e-8:
trackio.alert(
title="Vanishing loss",
text="Loss near zero β possible gradient collapse",
level=trackio.AlertLevel.WARN,
)
trackio.finish()
```
Then poll from a separate terminal/process:
```bash
trackio list alerts --project my-project --json --since "2025-01-01T00:00:00"
```
## π¨ Edge-Case & Failure Mode Matrix
| Scenario | Risk | Production Mitigation |
|:---|:---|:---|
| **Empty or Null Inputs** | Unhandled exception or unexpected rendering collapse | Enforce fallback guards, optional chaining, and explicit empty state handlers |
| **Network Timeout / Latency** | Hanging operations or duplicate side-effects | Implement bounded abort controllers, exponential backoff, and idempotency keys |
| **Concurrency / Race Conditions** | Stale state overwrite or inconsistent data mutations | Use atomic transactions, mutex locking, or cancel-on-resubmit controls |
| **Invalid Schema / Malformed Payload** | Downstream runtime errors or security injection | Validate boundary payloads with Zod/Pydantic schemas prior to execution |
| **Resource / Memory Saturation** | OOM errors, frame drops, or memory leaks | Clean up listeners, cancel active timers, and enforce pagination/virtualization |
## π€ LLM-Specific Traps Table
| Anti-Pattern | What AI Commonly Does Wrong | What Is Actually Correct |
|:---|:---|:---|
| **Platform-Dependent Shell Commands** | Hardcoding $(cat ~/.cache/huggingface/token) or piping to jq | Use platform-agnostic token checks via env var HF_TOKEN and native JSON parsing |
| **VRAM OOM Crash** | Loading 70B model weights on a consumer 16GB GPU without quantization | Calculate parameter bounds (fp16 = VRAM/2, Q4 = VRAM*2) and load with bitsandbytes/GGUF |
| **Blocking Batch Generation** | Generating large batches synchronously without streaming or yield | Use TextIteratorStreamer or asynchronous generate workers to prevent request timeouts |
## ποΈ Tribunal Verification & Guardrails
**Active Reviewers:** `ai-code-reviewer` Β· `python-pro` Β· `performance-optimizer`
**Slash Command:** `/review` or `/tribunal-full`
### π¬ Evidence Standard (Tri-State Verification)
Every finding, audit statement, or completion claim must classify its factual certainty:
- **`[OBSERVED]`**: Directly confirmed in the codebase or verified via executed terminal command.
- **`[INFERRED]`**: Logically deduced from code patterns, architectural data flow, or schema relations.
- **`[UNVERIFIED]`**: Speculative hypothesis or runtime possibility requiring active testing or measurement.
### β Pre-Flight Self-Audit Checklist
```
β Are model architectures and weights verified to fit within target hardware VRAM budgets?
β Are pipeline requests guarded with bounded timeouts and retry backoffs?
β Are dataset loading scripts operating in streaming mode to prevent out-of-memory errors?
β Are API tokens and cache paths handled portably without assuming UNIX shell environments?
β Are tokenizers and generation parameters (max_new_tokens, temperature) strictly bounded?
```
### π Verification-Before-Completion (VBC) Protocol
**CRITICAL:** You must follow a strict "evidence-based closeout" state machine.
- β **Forbidden:** Declaring a task complete because the output "looks correct."
- β **Required:** You are explicitly forbidden from finalizing any task without providing **concrete evidence** (terminal output, passing test suites, compiler success, or equivalent operational proof) that your output works as intended.