In the previous tutorial, we set up GitHub Spec Kit in our project and explored its structure and got a basic understanding of its commands. In this tutorial, we will dive deeper into one of the commands provided by Spec Kit: the Constitution command. We are going to use the /constitution command to update the constitution file that defines the high-level principles and guidelines for our AI assistant to follow throughout the development process.
If we look into the specify/memory/constitution.md file, you can see that it already has some default content that outlines general principles for the AI assistant. As an example, if accessibility is important for our project, we can add a guideline to constitution file to ensure that all generated code adheres to accessibility best practices or if you use a specific library or framework like Next.js or Laravel, you can add that to the constitution so that the AI assistant knows to use those technologies when generating code.
We can obviously manually edit the constitution.md file to add or modify these guidelines, but using the /constitution command in Copilot chat makes it much easier and more interactive. In this project I’m going to build a simple web app that allows users to generate iCal calendar files. Users can input event details through a form, and the app will generate a downloadable .ics file that can be imported into calendar applications. So in the copilot chat, I will type /constitution to invoke the constitution command and then provide some specific guidelines for our project:

As you can see in the screenshot above, I have given the package.json file as context so that the AI assistant can understand the existing dependencies. I deliberately asked the AI to not to write and test because the default prompt that Spec Kit provides are geared towards writing tests, which can take a lot of time and might not be necessary for a dummy project like this. I know tests are important when you develop a real project, if this is a real project, I would definitely keep the testing guidelines in the constitution and I would outline my testing preferences. Another important point is try defferent models and check the guidelines they provide. Play around and choose the one that fits your needs the best.
When we fire off the command, the AI agent will find that custom constitution prompt file inside .github/agents/ folder and use that to generate an updated constitution based on our input inside specify/memory/constitution.md. Since Spek Kit is being actively developed, the exact behavior and the folders structure might change over time. In the .github/agents/speckit.constitution.agent.md file, you can see how the prompt is structured and what kind of instructions it provides to the AI assistant. In that file $ARGUMENTS is a placeholder that will be replaced with the actual arguments we provide in the Copilot chat.
If we open the specify/memory/constitution.md file, you can see that it’s basically a template with a bunch of placeholders for different principles. These are the placeholders Copilot or any other AI agent should be updating with our principles we gave in the chat. So this constitution file serve as a reference to all future specs, plans or code generated by the coding agent with goal being that anything in the constitution should trump all other instructions, because those are your non negotiable principles.
Let’s run the command. It might take a little bit of time to complete the operation and along the way it might ask your permission to do certain things. After the command is finished, you will most likely see a summary of the changes made to the constitution file in the chat window. You can then open the specify/memory/constitution.md file to review the updated content. The file should now reflect the guidelines we provided in the Copilot chat in more detail. For example, it should now explicitly mention not to write tests. With constitution.md file, three more files should be updated. They are plan-template.md, tasks-template.md and spec-template.md inside specify/templates/ folder. Prior to running the constitution command, these files had some default content like testing and different features that we implement. Since I said not to write tests, those files should now reflect that preference by removing or modifying any sections related to testing.
In the constitution.md file, you can see that placeholders got replaced with actual principles we provided. If you use the same message that I used in the chat, you should see similar headings like “Clean Code”, “Simple UX”, “Minimal Dependencies”, and so on. Under each heading, there should be a brief explanation of the principle and how the AI assistant should adhere to it during the development process.
In this tutorial, we’ve run the first command which updates the constitution file with any governing principles. In turn it also updates any other template files in accordance with those principles, so that when we come to use them later, they’ll incorporate those guidelines. Going forward, when we start to use other commands the idea is that this constitution file serves as a memory or guidance to the coding agent and forces it to stay within these outlined principles. So we are kind of putting walls around the application and we are saying “stay within these boundaries at all times”. The next step is to use the /specify command create a Spec for a new feature.