Spec-kit
Spec-kit is a collection of AI-Ready Specification Templates for various common features. These templates are designed to help developers create clear and comprehensive specifications that can be used to guide AI-driven code generation.
Spec-kit templates follow the CARE framework, which stands for Context, Action, Result, and Evaluation. This framework helps ensure that specifications are detailed and structured in a way that minimizes ambiguity and enhances the quality of AI-generated code.
Spec-Kit includes templates for a variety of features, such as user authentication, data validation, API endpoints, and more. Each template provides a structured format that developers can fill out with specific details relevant to their project.
Spec-kit aims to streamline the process of creating AI-ready specifications, making it easier for developers to leverage AI tools effectively in their code development workflows.
Spec-kit works with most AI code generation tools, including OpenAI’s Codex, GitHub Copilot, and Anthropic’s Claude. By using these templates, developers can improve the accuracy and reliability of the code generated by AI models.
Spec-kit has a CLI that is installed and run locally from VS Code. or alternatively, you can download the templates directly from the GitHub release repository. Pick either the sh or ps1 script depending on your operating system. and unpack the zip into your project root. This will create a .specify folder with the templates and scripts, and a .codex directory.

Spec-kit sets up a .specify folder in your project root with markdown templates for common features. The .specify folder will intitally contain templates such as:
* Memory - which should include your constituional principles for AI code generation.
* Scripts - which contains helper scripts to generate SPEC.md files from templates.
* Templates - which contains markdown files for various common features.
The .specify/Memory folder is where you can define your constitutional principles for AI code generation. These principles are used to guide the behavior of AI agents and ensure that they generate code that aligns with your project’s goals and values. For example, you might include principles such as “Prioritize security best practices” or “Ensure code is well-documented and maintainable”. By defining these principles, you can help ensure that the code generated by AI agents meets your standards and requirements.
The .specify/Scripts folder contains helper scripts that can be used to generate SPEC.md files from the templates in the .specify /Templates folder. These scripts can automate the process of creating specifications, making it easier and faster to generate high-quality specifications for your project. For example, you might have a script that takes a template for user authentication and fills in the specific details for your project, such as the authentication method you want to use and the acceptance criteria you want to enforce. By using these scripts, you can save time and ensure consistency in your specifications across different features and components of your project.
The .specify/Templates folder includes the following AI-Ready Specification Templates:
- agent-file-template.md - Template for AI agents that interact with files.
- checklist-template.md - Template for creating checklists to guide AI code generation.
- constitution-template.md - Template for defining constitutional principles for AI code generation.
- plan-template.md - Template for outlining plans and strategies for AI-driven code development.
- spec-template.md - General template for creating AI-Ready Specifications for any feature.
- tasks-template.md - Template for defining specific tasks and actions for AI agents to perform.
Prompts
In order to use the Spec-kit templates effectively, you can use the following prompts to guide your AI agents in generating code based on the specifications you create:
Constitution is used to define the guiding principals of the AI agents. So once defined you would rarely need to update this, unless you want to change the guiding principles of your AI agents.
Sample Constitution.
A constitutuion should set out the pricipals that the AI agent should follow when generating the code. The Principals shouldn’t be too specific and drop into technical details, but should be high level and set out the values and goals that the AI agent should follow when generating code. The constitution will be defferent defpending on the project and the goals of the project, but it should set out the guiding principles that the AI agent should follow when generating code.
So below I’ve tried to set out what I would want a API that interfaces to a third-party service todo.
- Have a responsive interface for user interaction, with OpenAPI documentation for easy integration and testing.
- Have a Bus interface for service integration.
- Use a structured logging format for easy monitoring and troubleshooting.
- Defined Interface for health status reporting to support tools for monitoring and quick issue resolution.
- Testing should be a priority to ensure reliability and robustness in production environments.
Example.
Create a web api with the following principles:
- Security
- The API should follow security best practices, including input validation, authentication, and authorization to protect against common vulnerabilities and ensure the safety of user data.
- Interface
- Usability
- The API should have a Restful design and provide clear documentation for developers to ensure ease of use and integration.
- Service Integration
- The API should be designed to support integration with service buses, allowing for seamless communication and data exchange between different services and components within the system.
- Usability
- Code
- The API should be designed with maintainability and scalability in mind, following best practices in software development to ensure that it can evolve and adapt to changing requirements over time.
- Performance
- The API should be designed to be efficient and performant, with a focus on minimizing latency and maximizing throughput to ensure a smooth user experience.
- Testing
- Unit Testing
- Code will be tested with unit tests to ensure that individual components function correctly and to catch any issues early in the development process.
- Code coverage will be measured to ensure that a high percentage of the codebase is tested, which helps to improve the overall quality and reliability of the API.
- End to End Testing
- The API will undergo end-to-end testing to validate that all components work together as expected and to identify any issues that may arise in a production environment.
- Mock Testing
- In development environments, the API will employ mock testing to simulate various scenarios and edge cases, ensuring that it can handle unexpected inputs and conditions gracefully.
- Unit Testing
- Logging
- The API will produce logs in a structured format that can be easily consumed by log management tools for monitoring and troubleshooting purposes.
- Monitoring and Health Reporting
- The API will report health status through an interface with support tools so its current status can be easily monitored and any issues can be quickly addressed.