TUTORIAL
How to Automatically Run Commands in Visual Studio Code
Use Visual Studio Code tasks to make your life easier

There are many tools available to automate developer tasks such as listing, building, packaging, testing, and deploying software systems. Examples of these are NPM scripts, Gulp, Make, ESLint, Webpack, and Prettier.
Usually, these commands are run from the command line giving developers quick access to a series of steps that need to be taken. Sometimes it might be useful if you could run these commands straight from your editor, perhaps even automate when they should run.
This is where Visual Studio Code’s task feature comes into play.
Use Case
Every morning when I stumble out of bed I grab a cup of coffee, write a good morning message to my team on Slack and fire up VS Code and open my local dev URL in the browser.
What I often seem to forget is to start up Webpack to watch and build my assets. It isn’t until I made a few CSS or JS changes that I notice that nothing is happening. (Don’t judge me, I usually wake up at 6 AM 😅)
In this article, I want to make a task that starts up my asset watcher when I open VS Code. This way I can spare myself some of that self-created annoyance.
Creating a Task
You can create a task manually, or you can make a task based on an existing automatically detected script. VS Code already recognizes NPM scripts for example.
In this case, I used the automatically detected NPM script as a template. To do this:
- Open the command palette — CTRL / CMD + Shift + P
- Select the configure task option — Tasks: Configure Task
- Choose the NPM script you want to make a task for
I did this for my start script and it generated the following output for me.






