Lifecycle & custom scripts

Modified on: Tue, 21 Jul, 2026 at 3:36 PM

Lifecycle scripts are commands the app runs automatically at key moments in a worktree's life — when it's created, when you run your app, and when it's deleted. You can also add your own custom scripts. This article covers each and where to set them up.

The three lifecycle scripts

  • Setup — runs when a worktree is created, to prepare the checkout (for example, installing dependencies). A good setup script means a new worktree is ready to work in without any manual steps.
  • Launch — defines how to run your app, so you can start it for testing and preview it in the in-app browser.
  • Teardown — runs when you delete a worktree, to clean up after it so nothing is left behind.

Custom scripts

Beyond the three lifecycle scripts, you can define your own custom scripts for a workspace and run them whenever you need them — anything you'd otherwise run by hand.

Where they're configured

Set these up in your workspace's script settings. Each worktree also exposes its scripts, so you can see and run them from the worktree itself.

Next steps

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.