Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion openspec/specs/schema-init-command/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## Purpose
Define `openspec schema init` behavior for creating project-local schema skeletons in interactive and non-interactive modes.

## Requirements
### Requirement: Schema init command creates project-local schema
The CLI SHALL provide an `openspec schema init <name>` command that creates a new schema directory under `openspec/schemas/<name>/` with a valid `schema.yaml` file and default template files.
Expand Down Expand Up @@ -74,3 +73,23 @@ The CLI SHALL support `--json` flag for machine-readable output.
- **THEN** system outputs JSON with `error` field describing the issue
- **AND** exits with non-zero code

### Requirement: Schema init validates artifacts before forced replacement
The CLI SHALL validate all requested artifact IDs before replacing an existing project-local schema. If artifact validation fails, the CLI SHALL leave the existing schema directory and all of its contents unchanged on every supported platform.

#### Scenario: Unknown artifact preserves existing schema
- **GIVEN** `openspec/schemas/tdd-driven/` already exists with user-authored files
- **WHEN** the user runs `schema init tdd-driven` with `--force` and an artifact list containing the unknown ID `task`
- **THEN** the command exits with a non-zero status and reports the unknown artifact
- **AND** the existing `tdd-driven` schema directory and its contents remain unchanged

#### Scenario: Unknown artifact preserves a schema at a Windows project path
- **GIVEN** an existing project-local schema is resolved from a Windows filesystem path
- **WHEN** forced schema initialization fails artifact validation
- **THEN** the resolved schema directory and its contents remain unchanged

#### Scenario: Valid artifacts allow forced replacement
- **GIVEN** a project-local schema already exists
- **WHEN** the user runs `schema init` with `--force` and only valid artifact IDs
- **THEN** the command replaces the existing schema with the newly generated schema
- **AND** reports successful creation

Loading