Article summary
You’ve probably written a script that was intended to be used only once. But what do you after it has served its purpose? It’s easy to throw it in the digital trash bin when you’re done, but I believe these “throwaway” files should be tracked in version control.
You May Need It Later
Sometimes that one-off script that you wrote may come in handy later. If you delete it, you may cost yourself extra work.
For example, let’s say you have some data stored in a JSON file, and a less technically inclined client wants to be able to read through it. An easy solution would be to write a script that converts that JSON file into a CSV file. You write the script and deliver a well-formatted CSV to your client. They are happy with the work, so you delete the script.
A few weeks later, your client wants you to convert another JSON file with new data into another CSV file. Since the script that you used on the last JSON file was deleted, you’ll have to spend more effort writing the script, and the client will wait longer for the new file.
If that script had been saved in version control, you could deliver it to your client sooner, and you wouldn’t waste your time remaking your old script.
Artifact Documentation
I worked on an app that synchronized data from an API so it could be used offline. Before we implemented the synchronization process, we wanted a proof of concept that would use a pre-populated database. In order to create this, I wrote a script that pulled data from the API and seeded an SQLite database. This was sufficient as a POC until we had to implement the synchronization process.
When it came time to create the synchronization process, we saved a lot of time and effort by saving the script in version control. We were able to model the process around our script since it documented how the data was retrieved and used.
Low Effort, Low Risk
Finally, it doesn’t cost much to include these scripts in your project. The worst that can happen is that you never run the script again, and it stays in your repository forever.
You can always delete the file if you’re 100% certain that that script will never be run again. If you realize it was a mistake to delete that file, it will at least be recoverable.
Think carefully the next time you are considering deleting a “one-time-use” script. It could come back to haunt you.