Let's say I want to let the trainer execute the command /spawn (Teleporting me to spawn) on loss.
What I did was, use the command /tedit add loss /spawn @pl and right clicked my Trainer to add the command. I checked if it was there with /tedit list and it was there.