Skip to content

Commit 68fc049

Browse files
committed
docs(changes): use proposal/apply/archive names and per-tool slash naming; add format examples and test guidance
1 parent 4874a16 commit 68fc049

File tree

4 files changed

+105
-33
lines changed

4 files changed

+105
-33
lines changed

openspec/changes/add-slash-command-support/proposal.md

Lines changed: 98 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,118 @@
22

33
## Summary
44
- Enable OpenSpec to generate and update custom slash commands for supported coding agents (Claude Code and Cursor).
5-
- Provide three slash commands aligned with OpenSpec's workflow: create a change, implement a change, and archive a change.
5+
- Provide three slash commands aligned with OpenSpec's workflow: proposal (start a change proposal), apply (implement), and archive.
66
- Share slash command templating between agents to make future extensions simple.
77

88
## Motivation
99
Developers use different coding agents and editors. Having consistent slash commands across tools for the OpenSpec workflow reduces friction and ensures a standard way to trigger the workflow. Supporting both Claude Code and Cursor now lays a foundation for future agents that introduce slash command features.
1010

1111
## Proposal
12-
1. During `openspec init`, when a user selects a supported tool, generate slash command configuration for:
13-
- `/create-change` – scaffold a new OpenSpec change proposal.
14-
- `/implement-change` – walk through tasks in an approved change.
15-
- `/archive-change` – guide the user through archiving a completed change.
16-
- Each command file MUST provide step-by-step instructions pulled from `openspec/README.md` so the coding agent knows how to execute the corresponding workflow stage:
17-
- `/create-change` files explain how to pick a change ID, scaffold `proposal.md`, `tasks.md`, and delta specs, then run `openspec validate <change-id> --strict`.
18-
- `/implement-change` files instruct the agent to read the proposal, design, and tasks, complete tasks sequentially while marking them done, and validate with `openspec validate`.
19-
- `/archive-change` files outline moving the change to the archive directory, updating specs if needed, and using `openspec archive <change-id>`.
20-
2. Store slash command definitions as Markdown files in tool-specific directories:
21-
- Claude Code: `.claude/commands/openspec/{create-change,implement-change,archive-change}.md`
22-
- Cursor: `.cursor/commands/{create-change,implement-change,archive-change}.md`
23-
3. Centralize slash command templates so the text for each command is defined once and reused across agents.
24-
4. During `openspec update`, update existing slash command files within marker blocks without creating new files for tools that are not already configured.
12+
1. During `openspec init`, when a user selects a supported tool, generate slash command configuration for three OpenSpec workflow stages:
13+
- Claude (namespaced): `/openspec/proposal`, `/openspec/apply`, `/openspec/archive`.
14+
- Cursor (flat, prefixed): `/openspec-proposal`, `/openspec-apply`, `/openspec-archive`.
15+
- Semantics:
16+
- Create – scaffold a change (ID, `proposal.md`, `tasks.md`, delta specs); validate strictly.
17+
- Apply – implement an approved change; complete tasks; validate strictly.
18+
- Archive – archive after deployment; update specs if needed.
19+
- Each command file MUST embed concise, step-by-step instructions sourced from `openspec/README.md` (see Template Content section).
20+
2. Store slash command files per tool:
21+
- Claude Code: `.claude/commands/openspec/{proposal,apply,archive}.md`
22+
- Cursor: `.cursor/commands/{openspec-proposal,openspec-apply,openspec-archive}.md`
23+
- Ensure nested directories are created.
24+
3. Command file format and metadata:
25+
- Use Markdown with optional YAML frontmatter for tool metadata (name/title, description, category/tags) when supported by the tool.
26+
- Place OpenSpec markers around the body only, never inside frontmatter.
27+
- Keep the visible slash name, file name, and any frontmatter `name`/`id` consistently aligned (e.g., `proposal`, `openspec-proposal`).
28+
- Namespacing: categorize these under “OpenSpec” and prefer unique IDs (e.g., `openspec-proposal`) to avoid collisions.
29+
4. Centralize templates: define command bodies once and reuse across tools; apply minimal per-tool wrappers (frontmatter, categories, filenames).
30+
5. During `openspec update`, refresh only existing slash command files (per-file basis) within markers; do not create missing files or new tools.
2531

2632
## Design Ideas
27-
- Introduce a `SlashCommandConfigurator` base that mirrors the existing AI tool configurators.
28-
- Each tool-specific configurator supplies file paths and any platform-specific metadata while reusing shared command templates.
29-
- Command templates live in the TemplateManager for centralized maintenance.
30-
- Register slash command configurators alongside existing tool configurators so both `init` and `update` commands can iterate over them.
33+
- Introduce `SlashCommandConfigurator` to manage multiple files per tool.
34+
- Expose targets rather than a single `configFileName` (e.g., `getTargets(): Array<{ path: string; kind: 'slash'; id: string }>`).
35+
- Provide `generateAll(projectPath, openspecDir)` for init and `updateExisting(projectPath, openspecDir)` for update.
36+
- Per-tool adapters add only frontmatter and pathing; bodies come from shared templates.
37+
- Templates live in `TemplateManager` with helpers that extract concise, authoritative snippets from `openspec/README.md`.
38+
- Update flow logs per-file results so users see exactly which slash files were refreshed.
39+
40+
### Marker Placement
41+
- Markers MUST wrap only the Markdown body contents:
42+
- Frontmatter (if present) goes first.
43+
- Then `<!-- OPENSPEC:START -->` … body … `<!-- OPENSPEC:END -->`.
44+
- Avoid inserting markers into the YAML block to prevent parse errors.
45+
46+
### Idempotency and Creation Rules
47+
- `init`: create all three files for the chosen tool(s) once; subsequent `init` runs are no-ops for existing files.
48+
- `update`: refresh only files that exist; skip missing ones without creating new files.
49+
- Directory creation for `.claude/commands/openspec/` and `.cursor/commands/` is the configurator’s responsibility.
50+
51+
### Command Naming & UX
52+
- Claude Code: use namespacing in the slash itself for readability and grouping: `/openspec/proposal`, `/openspec/apply`, `/openspec/archive`.
53+
- Cursor: use flat names with an `openspec-` prefix: `/openspec-proposal`, `/openspec-apply`, `/openspec-archive`. Group via `category: OpenSpec` when supported.
54+
- Consistency: align file names, visible slash names, and any frontmatter `id` (e.g., `id: openspec-apply`).
55+
- Migration: do not rename existing commands during `update`; apply new naming only on `init` (or via an explicit migrate step).
3156

3257
## Open Questions
33-
- Determine whether marker-based updates are supported in each tool's configuration format or if whole-file replacement is acceptable.
34-
- Evaluate whether additional commands beyond the initial three should be generated by default.
58+
- Validate exact metadata/frontmatter supported by each tool version; if unsupported, omit frontmatter and ship Markdown body only.
59+
- Confirm the final Cursor command file location for the targeted versions; fall back to Markdown-only if Cursor does not parse frontmatter.
60+
- Evaluate additional commands beyond the initial three (e.g., `/show-change`, `/validate-all`) based on user demand.
3561

3662
## Alternatives
37-
- Hard-code slash command text separately for each tool (rejected: duplicates templates and makes future maintenance harder).
38-
- Delay Cursor support until its API stabilizes (rejected: adding initial support encourages early feedback).
63+
- Hard-code slash command text per tool (rejected: duplicates content; increases maintenance).
64+
- Delay Cursor support until its config stabilizes (partial accept): gate Cursor behind a feature flag until verified in real environments.
3965

4066
## Risks
41-
- Tool vendors may change their configuration formats, requiring updates to our templates.
42-
- Incorrect file paths could lead to commands not appearing; extra validation may be required.
67+
- Tool configuration formats may change, requiring updates to wrappers/frontmatter.
68+
- Incorrect paths or categories can hide commands; add path existence checks and clear logging.
69+
- Marker misuse (inside frontmatter) can break parsing; enforce placement rules in tests.
4370

4471
## Future Work
4572
- Support additional editors/agents that expose slash command APIs.
46-
- Allow users to customize command prompts during `openspec init`.
47-
- Provide a command to regenerate slash commands without running full `update`.
73+
- Allow users to customize command names and categories during `openspec init`.
74+
- Provide a dedicated command to regenerate slash commands without running full `update`.
75+
76+
## File Format Examples
77+
The following examples illustrate expected structure. If a tool does not support frontmatter, omit the YAML block and keep only the markers + body.
78+
79+
### Claude Code: `.claude/commands/openspec/proposal.md`
80+
```markdown
81+
---
82+
name: OpenSpec: Proposal
83+
description: Scaffold a new OpenSpec change and validate strictly.
84+
category: OpenSpec
85+
tags: [openspec, change]
86+
---
87+
<!-- OPENSPEC:START -->
88+
...command body from shared template...
89+
<!-- OPENSPEC:END -->
90+
```
91+
92+
Slash invocation: `/openspec/proposal` (namespaced)
93+
94+
### Cursor: `.cursor/commands/openspec-proposal.md`
95+
```markdown
96+
---
97+
name: /openspec-proposal
98+
id: openspec-proposal
99+
category: OpenSpec
100+
description: Scaffold a new OpenSpec change and validate strictly.
101+
---
102+
<!-- OPENSPEC:START -->
103+
...command body from shared template...
104+
<!-- OPENSPEC:END -->
105+
```
106+
107+
Slash invocation: `/openspec-proposal` (flat, prefixed)
108+
109+
## Template Content
110+
Templates should be brief, actionable, and sourced from `openspec/README.md` to avoid duplication. Each command body includes:
111+
- Guardrails: ask 1–2 clarifying questions if needed; follow minimal-complexity rules; use `pnpm` for Node projects.
112+
- Step list tailored to the workflow stage (proposal, apply, archive), including strict validation commands.
113+
- Pointers to `openspec show`, `openspec list`, and troubleshooting tips when validation fails.
114+
115+
## Testing Strategy
116+
- Golden snapshots for generated files per tool (frontmatter + markers + body).
117+
- Partial presence tests: if 1–2 files exist, `update` only refreshes those and does not create missing ones.
118+
- Marker placement tests: ensure markers never appear inside frontmatter; cover missing/duplicated marker recovery behavior.
119+
- Logging tests: `update` reports per-file updates for slash commands.

openspec/changes/add-slash-command-support/specs/cli-init/spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ The init command SHALL generate slash command files for supported editors using
44

55
#### Scenario: Generating slash commands for Claude Code
66
- **WHEN** the user selects Claude Code during initialization
7-
- **THEN** create `.claude/commands/openspec/create-change.md`, `.claude/commands/openspec/implement-change.md`, and `.claude/commands/openspec/archive-change.md`
7+
- **THEN** create `.claude/commands/openspec/proposal.md`, `.claude/commands/openspec/apply.md`, and `.claude/commands/openspec/archive.md`
88
- **AND** populate each file from shared templates so command text matches other tools
99
- **AND** each template includes instructions for the relevant OpenSpec workflow stage
1010

1111
#### Scenario: Generating slash commands for Cursor
1212
- **WHEN** the user selects Cursor during initialization
13-
- **THEN** create `.cursor/commands/create-change.md`, `.cursor/commands/implement-change.md`, and `.cursor/commands/archive-change.md`
13+
- **THEN** create `.cursor/commands/openspec-proposal.md`, `.cursor/commands/openspec-apply.md`, and `.cursor/commands/openspec-archive.md`
1414
- **AND** populate each file from shared templates so command text matches other tools
1515
- **AND** each template includes instructions for the relevant OpenSpec workflow stage

openspec/changes/add-slash-command-support/specs/cli-update/spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
The update command SHALL refresh existing slash command files for configured tools without creating new ones.
44

55
#### Scenario: Updating slash commands for Claude Code
6-
- **WHEN** `.claude/commands/openspec/` contains `create-change.md`, `implement-change.md`, and `archive-change.md`
6+
- **WHEN** `.claude/commands/openspec/` contains `proposal.md`, `apply.md`, and `archive.md`
77
- **THEN** refresh each file using shared templates
88
- **AND** ensure templates include instructions for the relevant workflow stage
99

1010
#### Scenario: Updating slash commands for Cursor
11-
- **WHEN** `.cursor/commands/` contains `create-change.md`, `implement-change.md`, and `archive-change.md`
11+
- **WHEN** `.cursor/commands/` contains `openspec-proposal.md`, `openspec-apply.md`, and `openspec-archive.md`
1212
- **THEN** refresh each file using shared templates
1313
- **AND** ensure templates include instructions for the relevant workflow stage
1414

openspec/changes/add-slash-command-support/tasks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Implementation Tasks
22

33
## 1. Templates and Configurators
4-
- [ ] 1.1 Create shared templates for `/create-change`, `/implement-change`, and `/archive-change` commands with instructions for each workflow stage from `openspec/README.md`.
4+
- [ ] 1.1 Create shared templates for the Proposal, Apply, and Archive commands with instructions for each workflow stage from `openspec/README.md`.
55
- [ ] 1.2 Implement a `SlashCommandConfigurator` base and tool-specific configurators for Claude Code and Cursor.
66

77
## 2. Claude Code Integration
8-
- [ ] 2.1 Generate `.claude/commands/openspec/{create-change,implement-change,archive-change}.md` during `openspec init` using shared templates.
8+
- [ ] 2.1 Generate `.claude/commands/openspec/{proposal,apply,archive}.md` during `openspec init` using shared templates.
99
- [ ] 2.2 Update existing `.claude/commands/openspec/*` files during `openspec update`.
1010

1111
## 3. Cursor Integration
12-
- [ ] 3.1 Generate `.cursor/commands/{create-change,implement-change,archive-change}.md` during `openspec init` using shared templates.
12+
- [ ] 3.1 Generate `.cursor/commands/{openspec-proposal,openspec-apply,openspec-archive}.md` during `openspec init` using shared templates.
1313
- [ ] 3.2 Update existing `.cursor/commands/*` files during `openspec update`.
1414

1515
## 4. Verification

0 commit comments

Comments
 (0)