Skip to content

Getting Started

m4bwav edited this page Nov 28, 2026 · 2 revisions

Install

claude plugin marketplace add m4bwav/trainwright
claude plugin install trainwright@trainwright

Then ask your agent things like "train a style LoRA on this folder" or "redo that training run exactly", and the skill drives tw.py. You can also run the script yourself, as below. The walk-through was run on Windows with Python 3.14 against a stand-in base file and a two-image dataset; the training itself was not run (no trainer was installed for the test).

Private settings

Facts about your machine live outside the repository, in the folder named by TRAINWRIGHT_HOME (default ~/.trainwright):

  • hosts.json: disk_floor_gb (default 100) and trainers.<name>.python and .entry for each trainer run may start.
  • leak-terms.txt: one private term per line, for tw.py leak.

The walk-through used this hosts.json:

{"disk_floor_gb": 1, "trainers": {"ai-toolkit": {"python": "/opt/ai-toolkit/venv/bin/python", "entry": "/opt/ai-toolkit/run.py"}}}

1. A recipe skeleton

python tw.py new image-lora my-style
{
 "ok": true,
 "recipe": "my-style.recipe.json",
 "next": "fill base, dataset, then tw.py check"
}

A fresh skeleton fails check until the base and dataset are filled in:

python tw.py check my-style.recipe.json --shallow
{
 "ok": false,
 "fail": [
  "base.name is empty",
  "base.path is empty",
  "base.licence is empty",
  "base.sha256 is empty (tw.py hash <file>)",
  "dataset.items is empty (tw.py hash --manifest <folder> fills it)"
 ],
 "warn": []
}

2. Hash the base and the dataset

python tw.py hash base.safetensors
python tw.py hash datasets/my-style --manifest --source "own photos"

Copy the base hash into base.sha256 and the manifest's items into dataset.items, set dataset.root, base.name, base.path and base.licence, and pick an empty output.dir. The output of both commands is on the Commands page.

3. Check, then write the trainer config

python tw.py check my-style.recipe.json --shallow
{
 "ok": true,
 "fail": [],
 "warn": []
}
python tw.py config my-style.recipe.json --trainer ai-toolkit
{
 "ok": true,
 "trainer": "ai-toolkit",
 "config": "my-style.ai-toolkit.yaml",
 "proven_on_real_trainer": true,
 "note": null
}

4. Dry run

python tw.py run my-style.recipe.json my-style.ai-toolkit.yaml --dry

The dry run prints the command it would start (the trainer's Python, its entry script and the config) along with the gate results, and starts nothing. Its full output is on the Commands page. A real run without --dry refuses when any gate fails, writes the trainer's output to my-style.recipe.log and appends the run to the recipe's runs list.

The skill's advice before a long run: a smoke run of a few steps on a copy of the recipe with a small config.steps, then the real run.

5. Pick and record

python tw.py record my-style.recipe.json --score style_match=0.82 --score "note=best at 300" --pick step_300 --files output/my-style/step_100.safetensors
{
 "ok": true,
 "recipe": "my-style.recipe.json",
 "still_missing": []
}

Next: Commands for rerun, diff and leak.

Clone this wiki locally