# Templates Directory

> **Organized by Specification System Source**

This directory contains templates and slash commands organized by their specification system source, following MetaSpec's **Specification Composability** principle.

---

## 📁 Directory Structure

```
templates/
{% for sc in slash_commands | groupby('source') %}├── {{ sc.grouper }}/               # From {% if sc.grouper == 'generic' %}MetaSpec library/generic{% elif sc.grouper.startswith('sdd/') %}MetaSpec library/{{ sc.grouper }}{% else %}library/{{ sc.grouper }}{% endif %}
│   ├── commands/           # Slash Commands (.md files)
│   └── templates/          # Template files
{% endfor %}
```

**Key Principle**: Each source maintains its own namespace, preventing naming conflicts and making provenance clear.

---

## 🎯 Available Templates

{% for sc in slash_commands | groupby('source') %}
### {{ sc.grouper }}

{% for cmd in sc.list %}**`{{ cmd.name }}-template.md`** - {{ cmd.description }}
- **Command**: `/{{ package_name }}.{{ cmd.name }}`
- **Location**: `templates/{{ sc.grouper }}/templates/{{ cmd.name }}-template.md`
{% endfor %}
{% endfor %}

---

## 🔧 How to Use

### 1. Using Slash Commands (AI Agents)

In your AI chat (Cursor, Windsurf, etc.), use slash commands to invoke templates:

```
/{{ package_name }}.specify "User Authentication"
→ Uses templates/generic/templates/specify-template.md
→ Generates specs/001-user-auth/spec.md
```

### 2. Using CLI Commands

Some templates can be invoked via CLI:

```bash
{{ package_name }} init my-spec.yaml
{{ package_name }} validate my-spec.yaml
```

### 3. Manual Template Usage

You can also copy templates manually:

```bash
cp templates/generic/templates/specify-template.md specs/my-feature/spec.md
# Edit the copied file
```

---

## ➕ Adding Custom Templates

### Option 1: Add to Existing Source

Create new template in appropriate source directory:

```bash
# Add to generic source
templates/generic/templates/my-custom-template.md
templates/generic/commands/my-custom.md
```

### Option 2: Create New Source

Create a new source directory for domain-specific templates:

```bash
mkdir -p templates/custom/commands
mkdir -p templates/custom/templates

# Add your templates
templates/custom/templates/my-template.md
templates/custom/commands/my-command.md
```

---

## 📖 Specification System Sources

{% for sc in slash_commands | groupby('source') %}
### {{ sc.grouper }}

{% if sc.grouper == 'generic' %}**From**: MetaSpec library/generic (Universal SD-X patterns)
**Purpose**: Domain-agnostic specification workflows
{% elif sc.grouper.startswith('sdd/') %}**From**: MetaSpec library/{{ sc.grouper }} (Spec-Driven Development)
**Purpose**: Software development workflows
{% else %}**From**: MetaSpec library/{{ sc.grouper }}
**Purpose**: Specialized specification workflows
{% endif %}

**Available Commands**: {{ sc.list | map(attribute='name') | join(', ') }}

{% endfor %}

---

## 🔍 Understanding the Structure

### Why Organize by Source?

1. **Clear Provenance**: Know which specification system each template comes from
2. **Namespace Isolation**: Different sources can have same-named commands without conflict
3. **Composability**: Mix and match specification systems as needed
4. **Maintainability**: Easy to update templates from upstream sources

### Example: Multiple Sources

```
templates/
├── generic/              # Universal patterns (0→1)
│   ├── commands/
│   │   └── specify.md
│   └── templates/
│       └── specify-template.md
└── spec-kit/             # Development patterns
    ├── commands/
    │   └── plan.md
    └── templates/
        └── plan-template.md
```

Both `generic` and `spec-kit` can coexist, each maintaining its own namespace.

---

## 📚 Learn More

- **AI Agent Guide**: See [AGENTS.md](../AGENTS.md) for AI-assisted development
- **MetaSpec Commands**: See [.metaspec/README.md](../.metaspec/README.md) for speckit development
- **Constitution**: See [memory/constitution.md](../memory/constitution.md) for design principles
- **Examples**: See [examples/](../examples/) directory

---

**Generated by**: MetaSpec {{ metaspec_version }}  
**Speckit**: {{ name }} v{{ version }}  
**Last Updated**: {{ date }}

