· 2 min read
Custom scaffolding with Copilot - July Update
A custom tailored project setup for your needs in just one click, with GitHub Copilot.
You got the idea for a new and fun side project which you will abandon after a few weeks, but that’s another story.
You open your terminal and start typing:
mkdir my-new-project
cd my-new-project
And now, you think…
Ok, what files should I create now?
How should I define the folder structure for the project?
Depending on what project you want to create (a Next.js app, an Astro blog, an npm package) there’s most likely already a CLI tool which takes some parameters and creates the project for you.
Scaffolding and boilerplates for new apps are usually done this way, but sometimes you have some particular needs which are not covered in an existing template.
You might want to already start with a npm package, with settings and files for Open Source, jest set up, GitHub Actions workflows to run the tests, a license, a changelog template...
and so on.
What options do you have?
- Create an empty npm project with
npm init
and then add all the files you need - Search for an existing template which is close to what you need and then modify it
- Search for an existing project which has most of the features you need, copy it and remove the parts you don’t need
or…
- Use Copilot to define the folder structure and create the files you need in just one click
Copilot’s /createWorkspace new command
In July’s update GitHub Copilot introduced a new command: /createWorkspace
.
You can type in Copilot Chat /createWorkspace
followed by a prompt which describes what project you’re going to create.
To begin with, you will get a proposed folder structure based on your needs, with also some comments and description of what has been generated.
At the end of the message, a blue “Create Workspace” button will appear.
Clicking the button will ask you to select a folder in which Copilot will create all the files and folders previously proposed.
Files will not be empty! Copilot will also generate some example content for each file, including package.json, eslint config, perfectly working GitHub Actions workflows and more.
However… we’re still in an early phase. The folder structure is perfectly fine most of the time, but the content sometimes needs to be tweaked before running the generated project.
I gave it a try and recorded the session, you can watch it here:
Hello! My name is Leonardo and as you might have noticed, I like to talk about Web Development and Open Source!
I use GitHub every day and my favourite editor is Visual Studio Code... this might influence a little bit my conent! :D
If you like what I do, you should have a look at my YouTube Channel!
Let's get in touch, feel free to send me a DM on Twitter!