Intermediate

Templates in spec-kit

Explore built-in templates, create custom ones, use template variables and conditional sections, and build your organization's template library.

Built-in Templates

spec-kit ships with five professional templates designed for common specification types:

📝

PRD Template

Product Requirements Document with sections for overview, goals, user stories, requirements, metrics, and timeline.

Tech Spec Template

Technical specification covering architecture, components, data models, APIs, security, and deployment.

🔌

API Spec Template

API documentation with endpoints, request/response schemas, authentication, error codes, and rate limits.

📋

ADR Template

Architecture Decision Record with context, decision, rationale, alternatives considered, and consequences.

📄

RFC Template

Request for Comments template for proposing changes, gathering feedback, and building consensus.

Using a Built-in Template

Terminal
# List available templates
specc templates list

# Create a spec using a built-in template
specc create --template prd --name "search-feature"

# Preview a template before using it
specc templates preview prd

Custom Template Creation

Create templates tailored to your team's needs:

Terminal
# Create a new custom template
specc templates create --name "microservice-spec"

# Create from an existing spec
specc templates create --from specs/tech-specs/auth-service.md \
  --name "microservice-spec"

Custom templates are stored in .specc/templates/ as YAML + Markdown files:

microservice-spec.yaml
---
name: microservice-spec
description: Template for microservice specifications
category: technical
variables:
  - name: service_name
    required: true
    prompt: "Service name"
  - name: port
    default: 3000
    prompt: "Default port number"
  - name: database
    options: [postgres, mysql, mongodb]
    prompt: "Database type"
---

# {{service_name}} Service

## Overview
Describe the purpose of the {{service_name}} service.

## Architecture
- **Port:** {{port}}
- **Database:** {{database}}
- **Protocol:** REST/gRPC

## Endpoints
Define API endpoints here.

## Data Model
Define database schema for {{database}}.

## Dependencies
List upstream and downstream service dependencies.

## Deployment
Container configuration and scaling parameters.

Template Variables

Variables make templates dynamic and reusable. spec-kit supports several variable types:

Variable Type Syntax Description
Required {{name}} Must be provided when creating a spec from this template
Default value {{port:3000}} Uses the default if not explicitly set
Options {{db:postgres|mysql}} User selects from predefined choices
Auto-generated {{_date}}, {{_author}} Automatically populated by spec-kit

Conditional Sections

Templates can include or exclude sections based on variable values:

Template with Conditionals
{{#if has_api}}
## API Endpoints
Define REST API endpoints for this service.

### Authentication
All endpoints require Bearer token authentication.
{{/if}}

{{#if database == "postgres"}}
## Database Migrations
Use Prisma for PostgreSQL schema management.
{{/if}}

{{#if database == "mongodb"}}
## Collections
Define MongoDB collections and indexes.
{{/if}}

{{#each stakeholders}}
- **{{name}}** ({{role}}): {{responsibility}}
{{/each}}

Organization Template Library

Share templates across your organization:

Terminal
# Publish a template to your org library
specc templates publish --name "microservice-spec" \
  --org acme-corp

# Install a template from the org library
specc templates install acme-corp/microservice-spec

# List organization templates
specc templates list --org acme-corp

# Update a template
specc templates update acme-corp/microservice-spec
Best practice: Maintain a small set of well-designed templates rather than creating one for every situation. Templates with clear variables and conditional sections can cover a wide range of use cases.