Before keeping a caterpillar, make sure it is still in the larval stage and not about to pupate. Provide a safe container with airflow, fresh leaves from the plant you found it on, and a setup that mimics its natural habitat. Avoid sealed boxes with lids, and be prepared to release it or provide a suitable pupation space if it begins to transform.