Automated Vercel Cleanup

Project’s GitLab Repo

Problem

I’ve been working with Vercel for a while now, and I love how easy it is to deploy applications. However, one thing that always bothered me was the deployment clutter. Vercel keeps all deployments, including previews from pull requests, indefinitely. This means that after months of active development, you can end up with hundreds, if not thousands, of old deployments taking up space. Managing these manually through Vercel’s dashboard is incredibly tedious, especially when you’re juggling multiple projects. I searched for an automated solution, but couldn’t find anything that fit my needs.

Solution

To solve this problem, I developed Vercel Purge or in short vp, a CLI tool designed to automatically clean up unused deployments in Vercel projects. With a single command, you can remove all old deployments from a specific project or even from all your projects at once. The tool is straightforward to use, provides confirmation prompts to prevent accidents, and supports bulk operations when you’re confident about what you’re removing. It’s fully functional and ready to use today!

Design

The vp CLI is written in Python and leverages the Vercel CLI under the hood. It uses the Vercel API to list and delete deployments, making it reliable and fast.

The tool supports several powerful options:

  • Project targeting: Remove deployments from a specific project or all projects at once.
  • Status checking: View deployment counts across your projects.
  • Project listing: See all your Vercel projects without making changes.
  • Force mode: Skip confirmation prompts for automated workflows.
  • Delay option: Schedule cleanup to run after a specified delay.

The command can be invoked as vercel_purge or its shorter alias vp, after it’s been installed, making it quick to type and remember.

Conclusion

I use vp daily on my own projects, and it’s been an absolute lifesaver. It’s saved me countless hours of manual cleanup work that I’d otherwise waste on navigating Vercel’s dashboard.

The more I used it, the more I realized this wasn’t just solving my own problem, but solving a problem for anyone regularly deploying to Vercel. That’s why I open-sourced it and made this blog post.

If you have a lot of deployments and previews just sitting there unused, you know the pain. Vercel’s slow UI and the base CLI tool make cleanup tedious and time consuming. This tool can significantly streamline that process and help you clean up your Vercel projects with ease. Check out vp on GitLab and give it a try!