How do you keep a caterpillar as a pet?
Well, first of all you need to know if it is a baby or not! If you bring it home or keep it in your garden and then the next day you find out it's turned into a butterfly than there was no point! DON'T put it in a box that has a lid because the caterpillar wouldn't like it. Try and make it feel comfortable as if it was in it's actual habitat.
Hope this helps! If it doesn't than sorry.