W&B Plot Skill
MANDATORY Setup (Run First)
IMPORTANT: Before running ANY script, you MUST execute this setup block to ensure the correct working directory and virtual environment.
# Determine skill directory (Claude Code plugin or Codex/local)
if [ -n "${CLAUDE_PLUGIN_ROOT}" ]; then
SKILL_DIR="${CLAUDE_PLUGIN_ROOT}/skills/wandb-plot"
elif [ -d "${HOME}/.codex/wandb-plot-skill/skills/wandb-plot" ]; then
SKILL_DIR="${HOME}/.codex/wandb-plot-skill/skills/wandb-plot"
else
SKILL_DIR="$(pwd)"
fi
cd "$SKILL_DIR"
# Create/activate venv and install deps (uv preferred, pip fallback)
if [ ! -d ".venv" ]; then
if command -v uv &> /dev/null; then
uv venv .venv && . .venv/bin/activate && uv pip install -e .
else
python3 -m venv .venv && . .venv/bin/activate && pip install -e .
fi
else
. .venv/bin/activate
fi
After setup completes, all python3 scripts/*.py commands will work correctly from this directory.
Prereqs
- Auth: set
WANDB_API_KEY environment variable (recommended) or run wandb login.
Tools (Scripts)
scripts/list_projects.py
Inputs
--entity <entity> (optional; defaults to current user or org)
--limit <n> (optional, default: 100)
--json (optional)
Output
- Stdout table (default) or JSON list (with
--json), where each item includes:
name, entity, description, created_at, url
scripts/list_runs.py
Inputs
<entity/project> (required)
--state <state> (optional)
--limit <n> (optional, default: 100)
--json (optional)
Output
- Stdout table (default) or JSON list (with
--json), where each item includes:
id, name, state, created_at, summary_metrics, tags
scripts/list_metrics.py
Inputs
<entity/project> (required)
<run_id> (required; run id or run name)
--include-system (optional; include _step, _timestamp, etc.)
--json (optional)
Output
- Stdout table (default) or JSON dict (with
--json) keyed by metric name.
- Each metric entry includes
type, count, non_null_count, and for numeric metrics: min, max, mean, std.
scripts/download_plots.py
Inputs
<entity/project> (required)
<run_id> (required)
--pattern "<glob>" (optional; defaults to common image paths)
--output <dir> (optional; overrides default output location)
--force (optional; re-download if file exists)
Output
- Writes downloaded images to the output directory (flat filenames).
- Updates/creates
metadata.json in the same directory.
- Stdout lists downloaded/skipped files; returns an empty list (and prints “No plot files found…”) when nothing matches.
scripts/generate_plots.py
Inputs
<entity/project> (required)
<run_id> (required; comma-separated for multiple runs)
--metrics "<m1,m2,...>" (required; metric names as shown by list_metrics.py)
--all-metrics (optional; plot all metrics)
--full-res (optional; uses full scan_history)
--smooth <n> (optional; rolling average window)
--output <dir> (optional)
--ema-weight <w> (optional; default: 0.99)
--viewport-scale <n> (optional; default: 1000)
--no-ema (optional; disable EMA smoothing)
--group-by-prefix (optional; group outputs by metric prefix)
--include-system (optional; include system metrics like _step and system/* with --all-metrics)
Output
- Writes
<metric>.png for each generated plot plus metadata.json to the output directory.
- Stdout lists generated files; missing metrics raise an error listing available metrics.
Workflow
python3 scripts/list_projects.py --limit 10
python3 scripts/list_runs.py <entity/project> --limit 10
python3 scripts/list_metrics.py <entity/project> <run_id>
python3 scripts/download_plots.py <entity/project> <run_id>
python3 scripts/generate_plots.py <entity/project> <run_id> --metrics loss,accuracy
python3 scripts/generate_plots.py <entity/project> run1,run2 --metrics loss --ema-weight 0.99 --viewport-scale 1000
python3 scripts/generate_plots.py <entity/project> run1,run2 --metrics rewards/total_mean,rewards/total_std --output /path/to/folder --group-by-prefix
python3 scripts/generate_plots.py <entity/project> run1,run2 --all-metrics --output /path/to/folder --group-by-prefix
Outputs
Default output directory:
wandb_plots/<entity>_<project>/<run_name>_<run_id>/
- *.png
- metadata.json
If download_plots.py finds no images, fall back to generate_plots.py.
1---2name: wandb-plot3description: Download and generate plots from Weights & Biases runs. Use when you need to: - List projects you have access to - List runs in a W&B project - Inspect available metrics for a run - Download existing plot images from a run - Generate line plots from metric history (loss, accuracy, etc.)4---5
6# W&B Plot Skill
7
8## MANDATORY Setup (Run First)
9
10**IMPORTANT:** Before running ANY script, you MUST execute this setup block to ensure the correct working directory and virtual environment.
11
12```bash
13# Determine skill directory (Claude Code plugin or Codex/local)
14if [ -n "${CLAUDE_PLUGIN_ROOT}" ]; then
15 SKILL_DIR="${CLAUDE_PLUGIN_ROOT}/skills/wandb-plot"
16elif [ -d "${HOME}/.codex/wandb-plot-skill/skills/wandb-plot" ]; then
17 SKILL_DIR="${HOME}/.codex/wandb-plot-skill/skills/wandb-plot"
18else
19 SKILL_DIR="$(pwd)"
20fi
21cd "$SKILL_DIR"
22
23# Create/activate venv and install deps (uv preferred, pip fallback)
24if [ ! -d ".venv" ]; then
25 if command -v uv &> /dev/null; then
26 uv venv .venv && . .venv/bin/activate && uv pip install -e .
27 else
28 python3 -m venv .venv && . .venv/bin/activate && pip install -e .
29 fi
30else
31 . .venv/bin/activate
32fi
33```
34
35After setup completes, all `python3 scripts/*.py` commands will work correctly from this directory.
36
37## Prereqs
38
39- Auth: set `WANDB_API_KEY` environment variable (recommended) or run `wandb login`.
40
41## Tools (Scripts)
42
43### `scripts/list_projects.py`
44
45**Inputs**
46- `--entity <entity>` (optional; defaults to current user or org)
47- `--limit <n>` (optional, default: 100)
48- `--json` (optional)
49
50**Output**
51- Stdout table (default) or JSON list (with `--json`), where each item includes:
52 - `name`, `entity`, `description`, `created_at`, `url`
53
54### `scripts/list_runs.py`
55
56**Inputs**
57- `<entity/project>` (required)
58- `--state <state>` (optional)
59- `--limit <n>` (optional, default: 100)
60- `--json` (optional)
61
62**Output**
63- Stdout table (default) or JSON list (with `--json`), where each item includes:
64 - `id`, `name`, `state`, `created_at`, `summary_metrics`, `tags`
65
66### `scripts/list_metrics.py`
67
68**Inputs**
69- `<entity/project>` (required)
70- `<run_id>` (required; run id or run name)
71- `--include-system` (optional; include `_step`, `_timestamp`, etc.)
72- `--json` (optional)
73
74**Output**
75- Stdout table (default) or JSON dict (with `--json`) keyed by metric name.
76- Each metric entry includes `type`, `count`, `non_null_count`, and for numeric metrics: `min`, `max`, `mean`, `std`.
77
78### `scripts/download_plots.py`
79
80**Inputs**
81- `<entity/project>` (required)
82- `<run_id>` (required)
83- `--pattern "<glob>"` (optional; defaults to common image paths)
84- `--output <dir>` (optional; overrides default output location)
85- `--force` (optional; re-download if file exists)
86
87**Output**
88- Writes downloaded images to the output directory (flat filenames).
89- Updates/creates `metadata.json` in the same directory.
90- Stdout lists downloaded/skipped files; returns an empty list (and prints “No plot files found…”) when nothing matches.
91
92### `scripts/generate_plots.py`
93
94**Inputs**
95- `<entity/project>` (required)
96- `<run_id>` (required; comma-separated for multiple runs)
97- `--metrics "<m1,m2,...>"` (required; metric names as shown by `list_metrics.py`)
98- `--all-metrics` (optional; plot all metrics)
99- `--full-res` (optional; uses full `scan_history`)
100- `--smooth <n>` (optional; rolling average window)
101- `--output <dir>` (optional)
102- `--ema-weight <w>` (optional; default: 0.99)
103- `--viewport-scale <n>` (optional; default: 1000)
104- `--no-ema` (optional; disable EMA smoothing)
105- `--group-by-prefix` (optional; group outputs by metric prefix)
106- `--include-system` (optional; include system metrics like `_step` and `system/*` with `--all-metrics`)
107
108**Output**
109- Writes `<metric>.png` for each generated plot plus `metadata.json` to the output directory.
110- Stdout lists generated files; missing metrics raise an error listing available metrics.
111
112## Workflow
113
114```bash
115python3 scripts/list_projects.py --limit 10
116python3 scripts/list_runs.py <entity/project> --limit 10
117python3 scripts/list_metrics.py <entity/project> <run_id>
118python3 scripts/download_plots.py <entity/project> <run_id>
119python3 scripts/generate_plots.py <entity/project> <run_id> --metrics loss,accuracy
120python3 scripts/generate_plots.py <entity/project> run1,run2 --metrics loss --ema-weight 0.99 --viewport-scale 1000
121python3 scripts/generate_plots.py <entity/project> run1,run2 --metrics rewards/total_mean,rewards/total_std --output /path/to/folder --group-by-prefix
122python3 scripts/generate_plots.py <entity/project> run1,run2 --all-metrics --output /path/to/folder --group-by-prefix
123```
124
125## Outputs
126
127Default output directory:
128
129```
130wandb_plots/<entity>_<project>/<run_name>_<run_id>/
131 - *.png
132 - metadata.json
133```
134
135If `download_plots.py` finds no images, fall back to `generate_plots.py`.