# https://github.com/Fission-AI/OpenSpec 项目说明书

生成时间：2026-05-18 02:52:58 UTC

## 目录

- [Introduction to OpenSpec](#introduction)
- [Getting Started](#getting-started)
- [System Architecture](#architecture)
- [Slash Commands](#slash-commands)
- [Workflows](#workflows)
- [Artifact Graph System](#artifact-graph)
- [Schemas](#schemas)
- [Configuration](#configuration)
- [Validation System](#validation-system)
- [Supported AI Tools](#supported-tools)

<a id='introduction'></a>

## Introduction to OpenSpec

### 相关页面

相关主题：[Getting Started](#getting-started), [System Architecture](#architecture)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)
- [CHANGELOG.md](https://github.com/Fission-AI/OpenSpec/blob/main/CHANGELOG.md)
- [docs/getting-started.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/getting-started.md)
- [docs/concepts.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/concepts.md)
- [docs/workflows.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/workflows.md)
- [docs/commands.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/commands.md)
- [docs/supported-tools.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/supported-tools.md)
</details>

# Introduction to OpenSpec

OpenSpec is a lightweight specification framework designed to bring structure and alignment to AI-assisted software development. It establishes a shared understanding between human developers and AI coding assistants before any code is written, reducing unpredictability and improving project organization.

## Purpose and Scope

AI coding assistants are powerful but often unpredictable when project requirements exist only in chat history. OpenSpec adds a lightweight spec layer that ensures human and AI align on specifications before code gets written.

The framework operates under a core philosophy:

```text
→ fluid not rigid
→ iterative not waterfall
→ easy not complex
→ built for brownfield not just greenfield
→ scalable from personal projects to enterprises
```

**资料来源：** [README.md:1-20]()

## Core Features

OpenSpec provides several key capabilities:

| Feature | Description |
|---------|-------------|
| **Agree Before Build** | Human and AI align on specs before code gets written |
| **Stay Organized** | Each change gets its own folder with proposal, specs, design, and tasks |
| **Work Fluidly** | Update any artifact anytime, no rigid phase gates |
| **Tool Integration** | Works with 25+ AI assistants via slash commands |

**资料来源：** [README.md:21-30]()

## Architecture Overview

OpenSpec uses an artifact-guided workflow where changes are organized into structured folders. The system tracks dependencies between artifacts and automatically manages state transitions.

```mermaid
graph TD
    A[User Request] --> B[Proposal]
    B --> C[Specs]
    C --> D[Design]
    D --> E[Tasks]
    E --> F[Implementation]
    F --> G[Archive]
    G --> C
    
    H[Config.yaml] --> A
    H --> B
    H --> C
    
    style A fill:#e1f5fe
    style G fill:#c8e6c9
```

**资料来源：** [CHANGELOG.md:1-30]()

## The Change Structure

Every change in OpenSpec follows a consistent folder structure:

```
openspec/
├── specs/                    # Source-of-truth specifications
│   └── <capability>/
│       └── spec.md
├── changes/
│   ├── <change-name>/        # Active change folder
│   │   ├── proposal.md       # Why and what changes
│   │   ├── tasks.md          # Implementation checklist
│   │   ├── design.md         # Technical decisions (optional)
│   │   └── specs/
│   │       └── <capability>/
│   │           └── spec.md   # Delta showing additions/modifications
│   └── archive/              # Completed changes
│       └── YYYY-MM-DD-<change-name>/
└── config.yaml               # Project configuration
```

**资料来源：** [README.md:200-230]()

## Workflow System

OpenSpec supports multiple workflow approaches:

### Standard Workflow

The traditional linear approach:

1. **Propose** - Create a change proposal that captures spec updates
2. **Review** - Review the proposal with AI assistant until agreement
3. **Implement** - Implement tasks that reference agreed specs
4. **Archive** - Archive the change to merge approved updates back into source specs

### Experimental Workflow

The new artifact-guided workflow using slash commands:

| Command | Purpose |
|---------|---------|
| `/opsx:propose` | Start a new change |
| `/opsx:new` | Start a new change (alternative) |
| `/opsx:continue` | Create one artifact at a time (step-through) |
| `/opsx:ff` | Fast-forward to completion |
| `/opsx:verify` | Verify artifact integrity |
| `/opsx:bulk-archive` | Archive multiple changes |
| `/opsx:onboard` | Initialize OpenSpec in a project |

**资料来源：** [README.md:150-170]()

## Instruction System

OpenSpec dynamically assembles instructions from three layers:

```mermaid
graph LR
    A[Context] --> D[Enriched Instruction]
    B[Rules] --> D
    C[Template] --> D
    
    A1[project.yaml] --> A
    B1[Artifact-specific] --> B
    C1[Schema template] --> C
```

### Context Layer
Project background from `config.yaml` including tech stack and conventions. Applied to **all artifacts**.

### Rules Layer
Artifact-specific constraints (e.g., "propose spike tasks for unknowns"). Applied only to **matching artifacts**.

### Template Layer
The actual structure for the output file, sourced from schemas.

**资料来源：** [CHANGELOG.md:40-70]()

## Supported AI Tools

OpenSpec integrates with 25+ AI coding assistants through slash commands or natural language:

### Native Slash Commands

| Tool | Commands | Configuration Path |
|------|----------|-------------------|
| **Claude Code** | `/opsx:propose`, `/opsx:apply`, `/opsx:archive` | Built-in |
| **Amazon Q Developer** | `@openspec-proposal`, `@openspec-apply`, `@openspec-archive` | `.amazonq/prompts/` |
| **CodeBuddy Code** | `/opsx:propose`, `/opsx:apply`, `/opsx:archive` | `.codebuddy/commands/` |
| **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.cursor/commands/` |
| **Roo Code** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.roo/commands/` |

### Workflow-Based Tools

| Tool | Workflow Location |
|------|-------------------|
| **Cline** | `.clinerules/workflows/` |
| **Windsurf** | `.windsurf/workflows/` |
| **Kilo Code** | `.kilocode/workflows/` |

**资料来源：** [README.md:80-120]()

## Installation and Setup

### Prerequisites

- **Node.js >= 20.19.0** - Check with `node --version`

### Installation Methods

**Option A: npm (Global)**

```bash
npm install -g @fission-ai/openspec@latest
```

**Option B: nix (NixOS)**

```bash
nix run github:Fission-AI/OpenSpec -- init
```

Or install to profile:

```bash
nix profile install github:Fission-AI/OpenSpec
```

**资料来源：** [README.md:50-80]()

### Quick Start

```bash
# Navigate to project
cd your-project

# Initialize OpenSpec
openspec init

# Start a new change
/opsx:propose <what-you-want-to-build>

# Or use CLI directly
openspec new <change-name>
```

**资料来源：** [README.md:40-55]()

## Command Reference

| Command | Description |
|---------|-------------|
| `openspec list` | View active change folders |
| `openspec view` | Interactive dashboard of specs and changes |
| `openspec show <change>` | Display change details |
| `openspec validate <change>` | Check spec formatting and structure |
| `openspec archive <change> [--yes]` | Archive completed change |
| `openspec config profile` | Select workflow profile |

**资料来源：** [README.md:180-200]()

## Telemetry

OpenSpec collects anonymous usage statistics to understand usage patterns:

- **Collected:** Command names and version only
- **NOT collected:** Arguments, paths, content, or PII
- **Auto-disabled:** In CI environments

**Opt-out:**

```bash
export OPENSPEC_TELEMETRY=0
# or
export DO_NOT_TRACK=1
```

**资料来源：** [README.md:220-240]()

## Contributing to OpenSpec

```bash
# Install dependencies
pnpm install

# Build
pnpm run build

# Test
pnpm test

# Develop CLI locally
pnpm run dev
pnpm run dev:cli
```

**Commit convention:**

```text
type(scope): subject
```

**资料来源：** [README.md:250-260]()

## License

OpenSpec is released under the **MIT License**.

---

<a id='getting-started'></a>

## Getting Started

### 相关页面

相关主题：[Introduction to OpenSpec](#introduction), [Slash Commands](#slash-commands)

<details>
<summary>Relevant Source Files</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)
- [docs/getting-started.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/getting-started.md)
- [docs/workflows.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/workflows.md)
- [docs/cli.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/cli.md)
- [docs/commands.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/commands.md)
- [docs/installation.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/installation.md)
- [openspec/changes/archive/2025-12-28-add-instruction-loader/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-12-28-add-instruction-loader/design.md)
</details>

# Getting Started

## Overview

OpenSpec is a lightweight specification framework designed to help development teams align on requirements before writing code. It provides a structured approach to capturing proposals, specifications, designs, and implementation tasks in organized change folders that integrate seamlessly with AI coding assistants.

The "Getting Started" documentation serves as the entry point for new users, covering prerequisites, installation methods, project initialization, and the fundamental workflows that define how OpenSpec operates. This guide ensures users can quickly set up OpenSpec in their development environment and begin using its artifact-guided workflow for managing changes systematically.

## Prerequisites

### System Requirements

OpenSpec has specific version requirements that must be met before installation:

| Requirement | Minimum Version | Notes |
|------------|-----------------|-------|
| Node.js | 20.19.0 or higher | Check with `node --version` |
| Package Managers | npm, pnpm, yarn, bun, or nix | Alternative installation options available |

资料来源：[README.md:1]()

To verify your Node.js installation, run:

```bash
node --version
```

If the version is below 20.19.0, you must upgrade Node.js before proceeding with OpenSpec installation.

## Installation

OpenSpec can be installed through multiple methods depending on your development environment and preferences.

### Method 1: npm (Global Installation)

The standard installation method uses npm to install OpenSpec globally:

```bash
npm install -g @fission-ai/openspec@latest
```

After installation, verify the installation by checking the version:

```bash
openspec --version
```

资料来源：[README.md:1]()

### Method 2: Nix Package Manager

For NixOS or Nix package manager users, OpenSpec can be run directly without explicit installation:

```bash
nix run github:Fission-AI/OpenSpec -- init
```

Alternatively, install to your user profile:

```bash
nix profile install github:Fission-AI/OpenSpec
```

Or add to your Nix configuration for persistent access.

### Method 3: Development Installation

For contributors or those who want to work with the source code:

```bash
# Clone the repository
git clone https://github.com/Fission-AI/OpenSpec.git
cd OpenSpec

# Install dependencies
pnpm install

# Build the project
pnpm run build

# Run tests
pnpm test

# Develop CLI locally
pnpm run dev
```

资料来源：[README.md:1]()

## Project Initialization

Once OpenSpec is installed, navigate to your project directory and initialize the OpenSpec structure:

```bash
cd your-project
openspec init
```

The initialization process creates the necessary directory structure for OpenSpec artifacts:

```text
openspec/
├── config.yaml          # Project configuration and context
├── specs/               # Schema definitions and templates
└── changes/             # Individual change proposals
```

### What `openspec init` Creates

| Artifact | Purpose |
|----------|---------|
| `config.yaml` | Project context, tech stack, conventions |
| `openspec/schemas/` | Schema definitions (spec-driven, etc.) |
| `openspec/changes/` | Directory for change proposals |

### Legacy Cleanup

When running `openspec init` in an existing project that previously used OpenSpec, the initialization process detects and handles legacy artifacts:

- Old slash command directories (`.claude/commands/openspec/`)
- Config files with OpenSpec markers (`CLAUDE.md`, `.cursorrules`, `.windsurfrules`)
- Legacy `openspec/AGENTS.md` files

Users are prompted for confirmation before removing these legacy artifacts.

资料来源：[README.md:1]()
资料来源：[openspec/changes/archive/2026-02-17-merge-init-experimental/design.md:1]()

## Core Workflow: Artifact-Guided Approach

OpenSpec uses an experimental artifact-guided workflow centered on creating structured changes. The workflow revolves around four key artifacts that capture different aspects of a change:

```mermaid
graph TD
    A[Propose Change] --> B[Create Proposal]
    B --> C[Write Specs]
    C --> D[Design Solution]
    D --> E[Define Tasks]
    E --> F[Implement]
    F --> G[Verify]
    G --> H[Archive]
    
    I[Iterate on Any Artifact] -.-> A
    I -.-> B
    I -.-> C
    I -.-> D
    I -.-> E
```

### The Four Core Artifacts

| Artifact | Purpose | Generated By |
|----------|---------|--------------|
| **Proposal** | Why the change is needed, what's changing | `/opsx:propose` |
| **Specs** | Requirements and acceptance scenarios | Sequential creation |
| **Design** | Technical approach and architecture | Sequential creation |
| **Tasks** | Implementation checklist | Sequential creation |

Each change folder under `openspec/changes/<change-name>/` contains these artifacts organized in a predictable structure.

资料来源：[README.md:1]()

## Supported AI Coding Assistants

OpenSpec integrates with over 25 AI coding assistants through slash commands. The supported tools include:

| Tool Category | Examples |
|--------------|----------|
| Claude Code | `/openspec/proposal`, `/openspec/apply`, `/openspec/archive` |
| Cursor | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
| CodeBuddy | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
| Codex | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
| RooCode | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
| Kilo Code | `.kilocode/workflows/` with `/openspec-proposal.md` |
| Windsurf | `.windsurf/workflows/` with `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` |
| Continue | `.continue/` with custom configuration |
| Cline | `CLAUDE.md` compatible |
| Other | Works with natural language requests |

To check if your tool is supported, view the [full list of supported tools](docs/supported-tools.md).

资料来源：[README.md:1]()
资料来源 [docs/supported-tools.md]()

## Essential Commands

### Quick Command Reference

| Command | Description |
|---------|-------------|
| `openspec list` | View active change folders |
| `openspec view` | Interactive dashboard of specs and changes |
| `openspec show <change>` | Display change details |
| `openspec update` | Refresh slash command files |
| `openspec config profile` | Switch between standard and experimental workflows |
| `openspec archive <change>` | Archive a completed change |

资料来源：[README.md:1]()
资料来源 [docs/cli.md]()

## The Experimental Workflow

OpenSpec offers an experimental artifact-guided workflow that provides a more flexible, iterative approach to managing changes.

### Enabling Experimental Features

```bash
openspec experimental
```

### Experimental Slash Commands

| Command | Purpose |
|---------|---------|
| `/opsx:propose` | Start a new change |
| `/opsx:new` | Create a new change folder |
| `/opsx:continue` | Create the next artifact in sequence |
| `/opsx:ff` | Fast-forward through completed tasks |
| `/opsx:verify` | Verify implementation against specs |
| `/opsx:bulk-archive` | Archive multiple completed changes |
| `/opsx:onboard` | Set up OpenSpec in a new project |
| `/opsx:explore` | Think through ideas before committing |

资料来源 [docs/opsx.md]()

### Workflow Comparison

| Aspect | Standard Workflow | Experimental Workflow |
|--------|------------------|----------------------|
| Artifact creation | Manual/guided | Sequential with dependencies |
| State tracking | File-based | Dynamic artifact graph |
| Flexibility | Phase-locked | Action-based |
| Iteration | Limited | Full iteration support |

## Telemetry

OpenSpec collects anonymous usage statistics to understand usage patterns. Only command names and version numbers are collected—no arguments, paths, content, or personally identifiable information.

**To opt out:**

```bash
export OPENSPEC_TELEMETRY=0
```

Or set the `DO_NOT_TRACK` environment variable:

```bash
export DO_NOT_TRACK=1
```

Telemetry is automatically disabled in CI environments.

资料来源：[README.md:1]()

## Next Steps

After completing the initial setup:

1. **Review Documentation**
   - [Workflows](docs/workflows.md) - Combos and patterns
   - [Commands](docs/commands.md) - Slash commands & skills
   - [Concepts](docs/concepts.md) - How OpenSpec fits together

2. **Try the Workflow**
   - Create your first proposal using `/opsx:propose`
   - Work through the artifact sequence
   - Archive and review the result

3. **Configure Your Tool**
   - Set up slash commands for your preferred AI assistant
   - Run `openspec update` to refresh command files

4. **Explore Advanced Features**
   - Multi-language support: [docs/multi-language.md](docs/multi-language.md)
   - Customization options: [docs/customization.md](docs/customization.md)
   - Community schemas: Browse the catalog in customization docs

## Troubleshooting

### Common Issues

| Issue | Solution |
|-------|----------|
| Node.js version too low | Upgrade to 20.19.0 or higher |
| Command not found | Verify installation with `openspec --version` |
| Legacy artifacts remain | Run `openspec init` with `--force` flag |
| Tool not responding | Check supported tools list and use natural language |

### Getting Help

- Join the [OpenSpec Discord](https://discord.gg/YctCnvvshC) for questions
- Follow [@0xTab on X](https://x.com/0xTab) for updates
- Review archived changes in `openspec/changes/archive/` for examples

---

<a id='architecture'></a>

## System Architecture

### 相关页面

相关主题：[Introduction to OpenSpec](#introduction), [Artifact Graph System](#artifact-graph), [Workflows](#workflows)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [openspec/changes/archive/2026-02-17-project-config/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/design.md)
- [openspec/changes/archive/2025-12-28-add-instruction-loader/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-12-28-add-instruction-loader/design.md)
- [openspec/changes/archive/2026-02-17-project-local-schemas/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-local-schemas/design.md)
- [schemas/spec-driven/schema.yaml](https://github.com/Fission-AI/OpenSpec/blob/main/schemas/spec-driven/schema.yaml)
- [openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)
- [openspec/changes/archive/2025-08-06-add-init-command/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-08-06-add-init-command/design.md)
</details>

# System Architecture

OpenSpec is a lightweight specification framework designed to add a spec layer between human-AI alignment and code implementation. The system architecture enables teams to agree on what to build before any code is written, maintaining organization through structured change folders and dynamic instruction generation.

## Architecture Overview

OpenSpec follows a modular architecture with clear separation between CLI interface, core business logic, and artifact management. The framework is designed to be tool-agnostic, supporting 25+ AI assistants through slash commands and natural language processing.

```mermaid
graph TD
    subgraph "CLI Layer"
        CLI[CLI Entry Point]
        Commands[Slash Commands]
    end
    
    subgraph "Core Layer"
        Config[Project Config]
        Schemas[Schema System]
        Artifacts[Artifact Graph]
        Instructions[Instruction Loader]
    end
    
    subgraph "Change Management"
        Changes[Change Folders]
        Proposals[Proposals]
        Specs[Specs]
        Designs[Designs]
        Tasks[Tasks]
    end
    
    CLI --> Commands
    Commands --> Artifacts
    Artifacts --> Instructions
    Instructions --> Config
    Instructions --> Schemas
    Artifacts --> Changes
    Changes --> Proposals
    Changes --> Specs
    Changes --> Designs
    Changes --> Tasks
```

## Core Components

### CLI Interface

The CLI serves as the entry point for all OpenSpec operations. It handles initialization, change management, and command execution across supported tools.

| Command | Purpose |
|---------|---------|
| `openspec init` | Initialize OpenSpec in a project directory |
| `openspec update` | Refresh generated instruction files |
| `openspec list` | View active change folders |
| `openspec show <change>` | Display change details |
| `openspec archive <change>` | Archive completed changes |

资料来源：[openspec/changes/archive/2025-08-06-add-init-command/design.md:1-50]()

### Schema System

Schemas define the workflow structure and artifact templates for OpenSpec changes. The system supports three schema sources:

| Source | Path | Priority |
|--------|------|----------|
| Project | `openspec/schemas/<name>/` | Highest |
| User | `~/.local/share/openspec/schemas/<name>/` | Middle |
| Package | Built-in `@fission-ai/openspec` | Lowest |

资料来源：[openspec/changes/archive/2026-02-17-project-local-schemas/design.md:1-30]()

**Schema Resolution Order:**
1. CLI `--schema` flag (explicit override)
2. `.openspec.yaml` in change directory (change-specific binding)
3. `openspec/config.yaml` schema field (project default)
4. `"spec-driven"` (hardcoded fallback)

The default `spec-driven` schema includes artifacts: proposal, specs, design, and tasks.

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md:1-50]()

## Artifact Graph System

The artifact graph tracks dependencies between different artifacts and manages their creation state. This system replaces the old phase-locked workflow with a flexible action-based model.

### Artifact Types

| Artifact | Generates | Dependencies |
|----------|-----------|--------------|
| proposal | proposal.md | None |
| specs | specs/*.md | proposal |
| design | design.md | proposal |
| tasks | tasks.md | specs, design |

### Instruction Loading

Instructions are dynamically assembled from three layers:

```mermaid
graph LR
    A[Context] --> D[Enriched Instruction]
    B[Rules] --> D
    C[Template] --> D
    
    subgraph "Instruction Components"
        A
        B
        C
    end
```

资料来源：[openspec/changes/archive/2025-12-28-add-instruction-loader/design.md:1-30]()

**Instruction Structure:**

```xml
<context>
[Project context from config.yaml]
</context>

<rules>
- Rule 1 for specific artifact
- Rule 2 for specific artifact
</rules>

<template>
[Schema's specs template]
</template>
```

Rules only appear for the **specific artifact** they're configured for. Artifacts without rules (e.g., design, tasks) don't get a `<rules>` section.

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md:50-100]()

## Project Configuration

Project configuration is stored in `openspec/config.yaml` and provides shared context and rules across the entire project.

### Configuration Structure

```yaml
context: |
  Tech stack: TypeScript, React
  Key conventions: ...

schema: spec-driven

rules:
  proposal:
    - Include rollback plan
  specs:
    - Use Given/When/Then format for scenarios
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md:100-150]()

### Design Decisions

1. **Config file location**: `openspec/config.yaml` in project root
   - Mirrors structure used by other tools (e.g., `.github/`)
   - Keeps OpenSpec-related files under one directory

2. **XML tags vs Markdown sections**: Use XML-style tags `<context>` and `<rules>`
   - Clear delimiters that don't conflict with Markdown
   - Agents can easily parse structure

3. **Rules validation**: Warn on unknown artifact IDs, don't error
   - Future-proof for new artifact types
   - Non-breaking change for existing configs

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md:150-200]()

## Command Workflow

### Modern Workflow (opsx)

The new artifact-guided workflow provides flexible action-based interactions:

| Command | What it does |
|---------|--------------|
| `/opsx:propose` | Start a new change with proposal |
| `/opsx:continue` | Create one artifact at a time |
| `/opsx:ff` | Fast-forward to next ready artifact |
| `/opsx:verify` | Verify specs and update tasks |
| `/opsx:bulk-archive` | Archive multiple changes |
| `/opsx:onboard` | Initialize project for OpenSpec |

资料来源：[README.md:1-50]()

### Legacy Commands

The legacy slash commands have been removed:

- `/openspec:proposal` - **Removed**
- `/openspec:apply` - **Removed**
- `/openspec:archive` - **Removed**

Tool-specific instruction files (`CLAUDE.md`, `.cursorrules`, `AGENTS.md`, `project.md`) are no longer generated.

资料来源：[CHANGELOG.md:1-30]()

## Change Lifecycle

```mermaid
graph TD
    A[Create Change] --> B[Write Proposal]
    B --> C[Create Specs]
    C --> D[Write Design]
    D --> E[Implement Tasks]
    E --> F[Archive Change]
    
    G[Explore Ideas] -.-> A
    
    style A fill:#e1f5fe
    style F fill:#fff3e0
```

### Change Directory Structure

```
openspec/
├── config.yaml           # Project configuration
├── schemas/              # Project-local schemas
│   └── <schema-name>/
│       └── templates/
└── changes/
    ├── <change-name>/
    │   ├── proposal.md
    │   ├── specs/
    │   │   └── *.md
    │   ├── design.md
    │   ├── tasks.md
    │   └── .openspec.yaml
    └── archive/
        └── <date>-<change-name>/
```

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:1-30]()

## Data Flow Architecture

### Instruction Generation Flow

```mermaid
sequenceDiagram
    participant User
    participant CLI
    participant Config
    participant Schema
    participant Loader
    participant Output
    
    User->>CLI: openspec instructions <artifact>
    CLI->>Config: readProjectConfig()
    Config-->>CLI: context + rules
    CLI->>Schema: resolveSchemaForChange()
    Schema-->>CLI: schema name
    CLI->>Loader: loadInstructions(change, artifact)
    Loader->>Schema: getTemplate(artifact)
    Schema-->>Loader: baseInstructions
    Loader->>Config: getRulesForArtifact(artifact)
    Config-->>Loader: artifactRules
    Loader->>Output: enrichInstruction(context, rules, template)
    Output-->>User: Enriched instruction with XML sections
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md:200-250]()

### Schema Loading Priority

When loading schemas, the system checks multiple locations in order:

```mermaid
graph TD
    A[Schema Request] --> B{Project schemas dir?}
    B -->|Yes| C[Return project-local schema]
    B -->|No| D{User schemas dir?}
    D -->|Yes| E[Return user schema]
    D -->|No| F[Return package schema]
    
    C --> G[Schema found]
    E --> G
    F --> G
```

资料来源：[openspec/changes/archive/2026-02-17-project-local-schemas/design.md:50-80]()

## Extensibility Points

### Slash Command Configuration

Slash commands are managed through a `SlashCommandConfigurator` that handles multiple files per tool:

- `getTargets()`: Expose targets with path and kind
- `generateAll(projectPath, openspecDir)`: For init
- `updateExisting(projectPath, openspecDir)`: For update

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:50-80]()

### Template System

Templates are brief, actionable, and sourced from `openspec/README.md`. Each command body includes:

- Guardrails: Ask 1-2 clarifying questions if needed
- Step list tailored to workflow stage
- Pointers to troubleshooting tips

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:30-50]()

## Security Considerations

The implementation includes several security measures:

| Concern | Mitigation |
|---------|------------|
| Path Traversal | Sanitize all user-provided paths |
| File Permissions | Check write permissions before operations |
| Existing Files | Never overwrite without explicit `--force` flag |
| Template Injection | Sanitize user inputs in templates |

资料来源：[openspec/changes/archive/2025-08-06-add-init-command/design.md:50-70]()

## Performance and Caching

Project config is read multiple times during a single command execution:

1. **Schema resolution** - To know which schema to use
2. **Instruction loading** - To inject context and rules

Rules are validated lazily during instruction loading (not at config load time) because:
- Schema isn't known at config load time (circular dependency)
- Warnings shown when user actually uses the feature (better UX)
- Validation warnings cached per session to avoid spam

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md:250-280]()

## Technology Stack

| Component | Technology |
|-----------|------------|
| Runtime | Node.js 20.19.0+ |
| Package Manager | npm, pnpm, yarn, bun, nix |
| License | MIT |
| Package | `@fission-ai/openspec` |

资料来源：[README.md:50-80]()

---

<a id='slash-commands'></a>

## Slash Commands

### 相关页面

相关主题：[Workflows](#workflows), [Getting Started](#getting-started), [Supported AI Tools](#supported-tools)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [docs/commands.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/commands.md)
- [docs/opsx.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/opsx.md)
- [README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)
- [openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)
- [openspec/changes/archive/2025-09-29-add-slash-command-support/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/design.md)
- [openspec/changes/archive/2025-10-14-add-codex-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-10-14-add-codex-slash-command-support/proposal.md)
</details>

# Slash Commands

Slash Commands provide a convenient shorthand mechanism for invoking OpenSpec workflows directly from AI coding assistants. Instead of typing verbose natural language instructions, users can trigger specific OpenSpec actions through a single slash command invocation, streamlining the specification-driven development workflow.

## Overview

OpenSpec integrates with over 20 AI coding assistants through native slash command support. These commands serve as shortcuts that invoke predefined workflow templates, allowing AI assistants to execute OpenSpec operations without requiring manual CLI invocation.

The slash command system is built on two fundamental principles:

1. **Centralized Templates**: Command bodies are defined once and reused across all supported tools, ensuring consistency while allowing minimal per-tool adaptations.
2. **Per-Tool Organization**: Each AI assistant receives its commands in the format and location that tool natively recognizes.

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:1-20]()

## Supported Tools and Command Formats

Different AI coding assistants use varying conventions for slash command naming and organization. The following table summarizes the supported tools and their respective command formats.

| Tool | Commands | Storage Location |
|------|----------|------------------|
| **Claude Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | `.claude/commands/openspec/` |
| **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.cursor/commands/` |
| **Amazon Q Developer** | `@openspec-proposal`, `@openspec-apply`, `@openspec-archive` | `.amazonq/prompts/` |
| **CodeBuddy Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | `.codebuddy/commands/` |
| **Antigravity** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.agent/workflows/` |
| **Auggie** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.augment/commands/` |
| **Roo Code** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.roo/commands/` |
| **Windsurf** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.windsurf/workflows/` |
| **Cline** | Workflows with `openspec-*` prefix | `.clinerules/workflows/` |

资料来源：[README.md:1-80]()

## Core Commands

OpenSpec defines three primary slash commands that cover the essential workflow stages.

### Proposal Command

The proposal command initiates a new change specification. When invoked, the AI assistant creates a dedicated change folder with the necessary artifact structure.

```
You: /openspec:propose add-dark-mode
AI:  Created openspec/changes/add-dark-mode/
     ✓ proposal.md — why we're doing this, what's changing
     ✓ specs/       — requirements and scenarios
     ✓ design.md    — technical approach
     ✓ tasks.md     — implementation checklist
     Ready for implementation!
```

资料来源：[README.md:1-30]()

### Apply Command

The apply command transitions the workflow from specification to implementation. It reads the tasks from the change folder and executes them in sequence, marking each task as complete.

```
You: /opsx:apply
AI:  Implementing tasks...
     ✓ 1.1 Add theme context provider
     ✓ 1.2 Create toggle component
     ✓ 2.1 Add CSS variables
     ✓ 2.2 Wire up localStorage
     All tasks complete!
```

资料来源：[README.md:1-30]()

### Archive Command

The archive command finalizes a completed change by moving it to the archive directory and updating the source-of-truth specifications.

```
You: /openspec:archive
AI:  Archived to openspec/changes/archive/2025-01-23-add-dark-mode/
     Specs updated. Ready for the next feature.
```

资料来源：[README.md:1-30]()

## Command File Structure

### File Format and Metadata

Slash command files are stored as Markdown with optional YAML frontmatter for tool-specific metadata. The frontmatter, when supported, includes fields such as `name`, `description`, and `category` or `tags`.

```yaml
---
name: openspec-proposal
description: Create a new OpenSpec change proposal
category: OpenSpec
---
<!-- OPENSPEC:START -->
...command body content...
<!-- OPENSPEC:END -->
```

### Marker Placement Rules

The OpenSpec system uses marker comments (`<!-- OPENSPEC:START -->` and `<!-- OPENSPEC:END -->`) to delineate command bodies. These markers must adhere to strict placement rules:

| Rule | Description |
|------|-------------|
| **Outside Frontmatter** | Markers must never appear inside YAML frontmatter |
| **Body Delimitation** | Markers wrap only the visible command body content |
| **Recovery Behavior** | Missing or duplicated markers trigger specific recovery behaviors |

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:30-45]()

### Naming Consistency

To ensure predictable behavior across tools, the following naming elements must remain aligned:

| Element | Example |
|---------|---------|
| Visible Slash Name | `proposal`, `apply`, `archive` |
| File Name | `proposal.md`, `apply.md`, `archive.md` |
| Frontmatter `name`/`id` | `id: openspec-proposal` |

This alignment prevents user confusion and ensures the AI assistant can correctly invoke commands regardless of the tool being used.

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/design.md:50-70]()

## Architecture

### SlashCommandConfigurator

The `SlashCommandConfigurator` is the core component responsible for managing slash command files across multiple tools. It abstracts the differences between tool-specific command formats and provides a unified interface for command generation and updates.

```typescript
interface SlashCommandConfigurator {
  getTargets(): Array<{
    path: string;
    kind: 'slash';
    id: string;
  }>;
  
  generateAll(projectPath: string, openspecDir: string): void;
  updateExisting(projectPath: string, openspecDir: string): void;
}
```

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/design.md:80-95]()

### Design Principles

The architecture follows several key principles that guide slash command implementation across all supported tools.

```mermaid
graph TD
    A[Centralized Template Definition] --> B[Tool-Specific Adapter]
    B --> C[Claude Code Commands]
    B --> D[Cursor Commands]
    B --> E[Amazon Q Commands]
    B --> F[Other Tool Commands]
    
    G[Init Command] --> H[generateAll]
    G --> I[Creates All Tool Directories]
    
    J[Update Command] --> K[updateExisting]
    J --> L[Refreshes Only Existing Files]
    
    style A fill:#e1f5fe
    style G fill:#fff3e0
    style J fill:#fff3e0
```

1. **Centralized Templates**: Command bodies are defined once in shared template files and applied across all tools with minimal per-tool wrappers.

2. **Per-File Refresh on Update**: During `openspec update`, the system refreshes only existing slash command files on a per-file basis. It does not create missing files or add support for new tools.

3. **Tool-Specific Directories**: Each AI assistant receives commands stored in its native configuration directory structure.

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:60-75]()

## Command Templates

### Template Content Structure

Each slash command template contains several key sections that guide the AI assistant's behavior.

| Section | Purpose |
|---------|---------|
| **Guardrails** | 1-2 clarifying questions if needed; minimal complexity rules; tool usage preferences |
| **Step List** | Tailored workflow steps for the specific command stage |
| **Pointers** | References to `openspec show`, `openspec list`, and troubleshooting tips |

### Claude Code Naming Convention

Claude Code uses namespacing within the slash command itself for better readability and natural grouping:

```
/openspec/proposal
/openspec/apply
/openspec/archive
```

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/design.md:20-35]()

### Other Tools Convention

Most other tools use a flat naming convention with an `openspec-` prefix:

```
/openspec-proposal
/openspec-apply
/openspec-archive
```

Grouping is achieved through category metadata where supported (e.g., `category: OpenSpec`).

## Initialization and Updates

### Init Command Behavior

When running `openspec init`, the system creates slash command directories for all supported tools:

| Tool | Directory Created |
|------|-------------------|
| Claude Code | `.claude/commands/openspec/` |
| Cursor | `.cursor/commands/` |
| Amazon Q | `.amazonq/prompts/` |
| Cline | `.clinerules/workflows/` |

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:25-30]()

### Update Command Behavior

The `openspec update` command implements a conservative update strategy:

1. **Detection Phase**: Identify which tools already have slash command files installed
2. **Refresh Phase**: Update only the files that exist, refreshing both frontmatter and body content
3. **Preservation Phase**: Do not create missing files or add support for tools not already present

```mermaid
graph LR
    A[openspec update] --> B{Detect Existing Tools}
    B --> C[Tool A: 2 files exist]
    B --> D[Tool B: 0 files exist]
    
    C --> E[Refresh Tool A Files]
    D --> F[Skip Tool B]
    
    E --> G[Update Frontmatter + Body]
    F --> H[No Changes]
    
    style E fill:#c8e6c9
    style F fill:#ffcdd2
```

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/design.md:100-120]()

### Migration Handling

When updating from legacy versions, the system handles backward compatibility:

- **Old slash command directories** (`.claude/commands/openspec/`): The entire directory may be removed during cleanup
- **Config files with markers**: Markers are removed; files are deleted if empty afterward
- **Migration hints**: Users are informed about manual migration steps when needed

资料来源：[openspec/changes/archive/2026-02-17-merge-init-experimental/design.md:30-50]()

## Testing Strategy

The slash command system employs a comprehensive testing approach to ensure reliability across all supported tools.

### Golden Snapshots

Generated files are validated against expected outputs for each tool:

- Frontmatter structure and content
- Marker placement (never inside frontmatter)
- Body content matches centralized templates

### Partial Presence Tests

When only some files exist, the update behavior is tested:

```typescript
// If 1-2 files exist, update should only refresh those files
// and should not create missing files
test('update refreshes only existing files', async () => {
  await createPartialSetup();
  await runUpdate();
  expect(existingFiles).toHaveUpdatedContent();
  expect(missingFiles).toBeUndefined();
});
```

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md:100-115]()

### Marker Placement Tests

Specific tests ensure markers never appear inside frontmatter and cover recovery behavior for missing or duplicated markers.

### Logging Tests

Update operations report per-file status, enabling verification that each tool's files are processed correctly.

## Additional Commands (Opsx Workflow)

Beyond the core three commands, the `/opsx` prefix provides access to an extended experimental workflow:

| Command | Purpose |
|---------|---------|
| `/opsx:explore` | Explore ideas before committing to a change |
| `/opsx:new` | Start a new change with a specific artifact structure |
| `/opsx:continue` | Create artifacts one at a time (step-through mode) |
| `/opsx:ff` | Fast-forward through completed tasks |
| `/opsx:verify` | Verify artifact completeness and dependencies |
| `/opsx:bulk-archive` | Archive multiple changes at once |
| `/opsx:onboard` | Onboard new team members to the project |

资料来源：[README.md:1-30]()

To enable these commands, run:

```bash
openspec experimental
```

资料来源：[docs/opsx.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/opsx.md)

## Tool-Specific Implementations

### Claude Code

Claude Code stores commands in nested directories with namespaced slash names:

```
.claude/commands/openspec/
├── proposal.md
├── apply.md
└── archive.md
```

Invocation: `/openspec:proposal`, `/openspec:apply`, `/openspec:archive`

### Cursor

Cursor uses flat naming with a prefix:

```
.cursor/commands/
├── openspec-proposal.md
├── openspec-apply.md
└── openspec-archive.md
```

Invocation: `/openspec-proposal`, `/openspec-apply`, `/openspec-archive`

### Codex

Codex commands are written to the global prompts directory:

```bash
~/.codex/prompts/  # or $CODEX_HOME/prompts
```

The system supports both local and global installation paths, with commands refreshed during `openspec update` when they already exist.

资料来源：[openspec/changes/archive/2025-10-14-add-codex-slash-command-support/proposal.md:15-30]()

## Configuration and Customization

### Tool Registry

The `ToolRegistry` manages discovery and configuration for supported AI coding assistants, enabling the system to:

- Detect which tools are installed in a project
- Determine appropriate command storage locations
- Handle tool-specific format variations

### Context Injection

Slash command templates support dynamic context injection, prepending project-specific information:

```markdown
---
change: add-auth
artifact: proposal
schema: spec-driven
output: openspec/changes/add-auth/proposal.md
---

## Dependencies
- [x] (none - this is a root artifact)

## Next Steps
After creating this artifact, you can work on: design, specs

---

[original template content...]
```

资料来源：[openspec/changes/archive/2025-12-28-add-instruction-loader/design.md:1-30]()

## Related Documentation

- [Getting Started](docs/getting-started.md) — First steps with OpenSpec
- [Workflows](docs/workflows.md) — Combos and patterns for using slash commands
- [Commands Reference](docs/commands.md) — Detailed slash command documentation
- [Supported Tools](docs/supported-tools.md) — Full list of supported AI assistants
- [Opsx Workflow](docs/opsx.md) — Extended experimental workflow commands

---

<a id='workflows'></a>

## Workflows

### 相关页面

相关主题：[Slash Commands](#slash-commands), [Artifact Graph System](#artifact-graph)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [docs/workflows.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/workflows.md)
- [README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)
- [src/core/templates/workflows/new-change.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/templates/workflows/new-change.ts)
- [openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)
- [openspec/changes/archive/2025-10-14-add-windsurf-workflows/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-10-14-add-windsurf-workflows/proposal.md)
- [WORKSPACE_REIMPLEMENTATION_DIRECTION.md](https://github.com/Fission-AI/OpenSpec/blob/main/WORKSPACE_REIMPLEMENTATION_DIRECTION.md)
- [openspec/changes/archive/2026-02-17-project-config/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/proposal.md)
</details>

# Workflows

## Overview

Workflows in OpenSpec define the ordered sequence of artifacts that get created during a change's lifecycle. They provide a structured approach to capturing requirements, design decisions, and implementation tasks before any code is written.

**Purpose**: Workflows ensure that human and AI assistants align on what to build through a consistent, repeatable process that captures the "why," "what," and "how" of each change.

**Scope**: A workflow determines which artifacts need to be created, in what order, and what dependencies exist between them.

资料来源：[README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

## Core Concepts

### Artifacts

Artifacts are the files created during a change lifecycle. OpenSpec supports the following artifact types:

| Artifact | Description | Output File |
|----------|-------------|-------------|
| proposal | Why and what changes | `proposal.md` |
| specs | Requirements and scenarios | `specs/*.md` |
| design | Technical approach | `design.md` |
| tasks | Implementation checklist | `tasks.md` |

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)

### Workflow Stages

Each workflow progresses through distinct stages:

```mermaid
graph LR
    A[Propose] --> B[Design]
    B --> C[Specs]
    C --> D[Tasks]
    D --> E[Apply]
    E --> F[Archive]
    
    style A fill:#e1f5fe
    style E fill:#fff3e0
    style F fill:#f3e5f5
```

| Stage | Purpose | Key Question |
|-------|---------|--------------|
| **Proposal** | Capture the reason for the change | "Why are we doing this?" |
| **Design** | Document technical approach | "How will we build it?" |
| **Specs** | Define requirements and scenarios | "What should it do?" |
| **Tasks** | Break down implementation | "What are the steps?" |
| **Apply** | Execute implementation | "Make it happen" |
| **Archive** | Finalize and merge | "Clean up" |

资料来源：[README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

## Workflow Templates

OpenSpec ships with predefined workflow templates located in `src/core/templates/workflows/`.

### The New Change Workflow

The new change workflow (`new-change.ts`) scaffolds a complete change structure:

```typescript
export const newChangeWorkflow = {
  name: "New Change",
  description: "Scaffold a new OpenSpec change and validate strictly.",
  async execute(params) {
    // 1. Validate change name (kebab-case)
    // 2. Check if change already exists
    // 3. Create change directory
    // 4. Show artifact status
    // 5. Output first artifact template
  }
};
```

资料来源：[src/core/templates/workflows/new-change.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/templates/workflows/new-change.ts)

### Workflow Execution Steps

When initiating a new change, the workflow performs these steps in order:

1. **Validate the change name**
   - Must be kebab-case (e.g., `add-dark-mode`)
   - If invalid, prompt for a valid name

2. **Check for existing changes**
   - If a change with the same name exists, suggest using `continue-change` instead

3. **Create the scaffold**
   - Run `openspec init --change "<name>"` with `--schema <name>` if a specific workflow is requested
   - Creates `openspec/changes/<name>/` with the selected schema

4. **Show artifact status**
   ```bash
   openspec status --change "<name>"
   ```
   This displays which artifacts need creation and which are ready (dependencies satisfied).

5. **Output first artifact template**
   ```bash
   openspec instructions <first-artifact-id> --change "<name>"
   ```
   This outputs the template and context for creating the first artifact.

6. **STOP and wait for user direction**

资料来源：[src/core/templates/workflows/new-change.ts:1-60](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/templates/workflows/new-change.ts)

### Guardrails

The new change workflow includes important guardrails:

- **Do NOT create any artifacts yet** — only show the instructions
- **Do NOT advance beyond showing the first artifact template**
- **Pass `--schema`** only if using a non-default workflow
- Changes with invalid names (not kebab-case) trigger a prompt for correction
- Existing changes suggest using `/continue` instead

资料来源：[src/core/templates/workflows/new-change.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/templates/workflows/new-change.ts)

## Workflow Patterns

### Spec-Driven Workflow

The spec-driven workflow emphasizes design-first approach:

```mermaid
graph TD
    P[proposal] --> D[design]
    D --> S[specs]
    S --> T[tasks]
    
    P -.->|blocking| S
    P -.->|blocking| T
    D -.->|blocking| T
```

| Artifact | Generates | Dependencies |
|----------|-----------|--------------|
| proposal | `proposal.md` | None (root) |
| design | `design.md` | proposal |
| specs | `specs/*.md` | proposal, design |
| tasks | `tasks.md` | specs |

### Artifact Flow

```
┌────────────────────┐
│ Archive & Update   │
│ Specs (source)     │
└────────────────────┘
         │
         ▼
┌────────────────────┐
│ 1. Draft proposal  │
└────────────────────┘
         │
         ▼
┌────────────────────┐
│ 2. Review proposal │
└────────────────────┘
         │
         ▼
┌────────────────────┐
│ 3. Implement tasks │
└────────────────────┘
         │
         ▼
┌────────────────────┐
│ 4. Archive change  │
└────────────────────┘
         │
         ▼
┌────────────────────┐
│ Specs updated      │
└────────────────────┘
```

资料来源：[openspec/changes/archive/2025-10-14-add-windsurf-workflows/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-10-14-add-windsurf-workflows/proposal.md)

## Workflows with Slash Commands

OpenSpec integrates with multiple AI coding assistants through slash command workflows. Each tool has its own command structure and file format.

### Supported Tools and Commands

| Tool | Slash Commands | File Location |
|------|----------------|---------------|
| Claude Code | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | Built-in |
| CodeBuddy | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | `.codebuddy/commands/` |
| Cursor | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.cursor/commands/` |
| Windsurf | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.windsurf/workflows/` |
| Kilo Code | `/openspec-proposal.md`, `/openspec-apply.md`, `/openspec-archive.md` | `.kilocode/workflows/` |
| Cline | Workflows | `.clinerules/workflows/` |
| GitHub Copilot | `@openspec-proposal`, `@openspec-apply`, `@openspec-archive` | `.github/prompts/` |
| Continue | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.continue/prompts/` |
| Antigravity | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.agent/workflows/` |

资料来源：[README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

### Slash Command File Structure

Slash command files follow a consistent pattern:

```markdown
---
name: openspec-proposal
description: Create an OpenSpec proposal
category: OpenSpec
---
<!-- OPENSPEC:START -->
...command body from shared template...
<!-- OPENSPEC:END -->
```

**Template Content Structure:**
- Guardrails: 1–2 clarifying questions
- Minimal-complexity rules
- Step list tailored to workflow stage
- Pointers to `openspec show`, `openspec list`
- Troubleshooting tips

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)

## CLI Commands for Workflows

OpenSpec provides CLI commands to interact with workflows:

```bash
# List active change folders
openspec list

# Interactive dashboard of specs and changes
openspec view

# Display change details
openspec show <change>

# Check spec formatting and structure
openspec validate <change>

# Move completed change to archive
openspec archive <change> [--yes|-y]

# Show artifact status
openspec status --change "<name>"

# Get instructions for artifact creation
openspec instructions <artifact-id> --change "<name>"
```

资料来源：[README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

## Workflow Example

### Create and Execute a Change

```text
You: /openspec:propose add-dark-mode
AI:  Created openspec/changes/add-dark-mode/
     ✓ proposal.md — why we're doing this, what's changing
     ✓ specs/       — requirements and scenarios
     ✓ design.md    — technical approach
     ✓ tasks.md     — implementation checklist
     Ready for implementation!

You: /openspec:apply
AI:  Implementing tasks...
     ✓ 1.1 Add theme context provider
     ✓ 1.2 Create toggle component
     ✓ 2.1 Add CSS variables
     ✓ 2.2 Wire up localStorage
     All tasks complete!

You: /openspec:archive
AI:  Archived to openspec/changes/archive/2025-01-23-add-dark-mode/
     Specs updated. Ready for the next feature.
```

资料来源：[README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

## Project Configuration

Workflows can be customized per project through configuration:

| Configuration Option | Description |
|---------------------|-------------|
| schema | Selected workflow/schema (e.g., "spec-driven") |
| projectContext | Multi-line context (tech stack, conventions) |
| artifactRules | Per-artifact custom rules |

### Config Section Prompts

When running `openspec init`, the setup command displays:

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📋 Project Configuration (Optional)
Configure project defaults for OpenSpec workflows.
```

Steps:
1. **Create config?** — Yes/No prompt (default "Yes")
2. **Schema selection** — List schemas with descriptions
3. **Project context** — Multi-line input for tech stack info
4. **Per-artifact rules** — Optional rules for specific artifacts
5. **Validate and write** — Save to `openspec/config.yaml`

资料来源：[openspec/changes/archive/2026-02-17-project-config/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/proposal.md)

## Workspace Workflow Extensions

The OpenSpec workspace feature extends workflows across multiple repositories:

```mermaid
graph TD
    W[Workspace] --> L[Links]
    L --> P[Proposal]
    P --> R[Repo Slices]
    R --> A[Apply]
    A --> V[Verify]
    V --> C[Archive]
```

### Workspace Workflow Sequence

| Step | Capability |
|------|------------|
| 1 | Set up the workspace |
| 2 | See linked repos or folders |
| 3 | Explore repos with agent |
| 4 | Capture a proposal |
| 5 | Check status |
| 6 | Implement one repo slice |
| 7 | Verify |
| 8 | Archive |

### Apply One Repo Slice

The `/apply` command for workspaces:

```text
User: /apply integrate-docs for landing
```

**Agent behavior:**
1. Ask OpenSpec for apply context
2. Read proposal, design, tasks, and relevant specs
3. Confirm the target repo checkout
4. Edit only that repo
5. Update workspace tasks
6. Run relevant checks

**What `/apply` means:**
- Implement the planned slice for one repo
- Does NOT copy planning files
- Does NOT materialize repo-local OpenSpec state
- Does NOT create proposal files for the first time

资料来源：[WORKSPACE_REIMPLEMENTATION_DIRECTION.md](https://github.com/Fission-AI/OpenSpec/blob/main/WORKSPACE_REIMPLEMENTATION_DIRECTION.md)

## Related Documentation

- [Getting Started](docs/getting-started.md) — First steps with workflows
- [Commands](docs/commands.md) — Slash commands & skills reference
- [CLI](docs/cli.md) — Terminal command reference
- [Supported Tools](docs/supported-tools.md) — Tool integrations & install paths
- [Concepts](docs/concepts.md) — How it all fits together
- [Customization](docs/customization.md) — Make workflows yours

---

<a id='artifact-graph'></a>

## Artifact Graph System

### 相关页面

相关主题：[System Architecture](#architecture), [Workflows](#workflows), [Schemas](#schemas)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [src/core/artifact-graph/graph.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/artifact-graph/graph.ts)
- [src/core/artifact-graph/state.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/artifact-graph/state.ts)
- [src/core/artifact-graph/resolver.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/artifact-graph/resolver.ts)
- [src/core/artifact-graph/schema.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/artifact-graph/schema.ts)
- [src/core/artifact-graph/outputs.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/artifact-graph/outputs.ts)
- [src/core/artifact-graph/instruction-loader.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/artifact-graph/instruction-loader.ts)
</details>

# Artifact Graph System

## Overview

The Artifact Graph System is the core module of OpenSpec that manages artifact dependencies, workflow state detection, and schema-driven instruction generation. It provides a declarative way to define artifact relationships through YAML schemas and enables intelligent workflow progression based on filesystem state.

### Purpose

The system solves several key problems in AI-assisted development:

1. **Dependency Management** - Ensures artifacts are created in the correct order based on their dependencies
2. **State Detection** - Automatically detects which artifacts are completed, ready, or blocked based on filesystem presence
3. **Schema Resolution** - Supports both user-defined schemas (via XDG directories) and built-in package schemas
4. **Instruction Generation** - Enriches templates with project context, artifact-specific rules, and dependency status

### High-Level Architecture

```mermaid
graph TB
    subgraph "Artifact Graph System"
        YAML[("Schema YAML")]
        GRAPH[("ArtifactGraph")]
        STATE[("State Detection")]
        INSTR[("Instruction Loader")]
        CTX[("ChangeContext")]
    end
    
    subgraph "Schema Sources"
        USER[("User Schemas<br/>XDG_DATA_HOME")]
        BUILTIN[("Built-in Schemas<br/>Package")]
    end
    
    YAML --> GRAPH
    GRAPH --> STATE
    GRAPH --> CTX
    STATE --> CTX
    CTX --> INSTR
    
    USER -->|resolveSchema| GRAPH
    BUILTIN -->|resolveSchema| GRAPH
```

## Core Concepts

### Artifacts

Artifacts are the fundamental units of work in OpenSpec. Each artifact has:

| Property | Type | Description |
|----------|------|-------------|
| `id` | string | Unique identifier within the schema |
| `generates` | string | File pattern generated by this artifact |
| `template` | string | Template file path (relative to schema directory) |
| `requires` | string[] | List of artifact IDs that must complete first |

### Schema Structure

Schemas define the workflow for a change. They are YAML files with the following structure:

```yaml
name: spec-driven
version: 1
description: Specification-driven development workflow

artifacts:
  - id: proposal
    generates: "proposal.md"
    template: "proposal.md"
    requires: []

  - id: specs
    generates: "specs/*.md"
    template: "spec.md"
    requires: [proposal]

  - id: design
    generates: "design.md"
    template: "design.md"
    requires: [proposal]

  - id: tasks
    generates: "tasks.md"
    template: "tasks.md"
    requires: [specs, design]
```

## ArtifactGraph Class

The `ArtifactGraph` class is the central component that loads schemas and provides graph query operations.

### Class Structure

```typescript
export class ArtifactGraph {
  private artifacts: Map<string, Artifact>;
  private schema: SchemaYaml;

  private constructor(schema: SchemaYaml) {
    this.schema = schema;
    this.artifacts = new Map(schema.artifacts.map(a => [a.id, a]));
  }
}
```

### Factory Methods

| Method | Description | Source |
|--------|-------------|--------|
| `fromYaml(filePath)` | Load graph from a schema YAML file path | `graph.ts:18-21` |
| `fromYamlContent(yamlContent)` | Parse graph from YAML content string | `graph.ts:27-29` |
| `fromSchema(schema)` | Create graph from pre-validated SchemaYaml object | `graph.ts:35-37` |

### Query Methods

| Method | Return Type | Description |
|--------|-------------|--------------|
| `getArtifact(id)` | `Artifact \| undefined` | Get a single artifact by ID |
| `getAllArtifacts()` | `Artifact[]` | Get all artifacts in definition order |
| `getName()` | `string` | Get the schema name |
| `getSchema()` | `SchemaYaml` | Get the underlying schema object |

## State Detection

The state detection module (`state.ts`) monitors the filesystem to determine the status of each artifact relative to a change directory.

### State Types

| State | Description |
|-------|-------------|
| `completed` | All files matching the artifact's `generates` pattern exist |
| `ready` | All dependencies are completed, can be worked on |
| `blocked` | Dependencies are not yet completed |

### State Detection Logic

```typescript
interface ArtifactGraphResult {
  completed: string[];      // Artifact IDs that are fully completed
  ready: string[];          // Artifact IDs ready to work on
  blocked: BlockedArtifacts; // Artifact IDs with their unmet dependencies
  buildOrder: string[];     // Topological order for creation
}
```

The detection process:

1. For each artifact, check if files matching `generates` exist in the change directory
2. Collect all completed artifact IDs into a `CompletedSet` (a `Set<string>`)
3. For each non-completed artifact, find which dependencies are unmet
4. Artifacts with all dependencies met are marked `ready`

## Topological Sorting

The system uses Kahn's algorithm for topological sorting to determine the correct build order for artifacts.

### Algorithm Properties

- **Cycle Detection**: Kahn's algorithm naturally fails on cyclic dependencies, providing natural cycle detection
- **Stable Ordering**: Independent artifacts are returned in definition order
- **Linear Time**: O(V + E) where V is artifacts and E is dependencies

### Error Format

When a cycle is detected, the error message clearly identifies the cycle path:

```
Cyclic dependency detected: A → B → C → A
```

## Schema Resolution

The `resolver.ts` module handles loading schemas from multiple sources with a defined priority order.

### Resolution Order

```mermaid
graph LR
    A[("Schema Name")] --> B{Global Override?}
    B -->|Yes| C["${XDG_DATA_HOME}/openspec/schemas/<name>"]
    B -->|No| D{Package Built-in?}
    D -->|Yes| E["<package>/schemas/<name>"]
    D -->|No| F[("Error: Schema not found")]
    C --> G[("Loaded Schema")]
    E --> G
```

### Resolution Paths

| Priority | Location | Environment Variable |
|----------|----------|----------------------|
| 1 (User Override) | `${XDG_DATA_HOME}/openspec/schemas/<name>` | `XDG_DATA_HOME` |
| 2 (Built-in) | `<package>/schemas/<name>` | N/A |
| 3 (Error) | Schema not found | N/A |

**Fallback Behavior**: If `XDG_DATA_HOME` is not set, the system falls back to `~/.local/share` on Unix systems.

## Built-in Schemas

OpenSpec ships with two built-in schemas:

### spec-driven Schema

The default schema following a proposal → specs → design → tasks workflow:

```yaml
name: spec-driven
artifacts:
  - id: proposal
    generates: "proposal.md"
    requires: []
  - id: specs
    generates: "specs/*.md"
    requires: [proposal]
  - id: design
    generates: "design.md"
    requires: [proposal]
  - id: tasks
    generates: "tasks.md"
    requires: [specs, design]
```

### tdd Schema

An alternative schema for test-driven development:

```yaml
name: tdd
artifacts:
  - id: tests
    generates: "tests/*.md"
    requires: []
  - id: implementation
    generates: "implementation.md"
    requires: [tests]
  - id: docs
    generates: "docs.md"
    requires: [implementation]
```

## Instruction Loading

The `instruction-loader.ts` module enriches templates with change-specific context and project configuration.

### ChangeContext Interface

```typescript
interface ChangeContext {
  changeName: string;
  changeDir: string;
  schemaName: string;
  graph: ArtifactGraph;
  completed: CompletedSet;
}
```

### Instruction Output Structure

Instructions are formatted with XML-like sections for AI consumption:

```markdown
<artifact id="proposal" change="add-auth" schema="spec-driven">
<context>
[Project context from config]
</context>

<rules>
[Artifact-specific rules from config]
</rules>

<template>
[Schema's template content]
</template>
```

### Context Injection Rules

| Section | Applies To | Source |
|---------|-----------|--------|
| `<context>` | All artifacts | Project config's `context` field |
| `<rules>` | Specific artifacts only | Per-artifact rules in project config |
| `<template>` | All artifacts | Schema's template file |

## File Structure

```
src/core/artifact-graph/
├── index.ts              # Public exports
├── types.ts              # Zod schemas and TypeScript types
├── graph.ts              # ArtifactGraph class
├── state.ts              # State detection logic
├── resolver.ts           # Schema resolution
├── schema.ts             # YAML parsing and validation
├── outputs.ts            # Output path resolution
├── instruction-loader.ts # Template enrichment
└── schemas/              # Built-in schema definitions
    ├── spec-driven/
    │   ├── schema.yaml
    │   └── templates/
    └── tdd/
        ├── schema.yaml
        └── templates/
```

## Integration Points

### With Workflow Commands

The Artifact Graph System integrates with the `/opsx:continue` and `/opsx:apply` workflows:

1. **Continue Workflow** - Reads instructions for the next ready artifact
2. **Apply Workflow** - Checks completion status and provides apply-phase instructions

### With Project Config

Project-level configuration (`openspec/config.yaml`) can provide:

- Default schema selection
- Project context for all artifacts
- Per-artifact rules and guidelines

## Testing

The system includes comprehensive test coverage:

| Test Case | Purpose |
|-----------|---------|
| Parse valid schema YAML | Schema loading works correctly |
| Parse invalid schema | Missing fields throw descriptive errors |
| Duplicate artifact IDs | Detection and error reporting |
| Invalid `requires` reference | Identification of invalid artifact IDs |
| Cycle detection | Error with cycle path listing |
| Build order (linear) | Topological sort correctness |
| Build order (diamond) | Complex dependency handling |
| Independent artifacts | Stable ordering of unrelated nodes |

## Related Documentation

- [Schema Directories Design](../changes/archive/2025-12-28-restructure-schema-directories/design.md) - Schema directory structure
- [Instruction Loader Design](../changes/archive/2025-12-28-add-instruction-loader/design.md) - Template loading and enrichment
- [Apply-Phase Schema Design](../changes/archive/2026-01-06-make-apply-instructions-schema-aware/design.md) - Apply phase configuration
- [Project Config Design](../changes/archive/2026-02-17-project-config/design.md) - Project-level configuration integration

---

<a id='schemas'></a>

## Schemas

### 相关页面

相关主题：[Validation System](#validation-system), [Artifact Graph System](#artifact-graph)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [schemas/spec-driven/schema.yaml](https://github.com/Fission-AI/OpenSpec/blob/main/schemas/spec-driven/schema.yaml)
- [schemas/workspace-planning/schema.yaml](https://github.com/Fission-AI/OpenSpec/blob/main/schemas/workspace-planning/schema.yaml)
- [src/core/schemas/index.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/schemas/index.ts)
- [src/core/schemas/base.schema.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/schemas/base.schema.ts)
- [src/core/schemas/change.schema.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/schemas/change.schema.ts)
- [src/core/schemas/spec.schema.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/schemas/spec.schema.ts)
</details>

# Schemas

Schemas define the workflow structure for OpenSpec changes. They specify which artifacts should be created, their dependencies, requirements for completion, and how the apply phase operates.

## Overview

A schema in OpenSpec is a configuration that defines a complete workflow for planning and implementing changes. Schemas specify:

- The **artifacts** to create (e.g., proposal, specs, design, tasks)
- The **dependencies** between artifacts
- **Requirements** that must be met before each artifact is considered complete
- **Templates** for generating artifact content
- **Apply phase** configuration for implementation guidance

Schemas are self-contained directories containing `schema.yaml` and template files, following a structure similar to Helm charts. 资料来源：[openspec/changes/archive/2025-12-28-restructure-schema-directories/design.md]()

## Schema Directory Structure

```
schemas/
├── spec-driven/
│   ├── schema.yaml           # Schema definition
│   └── templates/
│       ├── proposal.md
│       ├── design.md
│       ├── spec.md
│       └── tasks.md
└── tdd/
    ├── schema.yaml
    └── templates/
        ├── spec.md
        ├── test.md
        ├── implementation.md
        └── docs.md
```

Built-in schemas are distributed with the package, while user overrides can be placed in XDG data directories. 资料来源：[openspec/changes/archive/2025-12-28-restructure-schema-directories/design.md]()

## Schema Resolution Order

OpenSpec resolves schemas using a priority-based lookup:

```mermaid
graph TD
    A[Schema Request] --> B{CLI --schema flag?}
    B -->|Yes| C[Use CLI flag]
    B -->|No| D{.openspec.yaml in change?}
    D -->|Yes| E[Use change metadata]
    D -->|No| F{openspec/config.yaml schema?}
    F -->|Yes| G[Use project default]
    F -->|No| H{"spec-driven" fallback}
```

| Priority | Source | Example Path |
|----------|--------|--------------|
| 1 (highest) | CLI flag | `--schema tdd` |
| 2 | Change metadata | `.openspec.yaml` |
| 3 | Project config | `openspec/config.yaml` |
| 4 (lowest) | Hardcoded default | `"spec-driven"` |

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md]()

## Schema YAML Format

### Core Fields

```yaml
name: spec-driven
version: 1
description: Specification-driven development
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `name` | string | Yes | Unique schema identifier (kebab-case) |
| `version` | number | Yes | Schema version for compatibility |
| `description` | string | Yes | Human-readable description |

### Artifacts Section

The `artifacts` array defines each artifact in the workflow:

```yaml
artifacts:
  - id: proposal
    generates: proposal.md
    template: proposal.md
    requires: []
    
  - id: specs
    generates: specs/
    template: spec.md
    requires:
      - proposal
```

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `id` | string | Yes | Unique artifact identifier |
| `generates` | string | Yes | Output path or directory |
| `template` | string | Yes | Template file relative to `templates/` |
| `requires` | string[] | No | Artifact IDs that must exist first |
| `format_requirements` | string | No | Special formatting instructions |

资料来源：[schemas/spec-driven/schema.yaml]()

## Built-in Schemas

### spec-driven

The default schema focused on specification-driven development. It emphasizes clear requirements and scenarios before implementation.

**Artifact Flow:**
```mermaid
graph LR
    A[proposal] --> B[specs]
    B --> C[design]
    C --> D[tasks]
    D --> E[apply]
```

| Artifact | Generates | Requires | Purpose |
|----------|-----------|----------|---------|
| `proposal` | `proposal.md` | (none) | Define the change scope |
| `specs` | `specs/*.md` | proposal | Document requirements and scenarios |
| `design` | `design.md` | specs | Technical approach |
| `tasks` | `tasks.md` | design, specs | Implementation checklist |

### workspace-planning

Schema for multi-repository planning and coordination across workspaces.

资料来源：[schemas/workspace-planning/schema.yaml]()

### tdd (Test-Driven Development)

Schema focused on tests first, following the pattern: spec → test → implementation → docs.

| Artifact | Generates | Requires |
|----------|-----------|----------|
| `spec` | `spec.md` | (none) |
| `test` | `test.md` | spec |
| `implementation` | `implementation.md` | test |
| `docs` | `docs.md` | implementation |

## Requirements Format

Requirements define completion criteria for artifacts. They use a structured format with scenarios.

```markdown
## Requirements

### Requirement: <name>
<description using SHALL/MUST for normative requirements>

#### Scenario: <name>
- **WHEN** <condition>
- **THEN** <expected outcome>
```

**Key Formatting Rules:**
- Requirements use `### Requirement:` with exactly 3 hashtags
- Scenarios use `#### Scenario:` with exactly 4 hashtags
- Use SHALL/MUST for normative requirements (avoid should/may)
- Every requirement MUST have at least one scenario

资料来源：[schemas/spec-driven/schema.yaml]()

## Apply Phase Configuration

The optional `apply` block defines how implementation should proceed:

```yaml
apply:
  requires:
    - specs
    - design
    - tasks
  tracks:
    - id: implementation
      label: Implementation
  instruction: |
    Proceed with implementation based on the tasks artifact.
```

| Field | Type | Description |
|-------|------|-------------|
| `requires` | string[] | Artifacts that must exist before apply |
| `tracks` | Track[] | Progress tracking categories |
| `instruction` | string | Instructions displayed during apply |

资料来源：[openspec/changes/archive/2026-01-06-make-apply-instructions-schema-aware/tasks.md]()

## Schema Resolution Implementation

The `resolveSchema()` function handles schema loading with user overrides:

```typescript
// Resolution order (highest to lowest priority)
1. ${XDG_DATA_HOME}/openspec/schemas/<name>/schema.yaml   // User override
2. <package>/schemas/<name>/schema.yaml                   // Built-in
```

```typescript
function getPackageSchemasDir(): string {
  const currentFile = fileURLToPath(import.meta.url);
  // Navigate from src/core/artifact-graph/ to package root
  return path.join(path.dirname(currentFile), '..', '..', '..', 'schemas');
}
```

资料来源：[openspec/changes/archive/2025-12-28-restructure-schema-directories/design.md]()

## Template Loading

Templates are loaded relative to the schema's `templates/` directory:

```yaml
# In schema.yaml
artifacts:
  - id: proposal
    template: "proposal.md"  # → schemas/spec-driven/templates/proposal.md
```

Templates are simple markdown files without template engine dependencies. Context injection prepends a header section:

```markdown
---
change: add-auth
artifact: proposal
schema: spec-driven
output: openspec/changes/add-auth/proposal.md
---

## Dependencies
- [x] (none - this is a root artifact)

## Next Steps
After creating this artifact, you can work on: design, specs

---

[original template content...]
```

资料来源：[openspec/changes/archive/2025-12-28-add-instruction-loader/design.md]()

## Project Configuration Integration

Schemas integrate with `openspec/config.yaml` for project defaults:

```yaml
schema: spec-driven  # Default schema for new changes
context: |
  Tech stack: TypeScript, React, Node.js
  API style: RESTful
rules:
  design:
    - Include rollback plan
```

The `schema` field in config sets the project default, which is used when:
- Creating new changes without `--schema` flag
- Running commands on changes without `.openspec.yaml` metadata

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md]()

## Context Injection

When generating instructions for artifacts, schemas support context injection via XML-style tags:

```xml
<context>
Tech stack: TypeScript, React, Node.js, PostgreSQL
API style: RESTful, documented in docs/api-conventions.md
</context>

<rules>
- Include rollback plan
- Identify affected teams and notify in #platform-changes
</rules>

<template>
[Schema's built-in template content]
</template>
```

**Injection Priority:**
- `<context>` appears for all artifacts (from project config)
- `<rules>` appear only for matching artifact IDs
- `<template>` contains the schema's base template content

资料来源：[openspec/changes/archive/2026-02-17-project-config/proposal.md]()

## CLI Commands

### List Available Schemas

```bash
openspec schemas list
```

Displays all available schemas with their source (project, user, package).

### Initialize New Schema

```bash
openspec schema init <name> \
  --description "My custom workflow" \
  --artifacts proposal,specs,design,tasks \
  --default
```

Creates a new schema in `openspec/schemas/<name>/` with the specified configuration.

### Show Schema Details

```bash
openspec schema show <name>
```

Displays schema definition including artifacts, requirements, and apply configuration.

---

<a id='configuration'></a>

## Configuration

### 相关页面

相关主题：[Getting Started](#getting-started)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [openspec/config.yaml](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/config.yaml)
- [src/core/config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/config.ts)
- [src/core/config-schema.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/config-schema.ts)
- [src/core/global-config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/global-config.ts)
- [src/core/project-config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/project-config.ts)
- [src/core/profiles.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/profiles.ts)
- [src/commands/config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/commands/config.ts)
</details>

# Configuration

OpenSpec uses a layered configuration system that manages project-level settings, global defaults, and user preferences. This configuration architecture enables teams to share project context, define artifact-specific rules, and customize the OpenSpec workflow across different environments.

## Overview

The OpenSpec configuration system serves three primary purposes:

1. **Schema Selection** — Define which OpenSpec schema to use for change management
2. **Context Injection** — Provide project background (tech stack, conventions, terminology) that gets injected into generated artifacts
3. **Per-Artifact Rules** — Define constraints and guidelines that apply to specific artifact types

```mermaid
graph TD
    A[User Project] --> B[openspec/config.yaml]
    A --> C[Global Config]
    A --> D[User Config]
    
    B --> E[Schema Resolution]
    C --> E
    D --> E
    
    E --> F[spec-driven]
    E --> G[minimal]
    E --> H[custom schemas]
    
    F --> I[Artifact Generation]
    G --> I
    H --> I
    
    I --> J[proposal.md]
    I --> K[specs/*.md]
    I --> L[design.md]
    I --> M[tasks.md]
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/design.md)

## Configuration Files

### Project Configuration (`openspec/config.yaml`)

The project-level configuration file lives in the `openspec/` directory and is designed to be committed to version control. This ensures all team members share the same project context and rules.

**Location:** `<project-root>/openspec/config.yaml`

**Structure:**

```yaml
schema: spec-driven
context:
  project_name: My Application
  tech_stack:
    - Node.js
    - TypeScript
    - PostgreSQL
  conventions:
    - Use async/await for all asynchronous operations
    - Follow conventional commits
  terminology:
    - "change" refers to a feature or fix being implemented
    - "artifact" refers to a generated file

rules:
  proposal:
    - Include spike tasks for unknowns
  specs:
    - Use SHALL/MUST for normative requirements
    - Every requirement needs at least one scenario
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/proposal.md)

### Schema Configuration

Each schema defines its own structure and templates. The `spec-driven` schema, for example, includes requirements for how artifacts should be formatted:

```yaml
artifacts:
  - id: proposal
    generates: proposal.md
    requires: []
    
  - id: specs
    generates: specs/*.md
    requires:
      - proposal
      
  - id: design
    generates: design.md
    requires:
      - proposal
      - specs
```

资料来源：[schemas/spec-driven/schema.yaml](https://github.com/Fission-AI/OpenSpec/blob/main/schemas/spec-driven/schema.yaml)

## Configuration Architecture

### Configuration Resolution Order

OpenSpec resolves configuration values using a specific precedence order:

```mermaid
graph LR
    A[CLI Flag] -->|highest| B[Change Metadata]
    B --> C[Project Config]
    C -->|lowest| D[Global Config]
    D --> E[Hardcoded Default]
```

| Priority | Source | Description |
|----------|--------|-------------|
| 1 | CLI Flag | Explicit `--schema` parameter |
| 2 | Change Metadata | `.openspec.yaml` in change directory |
| 3 | Project Config | `openspec/config.yaml` |
| 4 | Global Config | User's global settings |
| 5 | Default | Hardcoded fallback (`spec-driven`) |

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/design.md)

### Module Structure

```
src/core/
├── config.ts           # Main configuration module
├── config-schema.ts    # Configuration schema definitions
├── global-config.ts    # Global configuration management
├── project-config.ts   # Project-level configuration handling
└── profiles.ts         # Profile management
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/design.md)

## Core Modules

### Project Config Module

The `project-config.ts` module handles reading, parsing, and validating project-level configuration.

**Key Responsibilities:**

- Read `openspec/config.yaml` from the project root
- Parse YAML into typed configuration objects
- Validate schema names against available schemas
- Provide error messages for misconfiguration

**Validation Logic:**

```typescript
export function validateProjectConfig(config: ProjectConfig): ValidationResult {
  const errors: string[] = [];
  
  if (config.schema) {
    const availableSchemas = getAvailableSchemas();
    if (!availableSchemas.includes(config.schema)) {
      errors.push(`Invalid schema: ${config.schema}`);
    }
  }
  
  return { valid: errors.length === 0, errors };
}
```

资料来源：[src/core/project-config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/project-config.ts)

### Profile Management

Profiles allow users to customize their OpenSpec workflow by selecting different command sets and behaviors.

```mermaid
graph TD
    A[Profile Selection] --> B[Minimal Profile]
    A --> C[Artifact-Guided Profile]
    A --> D[Experimental Profile]
    
    B --> B1[Basic commands: init, list, show]
    C --> C1[opsx commands: new, continue, ff]
    D --> D1[Early access features]
```

**Available Profiles:**

| Profile | Commands | Description |
|---------|----------|-------------|
| `minimal` | `init`, `list`, `show`, `new`, `apply`, `archive` | Basic workflow |
| `artifact-guided` | `opsx:*` commands | New artifact-driven workflow |
| `experimental` | All + experimental features | Early access features |

资料来源：[openspec/README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

## Configuration CLI Commands

The `config` command group provides interactive management of OpenSpec configuration.

### Commands

| Command | Description |
|---------|-------------|
| `openspec config profile` | Select active workflow profile |
| `openspec config view` | Display current configuration |
| `openspec config validate` | Validate configuration files |
| `openspec config init` | Initialize project configuration |

### Interactive Profile Selection

```bash
$ openspec config profile
? Select a profile:
  > minimal (default)
    artifact-guided (recommended)
    experimental
```

资料来源：[src/commands/config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/commands/config.ts)

## Context and Rules Injection

### How Context Works

The project `context` section is injected into generated artifacts to provide project-specific background information:

```bash
# Get instructions for artifact with context
openspec instructions specs --change my-feature

# Output structure:
<context>
[Project context from config.yaml]
</context>

<template>
[Schema's specs template]
</template>
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/proposal.md)

### Rule Injection by Artifact Type

Rules are only injected for artifacts that have them configured:

```mermaid
graph TD
    A[Artifact Request] --> B{Has rules?}
    B -->|Yes| C[Include rules section]
    B -->|No| D[Skip rules section]
    
    C --> E[<context>]
    C --> F[<rules>]
    C --> G[<template>]
    
    D --> E
    D --> G
```

**Example: Rules for `proposal` artifact:**

```yaml
rules:
  proposal:
    - Include spike tasks for unknown complexities
    - Reference existing patterns before inventing new ones
```

**Example: Rules for `specs` artifact:**

```yaml
rules:
  specs:
    - Use SHALL/MUST for normative requirements
    - Every requirement MUST have at least one scenario
    - Scenarios MUST use exactly 4 hashtags (####)
```

资料来源：[schemas/spec-driven/schema.yaml](https://github.com/Fission-AI/OpenSpec/blob/main/schemas/spec-driven/schema.yaml)

## Schema Resolution

### Resolution Function

The `resolveSchemaForChange()` function determines which schema to use:

```typescript
export function resolveSchemaForChange(
  changeName: string,
  cliSchema?: string
): string {
  // 1. CLI flag wins
  if (cliSchema) {
    return cliSchema;
  }

  // 2. Change metadata (.openspec.yaml)
  const metadata = readChangeMetadata(changeName);
  if (metadata?.schema) {
    return metadata.schema;
  }

  // 3. Project config (NEW)
  const projectConfig = readProjectConfig();
  if (projectConfig?.schema) {
    return projectConfig.schema;
  }

  // 4. Hardcoded default
  return 'spec-driven';
}
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/design.md)

### Project-Local Schemas

OpenSpec supports project-local schemas that override built-in schemas:

```mermaid
graph TD
    A[Schema Request] --> B{Project-local exists?}
    B -->|Yes| C[Use project-local]
    B -->|No| D{User override exists?}
    D -->|Yes| E[Use user override]
    D -->|No| F[Use built-in]
```

**Schema Search Order:**

1. `<project>/openspec/schemas/<name>/`
2. `<user-data>/openspec/schemas/<name>/`
3. `<npm-package>/schemas/<name>/`

资料来源：[openspec/changes/archive/2026-02-17-project-local-schemas/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-local-schemas/design.md)

## Global Configuration

Global configuration lives in the user's home directory and provides defaults that apply across all projects.

**Default Location:** `~/.config/openspec/config.yaml` (Linux/macOS)

**Purpose:**

- Default profile selection
- Telemetry preferences
- Editor-specific settings

### Telemetry Configuration

OpenSpec collects anonymous usage statistics by default:

```bash
# Opt-out via environment variable
export OPENSPEC_TELEMETRY=0
# or
export DO_NOT_TRACK=1
```

资料来源：[openspec/README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)

## Validation and Error Handling

### Configuration Validation

The validation system checks for common configuration errors:

```typescript
export function validateConfig(config: unknown): ValidationResult {
  const errors: string[] = [];
  
  // Check schema validity
  if (!config.schema || !isValidSchema(config.schema)) {
    errors.push(`Invalid schema: ${config.schema}`);
  }
  
  // Check context structure
  if (config.context && typeof config.context !== 'object') {
    errors.push('Context must be an object');
  }
  
  return { valid: errors.length === 0, errors };
}
```

### Error Messages

When validation fails, OpenSpec provides actionable error messages:

```
Error: Invalid schema 'unknown-schema'
Available schemas:
  Built-in: spec-driven, minimal, gpt-prompts
  Project-local: (none found)

Fix: Edit openspec/config.yaml and change 'schema: unknown-schema' to a valid schema name
```

资料来源：[src/core/project-config.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/project-config.ts)

## Migration from Legacy Config

### Old Configuration Files

OpenSpec previously used different configuration mechanisms that are now deprecated:

| Old File | New Location | Notes |
|----------|--------------|-------|
| `openspec/project.md` | `openspec/config.yaml.context` | Migrate manually |
| `CLAUDE.md` | `openspec/config.yaml` | Removed |
| `.cursorrules` | `openspec/config.yaml` | Removed |
| `.windsurfrules` | `openspec/config.yaml` | Removed |

### Migration Steps

1. Run `openspec init` to detect legacy artifacts
2. Review the migration hints provided
3. Manually migrate `project.md` content to `config.yaml.context`
4. Delete old configuration files when ready

资料来源：[openspec/changes/archive/2026-02-17-merge-init-experimental/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-merge-init-experimental/design.md)

## Best Practices

### Configuration Organization

1. **Commit `config.yaml`** — Keep project configuration in version control for team consistency
2. **Use descriptive context** — Include tech stack, conventions, and terminology
3. **Define artifact rules** — Set clear guidelines for each artifact type
4. **Keep rules concise** — Rules should be actionable constraints, not verbose documentation

### Team Collaboration

```bash
# Share configuration via git
git add openspec/config.yaml
git commit -m "Add project config with context and rules"

# Everyone gets the same context and rules automatically
```

资料来源：[openspec/changes/archive/2026-02-17-project-config/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2026-02-17-project-config/proposal.md)

## Summary

The OpenSpec configuration system provides a flexible, layered approach to managing project settings:

- **Project-level config** (`openspec/config.yaml`) for team-shared context and rules
- **Schema-based organization** for consistent artifact generation
- **Per-artifact rules** for tailored guidelines
- **Profile system** for workflow customization
- **Validation** to catch configuration errors early

---

<a id='validation-system'></a>

## Validation System

### 相关页面

相关主题：[Schemas](#schemas), [Configuration](#configuration)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [src/core/validation/validator.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/validation/validator.ts)
- [src/core/validation/types.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/validation/types.ts)
- [src/core/validation/constants.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/validation/constants.ts)
- [src/core/parsers/spec-structure.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/parsers/spec-structure.ts)
- [src/commands/validate.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/commands/validate.ts)
</details>

# Validation System

## Overview

The OpenSpec Validation System is a multi-layered infrastructure that ensures specification files, change artifacts, and project configurations conform to defined schemas and structural requirements. The validation system serves as the quality gate for the entire OpenSpec workflow, preventing malformed specs from entering the repository and maintaining consistency across teams and projects.

The validation system operates at multiple levels: structural validation of markdown content, schema-based validation using Zod, and command-level validation for CLI operations. This layered approach ensures that validation is both comprehensive and performant, catching errors early in the development workflow.

The system is designed to be reusable across different commands and workflows, following the principle established in the implementation order that schemas and validation infrastructure should be shared between command implementations.

## Architecture Overview

```mermaid
graph TD
    A[User/CLI Command] --> B[Validation Entry Point]
    B --> C[Command Validation]
    B --> D[Spec Structure Validation]
    B --> E[Schema Validation]
    
    C --> F[openspec validate]
    C --> G[openspec show --json --deltas-only]
    C --> H[openspec instructions]
    
    D --> I[Markdown Parser]
    D --> J[Spec Structure Parser]
    D --> K[Scenario Parser]
    
    E --> L[Zod Schemas]
    E --> M[Custom Validators]
    
    I --> N[Header Extraction]
    I --> O[Content Normalization]
    J --> P[Requirement Parsing]
    J --> Q[Delta Detection]
    K --> R[WHEN/THEN Format]
    K --> S[Scenario Validation]
    
    L --> T[ArtifactSchema]
    L --> U[SchemaYamlSchema]
    L --> V[ChangeMetadataSchema]
```

## Core Components

### Validation Types (`src/core/validation/types.ts`)

The types module defines the foundational data structures used throughout the validation system. These types are constructed using Zod schemas to enable runtime validation with full type inference.

| Type | Purpose | Key Fields |
|------|---------|------------|
| `ValidationResult` | Encapsulates validation outcome | `valid: boolean`, `errors: ValidationError[]`, `warnings: ValidationWarning[]` |
| `ValidationError` | Represents a validation failure | `code: string`, `message: string`, `path: string`, `line?: number` |
| `SpecRequirement` | Parsed requirement structure | `name: string`, `description: string`, `scenarios: Scenario[]` |
| `Scenario` | Individual test scenario | `name: string`, `when: string`, `then: string[]` |

The type definitions ensure that all validation operations work with consistent data structures, reducing runtime errors and improving developer experience through IDE autocompletion.

### Validation Constants (`src/core/validation/constants.ts`)

Constants define the boundaries and thresholds for validation operations. These values are extracted into a dedicated module to allow easy tuning without modifying validation logic.

```typescript
// Example constant categories
const VALIDATION = {
  MAX_REQUIREMENT_LENGTH: 500,
  MAX_SCENARIO_COUNT: 50,
  MIN_REQUIREMENT_COUNT: 1,
  REQUIRED_HEADERS: ['## Purpose', '## Requirements'],
} as const;

const ERROR_CODES = {
  MISSING_REQUIREMENT: 'SPEC_001',
  MISSING_SCENARIO: 'SPEC_002',
  INVALID_FORMAT: 'SPEC_003',
  CYCLIC_DEPENDENCY: 'GRAPH_001',
  INVALID_DELTA: 'DELTA_001',
} as const;
```

### Core Validator (`src/core/validation/validator.ts`)

The validator module contains the primary validation logic that orchestrates checks across different validation layers. It provides a unified interface for validating various OpenSpec artifacts.

**Key Responsibilities:**

- Coordinating validation across multiple layers (structural, schema, semantic)
- Aggregating errors and warnings from different validators
- Providing detailed error messages with file paths and line numbers
- Supporting both synchronous and asynchronous validation flows

```typescript
// Conceptual validation flow
async function validateSpec(specPath: string): Promise<ValidationResult> {
  const errors: ValidationError[] = [];
  const warnings: ValidationWarning[] = [];
  
  // Layer 1: File existence and readability
  const fileResult = await validateFileAccess(specPath);
  if (!fileResult.valid) return fileResult;
  
  // Layer 2: Structure validation
  const structure = await parseSpecStructure(specPath);
  const structureErrors = validateStructure(structure);
  errors.push(...structureErrors);
  
  // Layer 3: Content validation
  const contentErrors = validateContent(structure);
  errors.push(...contentErrors);
  
  // Layer 4: Cross-reference validation
  const xrefErrors = validateCrossReferences(structure);
  errors.push(...xrefErrors);
  
  return {
    valid: errors.length === 0,
    errors,
    warnings,
  };
}
```

## Spec Structure Validation

### Markdown Parser (`src/core/parsers/spec-structure.ts`)

The spec structure parser extracts structured data from markdown-formatted specification files. It handles the unique requirements of OpenSpec's spec format, including requirement blocks, scenario definitions, and delta operations.

**Parsing Capabilities:**

The parser handles multiple content types found in OpenSpec specifications:

- **Requirements**: Extracted from `### Requirement:` headers with accompanying descriptions
- **Scenarios**: Parsed from `#### Scenario:` headers using WHEN/THEN/AND format
- **Delta Operations**: Identifies ADDED, MODIFIED, REMOVED, and RENAMED sections
- **Frontmatter**: Processes YAML frontmatter for metadata and schema references

**Critical Parsing Rules:**

Per the schema specification, scenario headers must use exactly four hashtags (`####`) followed by `Scenario:`. Using three hashtags or bullet-point formats will result in silent parsing failures.

```typescript
// Scenario detection pattern
const SCENARIO_PATTERN = /^#### Scenario:\s*(.+)$/gm;
const WHEN_PATTERN = /^\*?\*?WHEN\*?\*?\s+(.+)$/im;
const THEN_PATTERN = /^\*?\*?THEN\*?\*?\s+(.+)$/im;
const AND_PATTERN = /^\*?\*?AND\*?\*?\s+(.+)$/im;
```

### Content Normalization

The validation system normalizes input content to handle platform-specific line endings. This is particularly important because different operating systems use different line ending conventions:

- Unix/Linux/macOS: LF (`\n`)
- Windows: CRLF (`\r\n`)
- Legacy systems: CR (`\r`)

The parser normalizes all line endings before processing to ensure consistent behavior regardless of the file's origin.

## Schema Validation

### Zod Integration

OpenSpec uses Zod for schema validation throughout the system. Zod provides runtime type validation with compile-time type inference, eliminating the gap between TypeScript types and runtime behavior.

**Schema Types:**

| Schema | Purpose | Used By |
|--------|---------|---------|
| `ArtifactSchema` | Validates artifact definitions in schema.yaml | Artifact graph loader |
| `SchemaYamlSchema` | Validates entire schema configuration files | Schema initialization |
| `ChangeMetadataSchema` | Validates change folder metadata | Change creation and validation |
| `SpecRequirementSchema` | Validates individual requirements | Spec parsing |

### Schema Loading and Validation

Schemas are loaded from `openspec/schemas/<schema-name>/schema.yaml` and validated against the SchemaYamlSchema before use. This two-stage validation ensures that invalid schema definitions are caught early.

```typescript
// Schema loading flow
async function loadSchema(schemaName: string, projectRoot: string): Promise<SchemaYaml> {
  const schemaPath = getSchemaPath(schemaName, projectRoot);
  const rawYaml = await fs.readFile(schemaPath, 'utf-8');
  const parsed = YAML.parse(rawYaml);
  
  // Validate against schema schema
  const result = SchemaYamlSchema.safeParse(parsed);
  if (!result.success) {
    throw new SchemaValidationError(result.error);
  }
  
  return result.data;
}
```

## Command-Level Validation

### CLI Validate Command (`src/commands/validate.ts`)

The `openspec validate` command provides the primary interface for manual and automated validation of OpenSpec artifacts.

**Usage:**

```bash
openspec validate <change> [--strict]
openspec validate --specs [--all]
openspec validate --changes [--all]
```

**Flags:**

| Flag | Description | Default |
|------|-------------|---------|
| `--strict` | Enable all validation rules including warnings as errors | `false` |
| `--specs` | Validate all specs in the repository | `false` |
| `--changes` | Validate all active changes | `true` |
| `--all` | Include archived items in validation scope | `false` |
| `--json` | Output machine-readable JSON format | `false` |

**Validation Output:**

When validation succeeds, the command outputs a summary table:

```text
✓ Change "add-dark-mode" validated successfully
  - proposal.md: valid
  - specs/auth/spec.md: valid (2 requirements, 5 scenarios)
  - tasks.md: valid (12 tasks)
```

When validation fails, the output includes detailed error information:

```text
✗ Validation failed for "update-auth-flow"
  - specs/auth/spec.md:12
    ERROR [SPEC_002]: Requirement "Legacy export" missing scenario
    HELP: Add at least one scenario using "#### Scenario:" header

  - specs/auth/spec.md:45
    ERROR [SPEC_003]: Invalid WHEN/THEN format
    HELP: Use "**WHEN** condition" and "**THEN** outcome" format
```

## Validation Workflows

### Change Lifecycle Validation

```mermaid
graph LR
    A[Create Change] --> B[Validate Proposal]
    B --> C{Valid?}
    C -->|No| D[Fix Errors]
    D --> B
    C -->|Yes| E[Implement Tasks]
    E --> F[Validate Specs]
    F --> G{Valid?}
    G -->|No| H[Update Specs]
    H --> F
    G -->|Yes| I[Archive Change]
    I --> J[Final Validation]
    J --> K[Merge to Source]
```

### Delta Detection Validation

The validation system extracts deltas from change spec files and validates their structure before applying them to the source specifications. This ensures that only properly formatted changes are merged.

**Delta Types:**

| Delta Type | Syntax | Description |
|------------|--------|-------------|
| ADDED | `## ADDED Requirements` | New requirements being introduced |
| MODIFIED | `## MODIFIED Requirements` | Changes to existing requirements |
| REMOVED | `## REMOVED Requirements` | Requirements being deleted |
| RENAMED | `## RENAMED Requirements` | Requirements being renamed or restructured |

**Delta Extraction Process:**

1. Parse the spec file in the change's `specs/` directory
2. Identify delta section headers using operation prefixes
3. Validate each delta against the appropriate schema
4. Check for conflicts between MODIFIED and REMOVED deltas
5. Generate a validation report with all findings

## Error Handling

### Error Code Reference

| Code | Category | Description | Resolution |
|------|----------|-------------|------------|
| `SPEC_001` | Structure | Missing required requirement | Add requirement with proper `### Requirement:` header |
| `SPEC_002` | Content | Requirement missing scenario | Add `#### Scenario:` with WHEN/THEN format |
| `SPEC_003` | Format | Invalid scenario syntax | Use exact `**WHEN**` and `**THEN**` format |
| `SPEC_004` | Content | Empty requirement description | Provide description after requirement header |
| `GRAPH_001` | Schema | Cyclic dependency detected | Review artifact `requires` field in schema.yaml |
| `GRAPH_002` | Schema | Duplicate artifact ID | Ensure unique IDs in schema definition |
| `DELTA_001` | Delta | Invalid delta operation | Use ADDED, MODIFIED, REMOVED, or RENAMED |
| `DELTA_002` | Delta | Delta references missing spec | Ensure target spec exists in source specs/ |

### Recovery Strategies

The validation system implements graceful degradation for common issues:

**Silent Failures Prevention:**

- Scenario parsing failures are caught and reported explicitly
- Missing headers trigger specific error messages with fix suggestions
- Format violations include the expected format in the error output

**Partial Success Handling:**

When a file contains multiple issues, validation continues to identify all problems rather than failing on the first error. This reduces the number of validation cycles needed to fix all issues.

## Integration with Other Modules

### Project Configuration

The validation system respects project-level configuration defined in `openspec/config.yaml`. Project-specific rules can be configured to add validation constraints beyond the defaults.

```yaml
validation:
  strict: true
  allowedDeltaTypes: [ADDED, MODIFIED, REMOVED]
  requireDesignArtifact: true
```

### Artifact Graph Integration

Validation is integrated with the artifact graph system to validate artifact state transitions and dependency requirements. Before marking an artifact as complete, the validation system verifies all prerequisites are satisfied.

### Change Manager Integration

The change manager uses validation to enforce naming conventions and structural requirements when creating new changes. Invalid change names or structures are rejected at creation time.

## Best Practices

### Writing Valid Specs

1. **Use Exact Headers**: Always use `#### Scenario:` with four hashtags for scenarios
2. **Follow WHEN/THEN Format**: Structure scenarios with clear conditions and outcomes
3. **Include All Scenarios**: Every requirement must have at least one scenario
4. **Use ADDED/MODIFIED/REMOVED**: Prefix delta sections with operation names
5. **Keep Scenarios Testable**: Scenarios should describe observable behavior

### Validation in CI/CD

Integrate validation into continuous integration pipelines:

```yaml
# Example CI configuration
- name: Validate OpenSpec changes
  run: |
    npx openspec validate --changes --strict
```

### Debugging Validation Failures

When validation fails, use the JSON output for programmatic inspection:

```bash
openspec show add-feature --json --deltas-only
```

This outputs the parsed deltas without full change details, helping identify parsing issues.

---

<a id='supported-tools'></a>

## Supported AI Tools

### 相关页面

相关主题：[Slash Commands](#slash-commands)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [docs/supported-tools.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/supported-tools.md)
- [src/core/available-tools.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/available-tools.ts)
- [src/core/command-generation/adapters/index.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/command-generation/adapters/index.ts)
- [README.md](https://github.com/Fission-AI/OpenSpec/blob/main/README.md)
- [CHANGELOG.md](https://github.com/Fission-AI/OpenSpec/blob/main/CHANGELOG.md)
</details>

# Supported AI Tools

OpenSpec is designed to integrate seamlessly with a wide variety of AI coding assistants. The supported AI tools system enables OpenSpec to provide consistent specification workflows across different development environments and toolchains.

## Overview

OpenSpec supports AI tools through a multi-layered integration system that includes:

- **Native Slash Commands**: Built-in commands directly recognized by the AI tool
- **Slash Command Templates**: Tool-specific command files with frontmatter metadata
- **AGENTS.md Compatible**: Workflow instructions that AI tools can automatically discover

资料来源：[README.md:1-100]()

## Architecture

The AI tools integration is built on a modular architecture with three core components:

```mermaid
graph TD
    A[User Request] --> B[OpenSpec CLI]
    B --> C{Determine Tool}
    C --> D[Claude Code]
    C --> E[Cursor]
    C --> F[Codex]
    C --> G[Amazon Q]
    C --> H[Other Tools]
    
    D --> I[Slash Commands]
    E --> J[Cursor Commands]
    F --> K[Codex Commands]
    G --> L[Q Developer Prompts]
    H --> M[AGENTS.md]
    
    I --> N[openspec/proposal<br/>openspec/apply<br/>openspec/archive]
    J --> O[openspec-proposal<br/>openspec-apply<br/>openspec-archive]
```

资料来源：[src/core/command-generation/adapters/index.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/command-generation/adapters/index.ts)

## Supported Tools List

OpenSpec integrates with the following AI coding assistants:

| Tool | Slash Commands | Command Directory | Category |
|------|---------------|-------------------|----------|
| **Claude Code** | `/openspec/proposal`, `/openspec/apply`, `/openspec/archive` | `.claude/commands/openspec/` | Native |
| **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.cursor/commands/` | Native |
| **CodeBuddy Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | `.codebuddy/commands/` | Native |
| **Amazon Q Developer** | `@openspec-proposal`, `@openspec-apply`, `@openspec-archive` | `.amazonq/prompts/` | Native |
| **Windsurf** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.windsurf/workflows/` | Native |
| **RooCode** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.roo/commands/` | Native |
| **Augment CLI** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.augment/commands/` | Native |
| **Antigravity** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | `.agent/workflows/` | Native |
| **Cline** | Workflows in `.clinerules/workflows/` | `.clinerules/workflows/openspec-*.md` | Native |
| **Kilo Code** | Command palette triggers | `.kilocode/workflows/` | Native |
| **Gemini CLI** | TOML-based commands | `.gemini/commands/openspec/` | Native |
| **Qwen Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | — | Native |
| **CoStrict AI** | — | — | Native |
| **Qoder CLI** | — | — | Native |
| **Continue** | `/openspec-proposal.md`, `/openspec-apply.md`, `/openspec-archive.md` | `.continue/prompts/` | Native |

资料来源：[docs/supported-tools.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/supported-tools.md)

## Tool Categories

### Native Slash Commands

Tools with native slash command support have built-in OpenSpec commands. When initializing OpenSpec for these tools, select the appropriate integration option.

```mermaid
graph LR
    A[openspec init] --> B[Select Tool]
    B --> C[Claude Code]
    B --> D[Cursor]
    B --> E[Windsurf]
    
    C --> F[Creates: .claude/commands/openspec/]
    D --> G[Creates: .cursor/commands/]
    E --> H[Creates: .windsurf/workflows/]
```

资料来源：[README.md:150-200]()

### AGENTS.md Compatible

Some tools automatically read workflow instructions from `openspec/AGENTS.md`. These tools can be instructed to follow the OpenSpec workflow using natural language.

| Tool | Support Level |
|------|---------------|
| Amp | Compatible |
| Jules | Compatible |
| Others | Via AGENTS.md convention |

资料来源：[README.md:200-250]()

## Command Structure

### Slash Command Format

Commands follow a consistent pattern across tools but with tool-specific adaptations:

```markdown
---
name: openspec-proposal
description: Create a new OpenSpec change proposal
category: OpenSpec
---
<!-- OPENSPEC:START -->
...command body...
<!-- OPENSPEC:END -->
```

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)

### Command Naming Conventions

| Tool | Naming Style | Example |
|------|-------------|---------|
| Claude Code | Namespaced with `/` | `/openspec/proposal` |
| Cursor | Flat with `openspec-` prefix | `/openspec-proposal` |
| Windsurf | Flat with `openspec-` prefix | `/openspec-proposal` |
| RooCode | Flat with `openspec-` prefix | `/openspec-proposal` |
| Gemini CLI | TOML-based configuration | — |

### Marker Placement Rules

Commands must follow strict marker placement rules:

1. **Frontmatter goes first** (if supported by the tool)
2. **`<!-- OPENSPEC:START -->`** marker opens the body
3. Command body content follows
4. **`<!-- OPENSPEC:END -->`** marker closes the body

```markdown
---
name: openspec-apply
description: Apply OpenSpec change tasks
category: OpenSpec
---
<!-- OPENSPEC:START -->
Step-by-step instructions for applying tasks...
<!-- OPENSPEC:END -->
```

**Critical**: Markers must never be placed inside the YAML frontmatter block.

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/design.md)

## Configuration

### Tool Configuration Interface

The `AIToolOption` interface defines how tools are configured:

| Field | Type | Description |
|-------|------|-------------|
| `id` | `string` | Unique identifier for the tool |
| `name` | `string` | Display name |
| `skillsDir` | `string` | Path to tool's skill/command directory |
| `commandPrefix` | `string` | Prefix for slash commands |
| `frontmatterFormat` | `string` | Supported frontmatter type |

资料来源：[src/core/available-tools.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/available-tools.ts)

### Command Generation Adapters

The adapter pattern allows OpenSpec to generate tool-specific command files:

```mermaid
classDiagram
    class ToolCommandAdapter {
        +generate(content: CommandContent): string
        +getFilePath(toolId: string): string
        +supportsFrontmatter(): boolean
    }
    
    class CommandContent {
        +id: string
        +name: string
        +description: string
        +body: string
    }
    
    class CommandGenerator {
        +generateAll(content: CommandContent, toolId: string)
        +updateExisting(content: CommandContent, toolId: string)
    }
    
    CommandGenerator --> ToolCommandAdapter
    CommandGenerator --> CommandContent
```

资料来源：[src/core/command-generation/adapters/index.ts](https://github.com/Fission-AI/OpenSpec/blob/main/src/core/command-generation/adapters/index.ts)

## Initialization Workflow

When running `openspec init`, the CLI performs the following steps:

```mermaid
graph TD
    A[openspec init] --> B{Interactive or --tool flag?}
    B -->|Interactive| C[Prompt for tool selection]
    B -->|--tool| D[Use specified tool]
    
    C --> E[Select from available tools]
    D --> F[Validate tool ID]
    
    E --> G[Create tool directories]
    F --> G
    G --> H[Generate command files]
    H --> I[Apply OPENSPEC markers]
    I --> J[Confirmation message]
```

### Idempotency Rules

| Operation | Behavior |
|-----------|----------|
| `init` | Create all command files once; subsequent runs are no-ops for existing files |
| `update` | Refresh only existing files; do not create missing files |

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/design.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/design.md)

## Adding New Tool Support

### Design Pattern

To add support for a new AI tool, implement the following:

1. **Create a tool adapter** in `src/core/command-generation/adapters/`
2. **Define tool configuration** in `src/core/available-tools.ts`
3. **Add command templates** for proposal, apply, and archive actions
4. **Update documentation** in `docs/supported-tools.md`

### Example Adapter Structure

```typescript
// src/core/command-generation/adapters/newtool-adapter.ts
import { ToolCommandAdapter } from './base';

export class NewToolAdapter implements ToolCommandAdapter {
  supportsFrontmatter(): boolean {
    return true;
  }
  
  getFilePath(): string {
    return '.newtool/commands/openspec';
  }
  
  generate(content: CommandContent): string {
    return this.wrapWithMarkers(content.body);
  }
}
```

### Testing Strategy

| Test Type | Purpose |
|-----------|---------|
| Golden snapshots | Verify generated files per tool (frontmatter + markers + body) |
| Partial presence tests | Ensure `update` only refreshes existing files |
| Marker placement tests | Verify markers never appear inside frontmatter |
| Logging tests | Confirm `update` reports per-file results |

资料来源：[openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md](https://github.com/Fission-AI/OpenSpec/blob/main/openspec/changes/archive/2025-09-29-add-slash-command-support/proposal.md)

## Version History

### Version 1.3.0+
Added support for:
- Gemini CLI with native TOML-based slash command support
- RooCode integration with full configurator support
- Cline workflows (moved from `.clinerules/rules/` to `.clinerules/workflows/`)
- Continue prompt generation with MARKDOWN frontmatter and `$ARGUMENTS` placeholder

资料来源：[CHANGELOG.md](https://github.com/Fission-AI/OpenSpec/blob/main/CHANGELOG.md)

### Version 0.15.0+
Added support for:
- Gemini CLI
- RooCode
- Cline (workflows)
- Qwen Code
- Qoder CLI
- CoStrict AI

### Version 0.14.0+
Added support for:
- Qwen Code with slash command integration
- `$ARGUMENTS` support in apply slash command
- Qoder CLI support

## Troubleshooting

### Commands Not Appearing

If slash commands are not appearing:

1. Verify the tool directory exists: `.claude/commands/openspec/`
2. Check file naming matches expected pattern
3. Run `openspec update` to refresh command files
4. Restart the AI tool to reload commands

### Marker Errors

If you see parsing errors:

- Ensure `<!-- OPENSPEC:START -->` and `<!-- OPENSPEC:END -->` are on separate lines
- Verify markers are not inside YAML frontmatter
- Check for duplicate markers in the file

### Tool Not Recognized

For unsupported tools:

- Use `AGENTS.md` convention for workflow discovery
- Run `openspec init` to see all available tool options
- Check [docs/supported-tools.md](https://github.com/Fission-AI/OpenSpec/blob/main/docs/supported-tools.md) for the latest supported list

## See Also

- [Getting Started](docs/getting-started.md) - First steps with OpenSpec
- [Workflows](docs/workflows.md) - Combos and patterns
- [Commands](docs/commands.md) - Slash commands and skills reference
- [Customization](docs/customization.md) - Making OpenSpec yours

---

---

## Doramagic 踩坑日志

项目：Fission-AI/OpenSpec

摘要：发现 22 个潜在踩坑项，其中 3 个为 high/blocking；最高优先级：安装坑 - 来源证据：/opsx:apply suggests openspec-continue-change which is not installed on core profile。

## 1. 安装坑 · 来源证据：/opsx:apply suggests openspec-continue-change which is not installed on core profile

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：/opsx:apply suggests openspec-continue-change which is not installed on core profile
- 对用户的影响：可能阻塞安装或首次运行。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_41aca88207aa4e70bba9c2ebaef629c7 | https://github.com/Fission-AI/OpenSpec/issues/963 | 来源类型 github_issue 暴露的待验证使用条件。

## 2. 配置坑 · 来源证据：Support schema extension or partial overrides to avoid full shadowing of built-in schemas

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：Support schema extension or partial overrides to avoid full shadowing of built-in schemas
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_34110f57274440d4bbc5492e3b4f3bee | https://github.com/Fission-AI/OpenSpec/issues/1074 | 来源类型 github_issue 暴露的待验证使用条件。

## 3. 维护坑 · 来源证据：open:sync messed up my spec.md files

- 严重度：high
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：open:sync messed up my spec.md files
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_ef1856d2856b49f5a7ed758bfc4099c8 | https://github.com/Fission-AI/OpenSpec/issues/911 | 来源类型 github_issue 暴露的待验证使用条件。

## 4. 安装坑 · 来源证据：Codex generated assets reference unsupported AskUserQuestion/TodoWrite/Task tools

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：Codex generated assets reference unsupported AskUserQuestion/TodoWrite/Task tools
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_35b315a2b1a74564be1fb71d1f08359c | https://github.com/Fission-AI/OpenSpec/issues/1103 | 来源讨论提到 node 相关条件，需在安装/试用前复核。

## 5. 安装坑 · 来源证据：First steps don't work

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：First steps don't work
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_51f62d023b734ba59978cc70908c01c3 | https://github.com/Fission-AI/OpenSpec/issues/820 | 来源类型 github_issue 暴露的待验证使用条件。

## 6. 安装坑 · 来源证据：v1.1.0 - Cross-Platform Fixes, Nix Improvements

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：v1.1.0 - Cross-Platform Fixes, Nix Improvements
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_016f567cecd44fbf96ffd635e1ec43bf | https://github.com/Fission-AI/OpenSpec/releases/tag/v1.1.0 | 来源讨论提到 node 相关条件，需在安装/试用前复核。

## 7. 安装坑 · 来源证据：v1.3.1 - Path & Telemetry Fixes

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安装相关的待验证问题：v1.3.1 - Path & Telemetry Fixes
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_e641868122bb43938d6ff8a83b71e3d3 | https://github.com/Fission-AI/OpenSpec/releases/tag/v1.3.1 | 来源讨论提到 windows 相关条件，需在安装/试用前复核。

## 8. 配置坑 · 来源证据：Incomplete artifacts marked as "done" after workflow interruption

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：Incomplete artifacts marked as "done" after workflow interruption
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_a0677545a17b433ca6e6561c5056ee46 | https://github.com/Fission-AI/OpenSpec/issues/1084 | 来源类型 github_issue 暴露的待验证使用条件。

## 9. 配置坑 · 来源证据：OpenCode sync missing

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：OpenCode sync missing
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_0076a9fb05a1443eb3e2a7c9185247e6 | https://github.com/Fission-AI/OpenSpec/issues/1007 | 来源类型 github_issue 暴露的待验证使用条件。

## 10. 配置坑 · 来源证据：v0.22.0 - Project Configuration

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：v0.22.0 - Project Configuration
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_1a526029491b40e38c20ba075f311169 | https://github.com/Fission-AI/OpenSpec/releases/tag/v0.22.0 | 来源类型 github_release 暴露的待验证使用条件。

## 11. 配置坑 · 来源证据：v1.0.0 - The OPSX Release

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个配置相关的待验证问题：v1.0.0 - The OPSX Release
- 对用户的影响：可能影响升级、迁移或版本选择。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_b60a0c136c0347e9a034197f65844e1b | https://github.com/Fission-AI/OpenSpec/releases/tag/v1.0.0 | 来源类型 github_release 暴露的待验证使用条件。

## 12. 能力坑 · 能力判断依赖假设

- 严重度：medium
- 证据强度：source_linked
- 发现：README/documentation is current enough for a first validation pass.
- 对用户的影响：假设不成立时，用户拿不到承诺的能力。
- 建议检查：将假设转成下游验证清单。
- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。
- 证据：capability.assumptions | github_repo:1032459340 | https://github.com/Fission-AI/OpenSpec | README/documentation is current enough for a first validation pass.

## 13. 运行坑 · 来源证据：v1.0.1

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个运行相关的待验证问题：v1.0.1
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_006cb659e21c431290fe448ddabc453c | https://github.com/Fission-AI/OpenSpec/releases/tag/v1.0.1 | 来源类型 github_release 暴露的待验证使用条件。

## 14. 运行坑 · 来源证据：v1.0.2

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个运行相关的待验证问题：v1.0.2
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_c7797487985047fba066bd58cba094ae | https://github.com/Fission-AI/OpenSpec/releases/tag/v1.0.2 | 来源类型 github_release 暴露的待验证使用条件。

## 15. 维护坑 · 来源证据：Feedback: Deep verification test - PUA mode v3 active

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：Feedback: Deep verification test - PUA mode v3 active
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_d3d2fc07081648f796e477458600a95f | https://github.com/Fission-AI/OpenSpec/issues/1094 | 来源类型 github_issue 暴露的待验证使用条件。

## 16. 维护坑 · 维护活跃度未知

- 严重度：medium
- 证据强度：source_linked
- 发现：未记录 last_activity_observed。
- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。
- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。
- 证据：evidence.maintainer_signals | github_repo:1032459340 | https://github.com/Fission-AI/OpenSpec | last_activity_observed missing

## 17. 安全/权限坑 · 下游验证发现风险项

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：下游已经要求复核，不能在页面中弱化。
- 建议检查：进入安全/权限治理复核队列。
- 防护动作：下游风险存在时必须保持 review/recommendation 降级。
- 证据：downstream_validation.risk_items | github_repo:1032459340 | https://github.com/Fission-AI/OpenSpec | no_demo; severity=medium

## 18. 安全/权限坑 · 存在评分风险

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：风险会影响是否适合普通用户安装。
- 建议检查：把风险写入边界卡，并确认是否需要人工复核。
- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。
- 证据：risks.scoring_risks | github_repo:1032459340 | https://github.com/Fission-AI/OpenSpec | no_demo; severity=medium

## 19. 安全/权限坑 · 来源证据：Protect OpenSpec from AI slop PRs

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Protect OpenSpec from AI slop PRs
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_a941eca296774492b16583764132d1f8 | https://github.com/Fission-AI/OpenSpec/issues/1087 | 来源类型 github_issue 暴露的待验证使用条件。

## 20. 安全/权限坑 · 来源证据：[Feature Request/Suggestion] Extension to package for custom schemas, associated skills, commands, hooks, and profiles

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：[Feature Request/Suggestion] Extension to package for custom schemas, associated skills, commands, hooks, and profiles
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 建议检查：来源问题仍为 open，Pack Agent 需要复核是否仍影响当前版本。
- 防护动作：不得脱离来源链接放大为确定性结论；需要标注适用版本和复核状态。
- 证据：community_evidence:github | cevd_abcb3cf5661b4a19862619c854eb531d | https://github.com/Fission-AI/OpenSpec/issues/1081 | 来源类型 github_issue 暴露的待验证使用条件。

## 21. 维护坑 · issue/PR 响应质量未知

- 严重度：low
- 证据强度：source_linked
- 发现：issue_or_pr_quality=unknown。
- 对用户的影响：用户无法判断遇到问题后是否有人维护。
- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。
- 防护动作：issue/PR 响应未知时，必须提示维护风险。
- 证据：evidence.maintainer_signals | github_repo:1032459340 | https://github.com/Fission-AI/OpenSpec | issue_or_pr_quality=unknown

## 22. 维护坑 · 发布节奏不明确

- 严重度：low
- 证据强度：source_linked
- 发现：release_recency=unknown。
- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。
- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。
- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。
- 证据：evidence.maintainer_signals | github_repo:1032459340 | https://github.com/Fission-AI/OpenSpec | release_recency=unknown

<!-- canonical_name: Fission-AI/OpenSpec; human_manual_source: deepwiki_human_wiki -->
