# ixi-enki/spec-kit architecture

> Architecture diagram of the GitHub repository ixi-enki/spec-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ixi-enki/spec-kit
- Repository: https://github.com/ixi-enki/spec-kit

## Overview

1. **What this repository is**
   - This is the source for **Spec Kit / Specify CLI**, a Python-based command-line tool for **spec-driven development**.
   - Its job is not to build an app itself, but to **bootstrap and manage project artifacts** for AI coding agents: specs, plans, tasks, templates, presets, extensions, integrations, and workflows.

2. **Primary runtime boundary: the CLI package**
   - The executable logic lives under `src/specify_cli/`.
   - This is the core runtime boundary where commands are parsed and routed into feature areas like initialization, integration management, preset/extension installation, and workflow handling.
   - The package is organized around CLI concerns rather than domain application logic.

3. **Core command surfaces**
   - `src/specify_cli/commands/` contains the top-level command handlers:
     - `init` for bootstrapping a new project
     - `integration` for listing/installing agent integrations
     - `extension` for extension management
     - `preset` for preset management
     - `workflow` for workflow-related actions
   - These commands are the main entry points that orchestrate everything else in the repo.

4. **Artifact generation and templating**
   - `templates/`, `presets/`, `extensions/`, and `workflows/` store the content that gets materialized into user projects.
   - The CLI resolves these assets at runtime and copies or merges them into target directories, especially `.specify/` and agent-specific command locations.
   - The docs emphasize a priority stack: **project-local overrides → presets → extensions → core templates**.

5. **Spec-driven project model**
   - The repository’s architecture revolves around a staged workflow:
     - constitution
     - spec
     - plan
     - tasks
     - implementation
   - The templates in `templates/commands/` and the preset/extension commands under `presets/*/commands/` and `extensions/*/commands/` encode that workflow as reusable artifacts for coding agents.
   - This is the central product boundary: the CLI produces and maintains the files that guide downstream AI-assisted development.

6. **Integration subsystem**
   - `src/specify_cli/integrations/` contains a large catalog of agent-specific adapters.
   - Each integration subpackage represents a supported AI coding agent or CLI environment, such as Copilot, Claude, Gemini, Cursor, Codex, Windsurf, and others.
   - The integration layer is responsible for translating the generic Spec Kit workflow into the file layout and command style expected by each agent.

7. **Catalog-driven extensibility**
   - `catalogs.py`, `extensions.py`, `presets.py`, and `src/specify_cli/integrations/catalog.py` suggest a registry/catalog model for discovering supported items.
   - JSON catalog files in `extensions/catalog.json`, `presets/catalog.json`, `integrations/catalog.json`, and community variants drive what the CLI knows how to install or display.
   - This gives the repo a data-driven architecture: supported integrations and community contributions are described in catalogs rather than hardcoded one-off logic.

8. **Workflow engine**
   - `src/specify_cli/workflows/` contains a separate workflow engine with steps such as `command`, `prompt`, `shell`, `if_then`, `switch`, `while_loop`, `do_while`, `fan_out`, `fan_in`, and `gate`.
   - This is a distinct subsystem from the CLI command handlers: the CLI invokes workflows, and the engine coordinates execution flow and branching.
   - The presence of expression handling and step types indicates an internal DSL-like orchestration layer for structured agent workflows.

9. **Authentication and external service access**
   - `src/specify_cli/authentication/` supports GitHub and Azure DevOps authentication flows.
   - `src/specify_cli/_github_http.py` and `src/specify_cli/authentication/http.py` show that the tool talks to remote services over HTTP, most likely for catalog lookups, release-related operations, or service-backed actions.
   - This is the primary network boundary in the repo.

10. **Repository asset layout**
   - `media/` holds product images and documentation assets.
   - `docs/` is a full documentation site built with **DocFX** (`docs/docfx.json`, `docs/toc.yml`), meaning docs are a first-class deliverable, not just README text.
   - `newsletters/`, `CHANGELOG.md`, and governance files like `CONTRIBUTING.md`, `SECURITY.md`, and `SUPPORT.md` show that this is an externally consumed open-source tool with active release and community processes.

11. **Automation and release pipeline**
   - `.github/workflows/` contains CI/CD for linting, testing, docs publishing, releases, stale issue handling, and catalog assignment.
   - The repo also includes release-process documentation and lock files for community extension/preset automation.
   - This indicates a strong GitHub-centered maintenance model: code changes are validated in CI, docs are published, and release flows are automated.

12. **Cross-platform scripting and bootstrap**
   - `scripts/bash/` and `scripts/powershell/` provide the same bootstrap/setup operations across Unix and Windows environments.
   - `.devcontainer/` adds a development container so contributors can work in a reproducible environment.
   - These scripts are part of the install/bootstrap boundary used by `init` and by repo maintenance workflows.

13. **Testing strategy**
   - `tests/` is broad and architecture-revealing: there are dedicated tests for authentication, CLI behavior, integrations, extensions, presets, workflows, path traversal protection, and update hardening.
   - The test layout mirrors the runtime subsystems, which suggests the intended architecture is modular and contract-driven rather than monolithic.

14. **Overall architecture in one sentence**
   - Spec Kit is a **catalog-driven Python CLI platform** that manages **specification artifacts and agent integrations** through a layered system of **templates, presets, extensions, and workflows**, with strong documentation, CI, and cross-platform scripting support.

Main entry points: [`src/specify_cli/commands`](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/commands) (Commands), [`src/specify_cli/catalogs.py`](https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/catalogs.py) (Catalogs), [`tests`](https://github.com/ixi-enki/spec-kit/tree/main/tests) (Tests), [`src/specify_cli/integrations`](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/integrations) (Integrations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI runtime"]
  node_commands["Commands<br/>cli entrypoints"]
  node_core["Core package<br/>cli runtime"]
  node_workflow_engine["Engine<br/>workflow runtime<br/>[engine.py]"]
  node_workflow_steps["Steps<br/>workflow primitives"]
  node_catalogs["Catalogs<br/>registry model<br/>[catalogs.py]"]
end

subgraph group_content["Artifact content"]
  node_assets["Asset layer<br/>resource loading<br/>[_assets.py]"]
  node_init_tpl["Templates<br/>spec artifacts"]
  node_presets["Presets<br/>artifact catalog"]
  node_extensions["Extensions<br/>artifact catalog"]
  node_workflows["Workflow specs<br/>workflow catalog"]
end

subgraph group_adapters["Adapters"]
  node_integration_base["Integrations<br/>adapter framework"]
  node_integration_catalog["Integration catalog<br/>registry<br/>[catalog.py]"]
  node_agent_impls["Agent adapters"]
  node_auth["Auth<br/>service access"]
  node_github_http["HTTP client<br/>network boundary<br/>[_github_http.py]"]
end

subgraph group_ops["Docs and ops"]
  node_docs_site["Docs site<br/>documentation"]
  node_ci["CI/CD<br/>automation<br/>[workflows]"]
  node_scripts["Scripts"]
  node_tests["Tests<br/>verification suite"]
end

node_commands -->|"uses"| node_core
node_commands -->|"loads"| node_assets
node_commands -->|"consults"| node_catalogs
node_commands -->|"invokes"| node_workflow_engine
node_commands -->|"orchestrates"| node_integration_base
node_assets -->|"serves"| node_init_tpl
node_catalogs -->|"indexes"| node_presets
node_catalogs -->|"indexes"| node_extensions
node_catalogs -->|"indexes"| node_integration_catalog
node_catalogs -->|"indexes"| node_workflows
node_presets -->|"extends"| node_init_tpl
node_extensions -->|"adds"| node_init_tpl
node_workflows -->|"defines"| node_workflow_steps
node_workflow_engine -->|"executes"| node_workflow_steps
node_integration_base -->|"specializes"| node_agent_impls
node_integration_base -->|"registered by"| node_integration_catalog
node_auth -->|"uses"| node_github_http
node_ci -->|"publishes"| node_docs_site
node_ci -->|"runs"| node_tests
node_scripts -->|"bootstraps"| node_commands
node_tests -->|"covers"| node_commands
node_tests -->|"covers"| node_integration_base
node_tests -->|"covers"| node_workflow_engine
node_tests -->|"covers"| node_auth

click node_commands "https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/commands"
click node_core "https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli"
click node_assets "https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/_assets.py"
click node_init_tpl "https://github.com/ixi-enki/spec-kit/tree/main/templates"
click node_presets "https://github.com/ixi-enki/spec-kit/tree/main/presets"
click node_extensions "https://github.com/ixi-enki/spec-kit/tree/main/extensions"
click node_workflows "https://github.com/ixi-enki/spec-kit/tree/main/workflows"
click node_workflow_engine "https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/workflows/engine.py"
click node_workflow_steps "https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/workflows/steps"
click node_catalogs "https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/catalogs.py"
click node_integration_base "https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/integrations"
click node_integration_catalog "https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/integrations/catalog.py"
click node_agent_impls "https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/integrations/claude"
click node_auth "https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/authentication"
click node_github_http "https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/_github_http.py"
click node_docs_site "https://github.com/ixi-enki/spec-kit/tree/main/docs"
click node_ci "https://github.com/ixi-enki/spec-kit/blob/main/.github/workflows"
click node_scripts "https://github.com/ixi-enki/spec-kit/tree/main/scripts"
click node_tests "https://github.com/ixi-enki/spec-kit/tree/main/tests"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_commands,node_core,node_workflow_engine,node_workflow_steps,node_catalogs toneBlue
class node_assets,node_init_tpl,node_presets,node_extensions,node_workflows toneAmber
class node_integration_base,node_integration_catalog,node_agent_impls,node_auth,node_github_http toneMint
class node_docs_site,node_ci,node_scripts,node_tests toneRose
```

## Components

### CLI runtime

Python package that parses commands and orchestrates repo operations.

- [Commands](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/commands): cli entrypoints · Top-level command handlers for init, integration, extension, preset, and workflow. · `src/specify_cli/commands`
- [Core package](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli): cli runtime · Shared CLI runtime, utilities, versioning, and app-facing helpers. · `src/specify_cli`
- [Engine](https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/workflows/engine.py): workflow runtime · Executes step graphs, branching, loops, and expression-driven orchestration. · `src/specify_cli/workflows/engine.py`
- [Steps](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/workflows/steps): workflow primitives · Step implementations such as command, prompt, shell, gates, branches, and fan-in/out. · `src/specify_cli/workflows/steps`
- [Catalogs](https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/catalogs.py): registry model · Discovers supported presets, extensions, integrations, and workflows from catalogs. · `src/specify_cli/catalogs.py`

### Artifact content

Materialized specs, templates, presets, extensions, and workflows.

- [Asset layer](https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/_assets.py): resource loading · Resolves packaged templates and other bundled artifacts at runtime. · `src/specify_cli/_assets.py`
- [Templates](https://github.com/ixi-enki/spec-kit/tree/main/templates): spec artifacts · Core spec-driven command and document templates used to bootstrap projects. · `templates`
- [Presets](https://github.com/ixi-enki/spec-kit/tree/main/presets): artifact catalog · Reusable project setups that add commands, templates, and workflow conventions. · `presets`
- [Extensions](https://github.com/ixi-enki/spec-kit/tree/main/extensions): artifact catalog · Installable feature packs that add commands, scripts, and config templates. · `extensions`
- [Workflow specs](https://github.com/ixi-enki/spec-kit/tree/main/workflows): workflow catalog · Reusable workflow definitions and orchestration artifacts for agent-driven tasks. · `workflows`

### Adapters

Agent integrations and external-service boundaries.

- [Integrations](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/integrations): adapter framework · Base integration layer that maps the generic Spec Kit model onto agent-specific layouts. · `src/specify_cli/integrations`
- [Integration catalog](https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/integrations/catalog.py): registry · Catalog and manifest logic for supported agent integrations. · `src/specify_cli/integrations/catalog.py`
- [Agent adapters](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/integrations/claude): agent adapters · Concrete adapters for Copilot, Claude, Gemini, Cursor, Codex, Windsurf, and others. · `src/specify_cli/integrations/claude`
- [Auth](https://github.com/ixi-enki/spec-kit/tree/main/src/specify_cli/authentication): service access · Authentication flows for GitHub and Azure DevOps. · `src/specify_cli/authentication`
- [HTTP client](https://github.com/ixi-enki/spec-kit/blob/main/src/specify_cli/_github_http.py): network boundary · Remote HTTP access used by auth and service-backed CLI operations. · `src/specify_cli/_github_http.py`

### Docs and ops

Documentation, automation, and contributor tooling.

- [Docs site](https://github.com/ixi-enki/spec-kit/tree/main/docs): documentation · DocFX-based documentation and reference site. · `docs`
- [CI/CD](https://github.com/ixi-enki/spec-kit/blob/main/.github/workflows): automation · GitHub workflows for linting, testing, docs, release, and community automation. · `.github/workflows`
- [Scripts](https://github.com/ixi-enki/spec-kit/tree/main/scripts): bootstrap scripts · Cross-platform shell and PowerShell bootstrap/setup helpers. · `scripts`
- [Tests](https://github.com/ixi-enki/spec-kit/tree/main/tests): verification suite · Contract tests covering CLI, auth, integrations, presets, extensions, workflows, and hardening. · `tests`

## Connections

- Commands → Core package: uses · Command handlers rely on shared CLI runtime and helpers.
- Commands → Asset layer: loads · Commands materialize packaged artifacts into target projects.
- Commands → Catalogs: consults · Commands look up supported items through registries.
- Commands → Engine: invokes · Workflow commands hand execution to the workflow runtime.
- Commands → Integrations: orchestrates · Integration-related commands route into adapter implementations.
- Asset layer → Templates: serves · Asset loader exposes core templates and command content.
- Catalogs → Presets: indexes · Registry data drives preset discovery and installation.
- Catalogs → Extensions: indexes · Registry data drives extension discovery and installation.
- Catalogs → Integration catalog: indexes · Registry data includes supported integrations and manifests.
- Catalogs → Workflow specs: indexes · Registry data also covers workflow packages.
- Presets → Templates: extends · Presets reuse and layer on top of core templates.
- Extensions → Templates: adds · Extensions contribute extra commands and templates.
- Workflow specs → Steps: defines · Workflow packages are built from reusable step primitives.
- Engine → Steps: executes · Engine interprets and runs the step implementations.
- Integrations → Agent adapters: specializes · Base adapter layer is concretized by agent-specific packages.
- Integrations → Integration catalog: registered by · Integration catalog exposes the available adapter set.
- Auth → HTTP client: uses · Authentication and service access flow through HTTP client code.
- CI/CD → Docs site: publishes · Documentation is built and published via GitHub workflows.
- CI/CD → Tests: runs · CI validates the repository through the test suite.
- Scripts → Commands: bootstraps · Setup scripts support initialization and maintenance flows.
- Tests → Commands: covers · CLI behavior is exercised by dedicated tests.
- Tests → Integrations: covers · Integration adapters have contract and matrix coverage.
- Tests → Engine: covers · Workflow orchestration behavior is tested directly.
- Tests → Auth: covers · Authentication flows and remote access are verified.
