If you're using GitHub Copilot in Visual Studio Code, there's a powerful new feature that can save you time and make your AI-powered development workflow more efficient: the /init command. This slash command provides a quick way to set up custom instructions for your workspace or adapt your existing instructions to the specific project context, helping you establish consistent coding practices and AI responses across your projects.
What is the /init command?
The /init command is a chat slash command in VSCode that helps you quickly prime your workspace with custom instructions for GitHub Copilot. When you type /init in the chat input box, it automatically generates a .github/copilot-instructions.md file tailored to your workspace.
Think of it as a quick-start wizard for setting up AI guidelines that will influence how Copilot generates code and handles development tasks throughout your project.
How to use the /init command?
Using the /init command is straightforward:
- Open the Chat view in VSCode (you can use the GitHub Copilot icon in the Activity Bar)
- In the chat input box, type
/init - Press Enter
That's it! VSCode will start analyzing your workspace and automatically generate a .github/copilot-instructions.md file with custom instructions that match your coding practices and project structure.
After the file is generated, you should:
- Review the generated instructions carefully
- Make any necessary edits to align with your specific needs
- Commit the file to your version control system to share with your team
The generation is done using a init.prompt.md file that you can customize further if you want. No magic here!
As mentioned in the intro, this also works when you already have a .github/copilot-instructions.md file in place. In that case the /init command will review the existing settings and adapt them where necessary.
Nice!