1# Agent OpenSpec Tools Delta23## MODIFIED Requirements45### Requirement: Spec lifecycle tools6The plugin SHALL provide filesystem-backed tools for creating, reading, and listing specs so agents can manage specs as first-class artifacts without the OpenSpec CLI binary.78#### Scenario: Create a baseline spec9- **GIVEN** a project with an `openspec/specs/` directory10- **WHEN** an agent calls `openspec_spec_create` with a spec name, title, purpose, and requirements array (each with name, description, and optional scenarios)11- **THEN** the tool writes a properly formatted `openspec/specs/<name>/spec.md` using `### Requirement:` and `#### Scenario:` markdown and returns `ok: true` with the spec name and relative path1213#### Scenario: Create a change-scoped spec14- **GIVEN** a project with an active change15- **WHEN** an agent calls `openspec_spec_create` with a `change` parameter and a spec name16- **THEN** the tool writes the spec under `openspec/changes/<change>/specs/<name>/spec.md` instead of the baseline directory1718#### Scenario: Refuse to overwrite existing spec19- **GIVEN** a spec already exists at the target path20- **WHEN** an agent calls `openspec_spec_create` without a `force` flag21- **THEN** the tool returns `ok: false` and does not modify the existing file2223#### Scenario: Show a spec as structured JSON24- **WHEN** an agent calls `openspec_spec_show` with a spec name and optional `change` id25- **THEN** the tool reads and parses the spec using `spec_parser.parse_spec` and returns `ok: true` with the title, purpose, and an array of requirements (each with name, description, and scenarios)2627#### Scenario: Show missing spec28- **WHEN** an agent calls `openspec_spec_show` for a spec that does not exist29- **THEN** the tool returns `ok: false` with a clear error3031#### Scenario: List baseline specs32- **WHEN** an agent calls `openspec_spec_list` without a `change` parameter33- **THEN** the tool returns `ok: true` with an array of spec names found under `openspec/specs/`3435#### Scenario: List change-scoped specs36- **WHEN** an agent calls `openspec_spec_list` with a `change` parameter37- **THEN** the tool returns `ok: true` with an array of spec names found under `openspec/changes/<change>/specs/`3839#### Scenario: List specs when none exist40- **GIVEN** the target specs directory is empty or missing41- **WHEN** an agent calls `openspec_spec_list`42- **THEN** the tool returns `ok: true` with an empty array4344#### Scenario: Invalid workdir45- **WHEN** any spec tool is called with a missing or non-directory workdir46- **THEN** the tool returns `ok: false` and does not perform filesystem operations