diff --git a/.github/workflows/polish-release-notes.yml b/.github/workflows/polish-release-notes.yml deleted file mode 100644 index a58e42bcc..000000000 --- a/.github/workflows/polish-release-notes.yml +++ /dev/null @@ -1,149 +0,0 @@ -name: Polish Release Notes - -# Uses Claude to transform raw changelog into polished release notes. -# Triggered automatically by release-prepare after publishing, or manually. -on: - repository_dispatch: - types: [polish-release-notes] - workflow_dispatch: - inputs: - tag_name: - description: 'Release tag to polish (e.g., v0.18.0)' - required: true - type: string - -env: - # repository_dispatch passes tag via client_payload, workflow_dispatch via inputs - TAG_NAME: ${{ github.event.client_payload.tag_name || inputs.tag_name }} - -permissions: - contents: write - -jobs: - polish: - # Only run on the main repo, not forks - if: github.repository == 'Fission-AI/OpenSpec' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Get current release body - id: get-release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh release view "${{ env.TAG_NAME }}" --json body -q '.body' > current-notes.md - echo "Fetched release notes for ${{ env.TAG_NAME }}" - - - name: Transform release notes with Claude - uses: anthropics/claude-code-action@v1 - id: claude - with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - github_token: ${{ secrets.GITHUB_TOKEN }} - claude_args: "--allowedTools Write,Read" - prompt: | - Transform the changelog in `current-notes.md` into release notes for OpenSpec ${{ env.TAG_NAME }}. - - ## Voice - - OpenSpec is a developer tool. Write like you're talking to a peer: - - Direct and practical, not marketing copy - - Focus on what changed and why it matters - - Skip the hype, keep it real - - ## Output - - Create two files: - - ### 1. `release-title.txt` - - A short title in this format: - ``` - ${{ env.TAG_NAME }} - [1-4 words describing the release] - ``` - - Examples: - - `v0.18.0 - OPSX Experimental Workflow` - - `v0.16.0 - Antigravity, iFlow Support` - - `v0.15.0 - Gemini CLI, RooCode` - - Rules for title: - - Lead with the most notable addition - - 1-4 words after the dash, no fluff - - If multiple features, comma-separate the top 2 - - For bugfix-only releases, use something like `v0.17.2 - Pre-commit Hook Fix` - - ### 2. `polished-notes.md` - - ```markdown - ## What's New in ${{ env.TAG_NAME }} - - [One sentence: what's the theme of this release?] - - ### New - - - **Feature name** - What it does and why you'd use it - - ### Improved - - - **Area** - What got better - - ### Fixed - - - What was broken, now works - ``` - - Omit empty sections. - - ## Rules - - 1. Write for developers using OpenSpec with AI coding assistants - 2. Remove commit hashes (like `eb152eb:`), PR numbers, and changesets wrappers (`### Minor Changes`) - 3. Lead with what users can do, not implementation details - 4. One to two sentences per item, max - 5. Use **bold** for feature/area names - 6. Skip internal changes (CI, refactors, tests) unless they affect users - 7. If the input is already well-formatted, just clean up structure and remove noise - - ## Example - - Before: - ``` - ### Minor Changes - - 8dfd824: Add OPSX experimental workflow commands and enhanced artifact system - **New Commands:** - - `/opsx:ff` - Fast-forward through artifact creation - ``` - - After (polished-notes.md): - ``` - ### New - - - **Fast-forward mode** - Generate all planning artifacts at once with `/opsx:ff`. Useful when you already know what you're building. - ``` - - After (release-title.txt): - ``` - v0.18.0 - OPSX Experimental Workflow - ``` - - Write both files. No other output. - - - name: Update release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - TAG="${{ env.TAG_NAME }}" - - if [ -f "polished-notes.md" ] && [ -f "release-title.txt" ]; then - TITLE=$(cat release-title.txt) - gh release edit "$TAG" --title "$TITLE" --notes-file polished-notes.md - echo "Updated: $TITLE" - elif [ -f "polished-notes.md" ]; then - gh release edit "$TAG" --notes-file polished-notes.md - echo "Updated notes (title unchanged)" - else - echo "No changes generated, keeping original" - fi diff --git a/.github/workflows/release-prepare.yml b/.github/workflows/release-prepare.yml index b59653e91..0a58d8e87 100644 --- a/.github/workflows/release-prepare.yml +++ b/.github/workflows/release-prepare.yml @@ -58,19 +58,3 @@ jobs: env: GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} # npm authentication handled via OIDC trusted publishing (no token needed) - - # Trigger release notes polishing after a release is published - # Uses repository_dispatch instead of workflow_dispatch because: - # - workflow_dispatch requires actions:write permission (GitHub App doesn't have it) - # - repository_dispatch works with contents:write (which we already have) - - name: Polish release notes - if: steps.changesets.outputs.published == 'true' - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: | - # Get version from package.json (just bumped by changesets) - TAG="v$(jq -r .version package.json)" - echo "Triggering polish workflow for $TAG" - gh api repos/${{ github.repository }}/dispatches \ - --method POST \ - --input - <<< "{\"event_type\":\"polish-release-notes\",\"client_payload\":{\"tag_name\":\"$TAG\"}}" diff --git a/README.md b/README.md index 73cfd7583..c43d3e933 100644 --- a/README.md +++ b/README.md @@ -1,453 +1,188 @@

- - - OpenSpec logo + + OpenSpec logo -

-

Spec-driven development for AI coding assistants.

+

CI npm version - node version License: MIT - Conventional Commits - Discord -

- -

- OpenSpec dashboard preview -

- -

- Follow @0xTab on X for updates · Join the OpenSpec Discord for help and questions. + Discord

-

- 🧪 New: Experimental Workflow (OPSX) — schema-driven, hackable, fluid. Iterate on workflows without code changes. -

+
+The most loved spec framework. -# OpenSpec +[![Stars](https://img.shields.io/github/stars/Fission-AI/OpenSpec?style=flat-square&label=Stars)](https://github.com/Fission-AI/OpenSpec/stargazers) +[![Downloads](https://img.shields.io/npm/dm/@fission-ai/openspec?style=flat-square&label=Downloads/mo)](https://www.npmjs.com/package/@fission-ai/openspec) +[![Contributors](https://img.shields.io/github/contributors/Fission-AI/OpenSpec?style=flat-square&label=Contributors)](https://github.com/Fission-AI/OpenSpec/graphs/contributors) -OpenSpec aligns humans and AI coding assistants with spec-driven development so you agree on what to build before any code is written. **No API keys required.** +
+

+Our philosophy: -## Why OpenSpec? +```text +→ fluid not rigid +→ iterative not waterfall +→ easy not complex +→ built for brownfield not just greenfield +→ scalable from personal projects to enterprises +``` -AI coding assistants are powerful but unpredictable when requirements live in chat history. OpenSpec adds a lightweight specification workflow that locks intent before implementation, giving you deterministic, reviewable outputs. +> [!TIP] +> **New workflow now available!** We've rebuilt OpenSpec with a new artifact-guided workflow. +> +> Run `/opsx:onboard` to get started. → [Learn more here](docs/opsx.md) -Key outcomes: -- Human and AI stakeholders agree on specs before work begins. -- Structured change folders (proposals, tasks, and spec updates) keep scope explicit and auditable. -- Shared visibility into what's proposed, active, or archived. -- Works with the AI tools you already use: custom slash commands where supported, context rules everywhere else. +

+ Follow @0xTab on X for updates · Join the OpenSpec Discord for help and questions. +

-## How OpenSpec compares (at a glance) +### Teams -- **Lightweight**: simple workflow, no API keys, minimal setup. -- **Brownfield-first**: works great beyond 0→1. OpenSpec separates the source of truth from proposals: `openspec/specs/` (current truth) and `openspec/changes/` (proposed updates). This keeps diffs explicit and manageable across features. -- **Change tracking**: proposals, tasks, and spec deltas live together; archiving merges the approved updates back into specs. -- **Compared to spec-kit & Kiro**: those shine for brand-new features (0→1). OpenSpec also excels when modifying existing behavior (1→n), especially when updates span multiple specs. +Using OpenSpec in a team? [Email here](mailto:teams@openspec.dev) for access to our Slack channel. -See the full comparison in [How OpenSpec Compares](#how-openspec-compares). + -## How It Works +## See it in action +```text +You: /opsx:new add-dark-mode +AI: Created openspec/changes/add-dark-mode/ + Ready to create: proposal + +You: /opsx:ff # "fast-forward" - generate all planning docs +AI: ✓ 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: /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! + +You: /opsx:archive +AI: Archived to openspec/changes/archive/2025-01-23-add-dark-mode/ + Specs updated. Ready for the next feature. ``` -┌────────────────────┐ -│ Draft Change │ -│ Proposal │ -└────────┬───────────┘ - │ share intent with your AI - ▼ -┌────────────────────┐ -│ Review & Align │ -│ (edit specs/tasks) │◀──── feedback loop ──────┐ -└────────┬───────────┘ │ - │ approved plan │ - ▼ │ -┌────────────────────┐ │ -│ Implement Tasks │──────────────────────────┘ -│ (AI writes code) │ -└────────┬───────────┘ - │ ship the change - ▼ -┌────────────────────┐ -│ Archive & Update │ -│ Specs (source) │ -└────────────────────┘ - -1. Draft a change proposal that captures the spec updates you want. -2. Review the proposal with your AI assistant until everyone agrees. -3. Implement tasks that reference the agreed specs. -4. Archive the change to merge the approved updates back into the source-of-truth specs. -``` - -## Getting Started - -### Supported AI Tools - -
-Native Slash Commands (click to expand) - -These tools have built-in OpenSpec commands. Select the OpenSpec integration when prompted. - -| Tool | Commands | -|------|----------| -| **Amazon Q Developer** | `@openspec-proposal`, `@openspec-apply`, `@openspec-archive` (`.amazonq/prompts/`) | -| **Antigravity** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.agent/workflows/`) | -| **Auggie (Augment CLI)** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.augment/commands/`) | -| **Claude Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | -| **Cline** | Workflows in `.clinerules/workflows/` directory (`.clinerules/workflows/openspec-*.md`) | -| **CodeBuddy Code (CLI)** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.codebuddy/commands/`) — see [docs](https://www.codebuddy.ai/cli) | -| **Codex** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (global: `~/.codex/prompts`, auto-installed) | -| **Continue** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.continue/prompts/`) | -| **CoStrict** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.cospec/openspec/commands/`) — see [docs](https://costrict.ai)| -| **Crush** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.crush/commands/openspec/`) | -| **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | -| **Factory Droid** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.factory/commands/`) | -| **Gemini CLI** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.gemini/commands/openspec/`) | -| **GitHub Copilot** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.github/prompts/`) | -| **iFlow (iflow-cli)** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.iflow/commands/`) | -| **Kilo Code** | `/openspec-proposal.md`, `/openspec-apply.md`, `/openspec-archive.md` (`.kilocode/workflows/`) | -| **OpenCode** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | -| **Qoder** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.qoder/commands/openspec/`) — see [docs](https://qoder.com) | -| **Qwen Code** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.qwen/commands/`) | -| **RooCode** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.roo/commands/`) | -| **Windsurf** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.windsurf/workflows/`) | - -Kilo Code discovers team workflows automatically. Save the generated files under `.kilocode/workflows/` and trigger them from the command palette with `/openspec-proposal.md`, `/openspec-apply.md`, or `/openspec-archive.md`. - -
-AGENTS.md Compatible (click to expand) +OpenSpec Dashboard -These tools automatically read workflow instructions from `openspec/AGENTS.md`. Ask them to follow the OpenSpec workflow if they need a reminder. Learn more about the [AGENTS.md convention](https://agents.md/). - -| Tools | -|-------| -| Amp • Jules • Others | +

+ OpenSpec dashboard preview +

-### Install & Initialize +## Quick Start -#### Prerequisites -- **Node.js >= 20.19.0** - Check your version with `node --version` +**Requires Node.js 20.19.0 or higher.** -#### Step 1: Install the CLI globally - -**Option A: Using npm** +Install OpenSpec globally: ```bash npm install -g @fission-ai/openspec@latest ``` -Verify installation: -```bash -openspec --version -``` - -**Option B: Using Nix (NixOS and Nix package manager)** - -Run OpenSpec directly without installation: -```bash -nix run github:Fission-AI/OpenSpec -- init -``` - -Or install to your profile: -```bash -nix profile install github:Fission-AI/OpenSpec -``` - -Or add to your development environment in `flake.nix`: -```nix -{ - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - openspec.url = "github:Fission-AI/OpenSpec"; - }; - - outputs = { nixpkgs, openspec, ... }: { - devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { - buildInputs = [ openspec.packages.x86_64-linux.default ]; - }; - }; -} -``` - -Verify installation: -```bash -openspec --version -``` - -#### Step 2: Initialize OpenSpec in your project - -Navigate to your project directory: -```bash -cd my-project -``` +Then navigate to your project directory and initialize: -Run the initialization: ```bash +cd your-project openspec init ``` -**What happens during initialization:** -- You'll be prompted to pick any natively supported AI tools (Claude Code, CodeBuddy, Cursor, OpenCode, Qoder,etc.); other assistants always rely on the shared `AGENTS.md` stub -- OpenSpec automatically configures slash commands for the tools you choose and always writes a managed `AGENTS.md` hand-off at the project root -- A new `openspec/` directory structure is created in your project - -**After setup:** -- Primary AI tools can trigger `/openspec` workflows without additional configuration -- Run `openspec list` to verify the setup and view any active changes -- If your coding assistant doesn't surface the new slash commands right away, restart it. Slash commands are loaded at startup, - so a fresh launch ensures they appear - -### Optional: Populate Project Context - -After `openspec init` completes, you'll receive a suggested prompt to help populate your project context: - -```text -Populate your project context: -"Please read openspec/project.md and help me fill it out with details about my project, tech stack, and conventions" -``` - -Use `openspec/project.md` to define project-level conventions, standards, architectural patterns, and other guidelines that should be followed across all changes. +Now tell your AI: `/opsx:new ` -### Create Your First Change +> [!NOTE] +> Not sure if your tool is supported? [View the full list](docs/supported-tools.md) – we support 20+ tools and growing. +> +> Also works with pnpm, yarn, bun, and nix. [See installation options](docs/installation.md). -Here's a real example showing the complete OpenSpec workflow. This works with any AI tool. Those with native slash commands will recognize the shortcuts automatically. +## Docs -#### 1. Draft the Proposal -Start by asking your AI to create a change proposal: - -```text -You: Create an OpenSpec change proposal for adding profile search filters by role and team - (Shortcut for tools with slash commands: /openspec:proposal Add profile search filters) - -AI: I'll create an OpenSpec change proposal for profile filters. - *Scaffolds openspec/changes/add-profile-filters/ with proposal.md, tasks.md, spec deltas.* -``` - -#### 2. Verify & Review -Check that the change was created correctly and review the proposal: - -```bash -$ openspec list # Confirm the change folder exists -$ openspec validate add-profile-filters # Validate spec formatting -$ openspec show add-profile-filters # Review proposal, tasks, and spec delta -``` +→ **[Getting Started](docs/getting-started.md)**: first steps
+→ **[Workflows](docs/workflows.md)**: combos and patterns
+→ **[Commands](docs/commands.md)**: slash commands & skills
+→ **[CLI](docs/cli.md)**: terminal reference
+→ **[Supported Tools](docs/supported-tools.md)**: tool integrations & install paths
+→ **[Concepts](docs/concepts.md)**: how it all fits
+→ **[Multi-Language](docs/multi-language.md)**: multi-language support
+→ **[Customization](docs/customization.md)**: make it yours -#### 3. Refine the Specs -Iterate on the specifications until they match your needs: -```text -You: Can you add acceptance criteria for the role and team filters? +## Why OpenSpec? -AI: I'll update the spec delta with scenarios for role and team filters. - *Edits openspec/changes/add-profile-filters/specs/profile/spec.md and tasks.md.* -``` +AI coding assistants are powerful but unpredictable when requirements live only in chat history. OpenSpec adds a lightweight spec layer so you agree on what to build before any code is written. -#### 4. Implement the Change -Once specs look good, start implementation: +- **Agree before you 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 +- **Use your tools** — works with 20+ AI assistants via slash commands -```text -You: The specs look good. Let's implement this change. - (Shortcut for tools with slash commands: /openspec:apply add-profile-filters) +### How we compare -AI: I'll work through the tasks in the add-profile-filters change. - *Implements tasks from openspec/changes/add-profile-filters/tasks.md* - *Marks tasks complete: Task 1.1 ✓, Task 1.2 ✓, Task 2.1 ✓...* -``` +**vs. [Spec Kit](https://github.com/github/spec-kit)** (GitHub) — Thorough but heavyweight. Rigid phase gates, lots of Markdown, Python setup. OpenSpec is lighter and lets you iterate freely. -#### 5. Archive the Completed Change -After implementation is complete, archive the change: +**vs. [Kiro](https://kiro.dev)** (AWS) — Powerful but you're locked into their IDE and limited to Claude models. OpenSpec works with the tools you already use. -```text -AI: All tasks are complete. The implementation is ready. +**vs. nothing** — AI coding without specs means vague prompts and unpredictable results. OpenSpec brings predictability without the ceremony. -You: Please archive the change - (Shortcut for tools with slash commands: /openspec:archive add-profile-filters) +## Updating OpenSpec -AI: I'll archive the add-profile-filters change. - *Runs: openspec archive add-profile-filters --yes* - ✓ Change archived successfully. Specs updated. Ready for the next feature! -``` +**Upgrade the package** -Or run the command yourself in terminal: ```bash -$ openspec archive add-profile-filters --yes # Archive the completed change without prompts +npm install -g @fission-ai/openspec@latest ``` -**Note:** Tools with native slash commands (Claude Code, CodeBuddy, Cursor, Codex, Qoder, RooCode) can use the shortcuts shown. All other tools work with natural language requests to "create an OpenSpec proposal", "apply the OpenSpec change", or "archive the change". +**Refresh agent instructions** -## Command Reference +Run this inside each project to regenerate AI guidance and ensure the latest slash commands are active: ```bash -openspec list # View active change folders -openspec view # Interactive dashboard of specs and changes -openspec show # Display change details (proposal, tasks, spec updates) -openspec validate # Check spec formatting and structure -openspec archive [--yes|-y] # Move a completed change into archive/ (non-interactive with --yes) -``` - -## Example: How AI Creates OpenSpec Files - -When you ask your AI assistant to "add two-factor authentication", it creates: - -``` -openspec/ -├── specs/ -│ └── auth/ -│ └── spec.md # Current auth spec (if exists) -└── changes/ - └── add-2fa/ # AI creates this entire structure - ├── proposal.md # Why and what changes - ├── tasks.md # Implementation checklist - ├── design.md # Technical decisions (optional) - └── specs/ - └── auth/ - └── spec.md # Delta showing additions -``` - -### AI-Generated Spec (created in `openspec/specs/auth/spec.md`): - -```markdown -# Auth Specification - -## Purpose -Authentication and session management. - -## Requirements -### Requirement: User Authentication -The system SHALL issue a JWT on successful login. - -#### Scenario: Valid credentials -- WHEN a user submits valid credentials -- THEN a JWT is returned -``` - -### AI-Generated Change Delta (created in `openspec/changes/add-2fa/specs/auth/spec.md`): - -```markdown -# Delta for Auth - -## ADDED Requirements -### Requirement: Two-Factor Authentication -The system MUST require a second factor during login. - -#### Scenario: OTP required -- WHEN a user submits valid credentials -- THEN an OTP challenge is required -``` - -### AI-Generated Tasks (created in `openspec/changes/add-2fa/tasks.md`): - -```markdown -## 1. Database Setup -- [ ] 1.1 Add OTP secret column to users table -- [ ] 1.2 Create OTP verification logs table - -## 2. Backend Implementation -- [ ] 2.1 Add OTP generation endpoint -- [ ] 2.2 Modify login flow to require OTP -- [ ] 2.3 Add OTP verification endpoint - -## 3. Frontend Updates -- [ ] 3.1 Create OTP input component -- [ ] 3.2 Update login flow UI +openspec update ``` -**Important:** You don't create these files manually. Your AI assistant generates them based on your requirements and the existing codebase. - -## Understanding OpenSpec Files - -### Delta Format +## Usage Notes -Deltas are "patches" that show how specs change: +**Model selection**: OpenSpec works best with high-reasoning models. We recommend Opus 4.5 and GPT 5.2 for both planning and implementation. -- **`## ADDED Requirements`** - New capabilities -- **`## MODIFIED Requirements`** - Changed behavior (include complete updated text) -- **`## REMOVED Requirements`** - Deprecated features +**Context hygiene**: OpenSpec benefits from a clean context window. Clear your context before starting implementation and maintain good context hygiene throughout your session. -**Format requirements:** -- Use `### Requirement: ` for headers -- Every requirement needs at least one `#### Scenario:` block -- Use SHALL/MUST in requirement text - -## How OpenSpec Compares - -### vs. spec-kit -OpenSpec’s two-folder model (`openspec/specs/` for the current truth, `openspec/changes/` for proposed updates) keeps state and diffs separate. This scales when you modify existing features or touch multiple specs. spec-kit is strong for greenfield/0→1 but provides less structure for cross-spec updates and evolving features. - -### vs. Kiro.dev -OpenSpec groups every change for a feature in one folder (`openspec/changes/feature-name/`), making it easy to track related specs, tasks, and designs together. Kiro spreads updates across multiple spec folders, which can make feature tracking harder. +## Contributing -### vs. No Specs -Without specs, AI coding assistants generate code from vague prompts, often missing requirements or adding unwanted features. OpenSpec brings predictability by agreeing on the desired behavior before any code is written. +**Small fixes** — Bug fixes, typo corrections, and minor improvements can be submitted directly as PRs. -## Team Adoption +**Larger changes** — For new features, significant refactors, or architectural changes, please submit an OpenSpec change proposal first so we can align on intent and goals before implementation begins. -1. **Initialize OpenSpec** – Run `openspec init` in your repo. -2. **Start with new features** – Ask your AI to capture upcoming work as change proposals. -3. **Grow incrementally** – Each change archives into living specs that document your system. -4. **Stay flexible** – Different teammates can use Claude Code, CodeBuddy, Cursor, or any AGENTS.md-compatible tool while sharing the same specs. +When writing proposals, keep the OpenSpec philosophy in mind: we serve a wide variety of users across different coding agents, models, and use cases. Changes should work well for everyone. -Run `openspec update` whenever someone switches tools so your agents pick up the latest instructions and slash-command bindings. +**AI-generated code is welcome** — as long as it's been tested and verified. PRs containing AI-generated code should mention the coding agent and model used (e.g., "Generated with Claude Code using claude-opus-4-5-20251101"). -## Updating OpenSpec +### Development -1. **Upgrade the package** - ```bash - npm install -g @fission-ai/openspec@latest - ``` -2. **Refresh agent instructions** - - Run `openspec update` inside each project to regenerate AI guidance and ensure the latest slash commands are active. +- Install dependencies: `pnpm install` +- Build: `pnpm run build` +- Test: `pnpm test` +- Develop CLI locally: `pnpm run dev` or `pnpm run dev:cli` +- Conventional commits (one-line): `type(scope): subject` -## Experimental Features +## Other
-🧪 OPSX: Fluid, Iterative Workflow (Claude Code only) - -**Why this exists:** -- Standard workflow is locked down — you can't tweak instructions or customize -- When AI output is bad, you can't improve the prompts yourself -- Same workflow for everyone, no way to match how your team works - -**What's different:** -- **Hackable** — edit templates and schemas yourself, test immediately, no rebuild -- **Granular** — each artifact has its own instructions, test and tweak individually -- **Customizable** — define your own workflows, artifacts, and dependencies -- **Fluid** — no phase gates, update any artifact anytime - -``` -You can always go back: - - proposal ──→ specs ──→ design ──→ tasks ──→ implement - ▲ ▲ ▲ │ - └───────────┴──────────┴────────────────────┘ -``` +Telemetry -| Command | What it does | -|---------|--------------| -| `/opsx:new` | Start a new change | -| `/opsx:continue` | Create the next artifact (based on what's ready) | -| `/opsx:ff` | Fast-forward (all planning artifacts at once) | -| `/opsx:apply` | Implement tasks, updating artifacts as needed | -| `/opsx:archive` | Archive when done | - -**Setup:** `openspec experimental` - -[Full documentation →](docs/experimental-workflow.md) - -
- -
-Telemetry – OpenSpec collects anonymous usage stats (opt-out: OPENSPEC_TELEMETRY=0) +OpenSpec collects anonymous usage stats. We collect only command names and version to understand usage patterns. No arguments, paths, content, or PII. Automatically disabled in CI. @@ -455,14 +190,6 @@ We collect only command names and version to understand usage patterns. No argum
-## Contributing - -- Install dependencies: `pnpm install` -- Build: `pnpm run build` -- Test: `pnpm test` -- Develop CLI locally: `pnpm run dev` or `pnpm run dev:cli` -- Conventional commits (one-line): `type(scope): subject` -
Maintainers & Advisors @@ -470,6 +197,8 @@ See [MAINTAINERS.md](MAINTAINERS.md) for the list of core maintainers and adviso
+ + ## License MIT diff --git a/README_OLD.md b/README_OLD.md new file mode 100644 index 000000000..e0f7f39a8 --- /dev/null +++ b/README_OLD.md @@ -0,0 +1,475 @@ +

+ + + + + OpenSpec logo + + + +

+

Spec-driven development for AI coding assistants.

+

+ CI + npm version + node version + License: MIT + Conventional Commits + Discord +

+ +

+ OpenSpec dashboard preview +

+ +

+ Follow @0xTab on X for updates · Join the OpenSpec Discord for help and questions. +

+ +

+ 🧪 New: OPSX Workflow — schema-driven, hackable, fluid. Iterate on workflows without code changes. +

+ +# OpenSpec + +OpenSpec aligns humans and AI coding assistants with spec-driven development so you agree on what to build before any code is written. **No API keys required.** + +## Why OpenSpec? + +AI coding assistants are powerful but unpredictable when requirements live in chat history. OpenSpec adds a lightweight specification workflow that locks intent before implementation, giving you deterministic, reviewable outputs. + +Key outcomes: +- Human and AI stakeholders agree on specs before work begins. +- Structured change folders (proposals, tasks, and spec updates) keep scope explicit and auditable. +- Shared visibility into what's proposed, active, or archived. +- Works with the AI tools you already use: custom slash commands where supported, context rules everywhere else. + +## How OpenSpec compares (at a glance) + +- **Lightweight**: simple workflow, no API keys, minimal setup. +- **Brownfield-first**: works great beyond 0→1. OpenSpec separates the source of truth from proposals: `openspec/specs/` (current truth) and `openspec/changes/` (proposed updates). This keeps diffs explicit and manageable across features. +- **Change tracking**: proposals, tasks, and spec deltas live together; archiving merges the approved updates back into specs. +- **Compared to spec-kit & Kiro**: those shine for brand-new features (0→1). OpenSpec also excels when modifying existing behavior (1→n), especially when updates span multiple specs. + +See the full comparison in [How OpenSpec Compares](#how-openspec-compares). + +## How It Works + +``` +┌────────────────────┐ +│ Draft Change │ +│ Proposal │ +└────────┬───────────┘ + │ share intent with your AI + ▼ +┌────────────────────┐ +│ Review & Align │ +│ (edit specs/tasks) │◀──── feedback loop ──────┐ +└────────┬───────────┘ │ + │ approved plan │ + ▼ │ +┌────────────────────┐ │ +│ Implement Tasks │──────────────────────────┘ +│ (AI writes code) │ +└────────┬───────────┘ + │ ship the change + ▼ +┌────────────────────┐ +│ Archive & Update │ +│ Specs (source) │ +└────────────────────┘ + +1. Draft a change proposal that captures the spec updates you want. +2. Review the proposal with your AI assistant until everyone agrees. +3. Implement tasks that reference the agreed specs. +4. Archive the change to merge the approved updates back into the source-of-truth specs. +``` + +## Getting Started + +### Supported AI Tools + +
+Native Slash Commands (click to expand) + +These tools have built-in OpenSpec commands. Select the OpenSpec integration when prompted. + +| Tool | Commands | +|------|----------| +| **Amazon Q Developer** | `@openspec-proposal`, `@openspec-apply`, `@openspec-archive` (`.amazonq/prompts/`) | +| **Antigravity** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.agent/workflows/`) | +| **Auggie (Augment CLI)** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.augment/commands/`) | +| **Claude Code** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` | +| **Cline** | Workflows in `.clinerules/workflows/` directory (`.clinerules/workflows/openspec-*.md`) | +| **CodeBuddy Code (CLI)** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.codebuddy/commands/`) — see [docs](https://www.codebuddy.ai/cli) | +| **Codex** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (global: `~/.codex/prompts`, auto-installed) | +| **Continue** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.continue/prompts/`) | +| **CoStrict** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.cospec/openspec/commands/`) — see [docs](https://costrict.ai)| +| **Crush** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.crush/commands/openspec/`) | +| **Cursor** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | +| **Factory Droid** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.factory/commands/`) | +| **Gemini CLI** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.gemini/commands/openspec/`) | +| **GitHub Copilot** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.github/prompts/`) | +| **iFlow (iflow-cli)** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.iflow/commands/`) | +| **Kilo Code** | `/openspec-proposal.md`, `/openspec-apply.md`, `/openspec-archive.md` (`.kilocode/workflows/`) | +| **OpenCode** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` | +| **Qoder** | `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` (`.qoder/commands/openspec/`) — see [docs](https://qoder.com) | +| **Qwen Code** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.qwen/commands/`) | +| **RooCode** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.roo/commands/`) | +| **Windsurf** | `/openspec-proposal`, `/openspec-apply`, `/openspec-archive` (`.windsurf/workflows/`) | + +Kilo Code discovers team workflows automatically. Save the generated files under `.kilocode/workflows/` and trigger them from the command palette with `/openspec-proposal.md`, `/openspec-apply.md`, or `/openspec-archive.md`. + +
+ +
+AGENTS.md Compatible (click to expand) + +These tools automatically read workflow instructions from `openspec/AGENTS.md`. Ask them to follow the OpenSpec workflow if they need a reminder. Learn more about the [AGENTS.md convention](https://agents.md/). + +| Tools | +|-------| +| Amp • Jules • Others | + +
+ +### Install & Initialize + +#### Prerequisites +- **Node.js >= 20.19.0** - Check your version with `node --version` + +#### Step 1: Install the CLI globally + +**Option A: Using npm** + +```bash +npm install -g @fission-ai/openspec@latest +``` + +Verify installation: +```bash +openspec --version +``` + +**Option B: Using Nix (NixOS and Nix package manager)** + +Run OpenSpec directly without installation: +```bash +nix run github:Fission-AI/OpenSpec -- init +``` + +Or install to your profile: +```bash +nix profile install github:Fission-AI/OpenSpec +``` + +Or add to your development environment in `flake.nix`: +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + openspec.url = "github:Fission-AI/OpenSpec"; + }; + + outputs = { nixpkgs, openspec, ... }: { + devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell { + buildInputs = [ openspec.packages.x86_64-linux.default ]; + }; + }; +} +``` + +Verify installation: +```bash +openspec --version +``` + +#### Step 2: Initialize OpenSpec in your project + +Navigate to your project directory: +```bash +cd my-project +``` + +Run the initialization: +```bash +openspec init +``` + +**What happens during initialization:** +- You'll be prompted to pick any natively supported AI tools (Claude Code, CodeBuddy, Cursor, OpenCode, Qoder,etc.); other assistants always rely on the shared `AGENTS.md` stub +- OpenSpec automatically configures slash commands for the tools you choose and always writes a managed `AGENTS.md` hand-off at the project root +- A new `openspec/` directory structure is created in your project + +**After setup:** +- Primary AI tools can trigger `/openspec` workflows without additional configuration +- Run `openspec list` to verify the setup and view any active changes +- If your coding assistant doesn't surface the new slash commands right away, restart it. Slash commands are loaded at startup, + so a fresh launch ensures they appear + +### Optional: Populate Project Context + +After `openspec init` completes, you'll receive a suggested prompt to help populate your project context: + +```text +Populate your project context: +"Please read openspec/project.md and help me fill it out with details about my project, tech stack, and conventions" +``` + +Use `openspec/project.md` to define project-level conventions, standards, architectural patterns, and other guidelines that should be followed across all changes. + +### Create Your First Change + +Here's a real example showing the complete OpenSpec workflow. This works with any AI tool. Those with native slash commands will recognize the shortcuts automatically. + +#### 1. Draft the Proposal +Start by asking your AI to create a change proposal: + +```text +You: Create an OpenSpec change proposal for adding profile search filters by role and team + (Shortcut for tools with slash commands: /openspec:proposal Add profile search filters) + +AI: I'll create an OpenSpec change proposal for profile filters. + *Scaffolds openspec/changes/add-profile-filters/ with proposal.md, tasks.md, spec deltas.* +``` + +#### 2. Verify & Review +Check that the change was created correctly and review the proposal: + +```bash +$ openspec list # Confirm the change folder exists +$ openspec validate add-profile-filters # Validate spec formatting +$ openspec show add-profile-filters # Review proposal, tasks, and spec delta +``` + +#### 3. Refine the Specs +Iterate on the specifications until they match your needs: + +```text +You: Can you add acceptance criteria for the role and team filters? + +AI: I'll update the spec delta with scenarios for role and team filters. + *Edits openspec/changes/add-profile-filters/specs/profile/spec.md and tasks.md.* +``` + +#### 4. Implement the Change +Once specs look good, start implementation: + +```text +You: The specs look good. Let's implement this change. + (Shortcut for tools with slash commands: /openspec:apply add-profile-filters) + +AI: I'll work through the tasks in the add-profile-filters change. + *Implements tasks from openspec/changes/add-profile-filters/tasks.md* + *Marks tasks complete: Task 1.1 ✓, Task 1.2 ✓, Task 2.1 ✓...* +``` + +#### 5. Archive the Completed Change +After implementation is complete, archive the change: + +```text +AI: All tasks are complete. The implementation is ready. + +You: Please archive the change + (Shortcut for tools with slash commands: /openspec:archive add-profile-filters) + +AI: I'll archive the add-profile-filters change. + *Runs: openspec archive add-profile-filters --yes* + ✓ Change archived successfully. Specs updated. Ready for the next feature! +``` + +Or run the command yourself in terminal: +```bash +$ openspec archive add-profile-filters --yes # Archive the completed change without prompts +``` + +**Note:** Tools with native slash commands (Claude Code, CodeBuddy, Cursor, Codex, Qoder, RooCode) can use the shortcuts shown. All other tools work with natural language requests to "create an OpenSpec proposal", "apply the OpenSpec change", or "archive the change". + +## Command Reference + +```bash +openspec list # View active change folders +openspec view # Interactive dashboard of specs and changes +openspec show # Display change details (proposal, tasks, spec updates) +openspec validate # Check spec formatting and structure +openspec archive [--yes|-y] # Move a completed change into archive/ (non-interactive with --yes) +``` + +## Example: How AI Creates OpenSpec Files + +When you ask your AI assistant to "add two-factor authentication", it creates: + +``` +openspec/ +├── specs/ +│ └── auth/ +│ └── spec.md # Current auth spec (if exists) +└── changes/ + └── add-2fa/ # AI creates this entire structure + ├── proposal.md # Why and what changes + ├── tasks.md # Implementation checklist + ├── design.md # Technical decisions (optional) + └── specs/ + └── auth/ + └── spec.md # Delta showing additions +``` + +### AI-Generated Spec (created in `openspec/specs/auth/spec.md`): + +```markdown +# Auth Specification + +## Purpose +Authentication and session management. + +## Requirements +### Requirement: User Authentication +The system SHALL issue a JWT on successful login. + +#### Scenario: Valid credentials +- WHEN a user submits valid credentials +- THEN a JWT is returned +``` + +### AI-Generated Change Delta (created in `openspec/changes/add-2fa/specs/auth/spec.md`): + +```markdown +# Delta for Auth + +## ADDED Requirements +### Requirement: Two-Factor Authentication +The system MUST require a second factor during login. + +#### Scenario: OTP required +- WHEN a user submits valid credentials +- THEN an OTP challenge is required +``` + +### AI-Generated Tasks (created in `openspec/changes/add-2fa/tasks.md`): + +```markdown +## 1. Database Setup +- [ ] 1.1 Add OTP secret column to users table +- [ ] 1.2 Create OTP verification logs table + +## 2. Backend Implementation +- [ ] 2.1 Add OTP generation endpoint +- [ ] 2.2 Modify login flow to require OTP +- [ ] 2.3 Add OTP verification endpoint + +## 3. Frontend Updates +- [ ] 3.1 Create OTP input component +- [ ] 3.2 Update login flow UI +``` + +**Important:** You don't create these files manually. Your AI assistant generates them based on your requirements and the existing codebase. + +## Understanding OpenSpec Files + +### Delta Format + +Deltas are "patches" that show how specs change: + +- **`## ADDED Requirements`** - New capabilities +- **`## MODIFIED Requirements`** - Changed behavior (include complete updated text) +- **`## REMOVED Requirements`** - Deprecated features + +**Format requirements:** +- Use `### Requirement: ` for headers +- Every requirement needs at least one `#### Scenario:` block +- Use SHALL/MUST in requirement text + +## How OpenSpec Compares + +### vs. spec-kit +OpenSpec’s two-folder model (`openspec/specs/` for the current truth, `openspec/changes/` for proposed updates) keeps state and diffs separate. This scales when you modify existing features or touch multiple specs. spec-kit is strong for greenfield/0→1 but provides less structure for cross-spec updates and evolving features. + +### vs. Kiro.dev +OpenSpec groups every change for a feature in one folder (`openspec/changes/feature-name/`), making it easy to track related specs, tasks, and designs together. Kiro spreads updates across multiple spec folders, which can make feature tracking harder. + +### vs. No Specs +Without specs, AI coding assistants generate code from vague prompts, often missing requirements or adding unwanted features. OpenSpec brings predictability by agreeing on the desired behavior before any code is written. + +## Team Adoption + +1. **Initialize OpenSpec** – Run `openspec init` in your repo. +2. **Start with new features** – Ask your AI to capture upcoming work as change proposals. +3. **Grow incrementally** – Each change archives into living specs that document your system. +4. **Stay flexible** – Different teammates can use Claude Code, CodeBuddy, Cursor, or any AGENTS.md-compatible tool while sharing the same specs. + +Run `openspec update` whenever someone switches tools so your agents pick up the latest instructions and slash-command bindings. + +## Updating OpenSpec + +1. **Upgrade the package** + ```bash + npm install -g @fission-ai/openspec@latest + ``` +2. **Refresh agent instructions** + - Run `openspec update` inside each project to regenerate AI guidance and ensure the latest slash commands are active. + +## Experimental Features + +
+🧪 OPSX: Fluid, Iterative Workflow (Claude Code only) + +**Why this exists:** +- Standard workflow is locked down — you can't tweak instructions or customize +- When AI output is bad, you can't improve the prompts yourself +- Same workflow for everyone, no way to match how your team works + +**What's different:** +- **Hackable** — edit templates and schemas yourself, test immediately, no rebuild +- **Granular** — each artifact has its own instructions, test and tweak individually +- **Customizable** — define your own workflows, artifacts, and dependencies +- **Fluid** — no phase gates, update any artifact anytime + +``` +You can always go back: + + proposal ──→ specs ──→ design ──→ tasks ──→ implement + ▲ ▲ ▲ │ + └───────────┴──────────┴────────────────────┘ +``` + +| Command | What it does | +|---------|--------------| +| `/opsx:new` | Start a new change | +| `/opsx:continue` | Create the next artifact (based on what's ready) | +| `/opsx:ff` | Fast-forward (all planning artifacts at once) | +| `/opsx:apply` | Implement tasks, updating artifacts as needed | +| `/opsx:archive` | Archive when done | + +**Setup:** `openspec experimental` + +[Full documentation →](docs/opsx.md) + +
+ +
+Telemetry – OpenSpec collects anonymous usage stats (opt-out: OPENSPEC_TELEMETRY=0) + +We collect only command names and version to understand usage patterns. No arguments, paths, content, or PII. Automatically disabled in CI. + +**Opt-out:** `export OPENSPEC_TELEMETRY=0` or `export DO_NOT_TRACK=1` + +
+ +## Contributing + +- Install dependencies: `pnpm install` +- Build: `pnpm run build` +- Test: `pnpm test` +- Develop CLI locally: `pnpm run dev` or `pnpm run dev:cli` +- Conventional commits (one-line): `type(scope): subject` + +
+Maintainers & Advisors + +See [MAINTAINERS.md](MAINTAINERS.md) for the list of core maintainers and advisors who help guide the project. + +
+ +## License + +MIT diff --git a/assets/openspec_bg.png b/assets/openspec_bg.png new file mode 100644 index 000000000..423c2d35a Binary files /dev/null and b/assets/openspec_bg.png differ diff --git a/docs/artifact_poc.md b/docs/artifact_poc.md deleted file mode 100644 index 01dd00985..000000000 --- a/docs/artifact_poc.md +++ /dev/null @@ -1,597 +0,0 @@ -# POC-OpenSpec-Core Analysis - ---- - -## Design Decisions & Terminology - -### Philosophy: Not a Workflow System - -This system is **not** a workflow engine. It's an **artifact tracker with dependency awareness**. - -| What it's NOT | What it IS | -|---------------|------------| -| Linear step-by-step progression | Exploratory, iterative planning | -| Bureaucratic checkpoints | Enablers that unlock possibilities | -| "You must complete step 1 first" | "Here's what you could create now" | -| Form-filling | Fluid document creation | - -**Key insight:** Dependencies are *enablers*, not *gates*. You can't meaningfully write a design document if there's no proposal to design from - that's not bureaucracy, it's logic. - -### Terminology - -| Term | Definition | Example | -|------|------------|---------| -| **Change** | A unit of work being planned (feature, refactor, migration) | `openspec/changes/add-auth/` | -| **Schema** | An artifact graph definition (what artifacts exist, their dependencies) | `spec-driven.yaml` | -| **Artifact** | A node in the graph (a document to create) | `proposal`, `design`, `specs` | -| **Template** | Instructions/guidance for creating an artifact | `templates/proposal.md` | - -### Hierarchy - -``` -Schema (defines) ──→ Artifacts (guided by) ──→ Templates -``` - -- **Schema** = the artifact graph (what exists, dependencies) -- **Artifact** = a document to produce -- **Template** = instructions for creating that artifact - -### Schema Variations - -Schemas can vary across multiple dimensions: - -| Dimension | Examples | -|-----------|----------| -| Philosophy | `spec-driven`, `tdd`, `prototype-first` | -| Version | `v1`, `v2`, `v3` | -| Language | `en`, `zh`, `es` | -| Custom | `team-alpha`, `experimental` | - -### Schema Resolution (XDG Standard) - -Schemas follow the XDG Base Directory Specification with a 2-level resolution: - -``` -1. ${XDG_DATA_HOME}/openspec/schemas//schema.yaml # Global user override -2. /schemas//schema.yaml # Built-in defaults -``` - -**Platform-specific paths:** -- Unix/macOS: `~/.local/share/openspec/schemas/` -- Windows: `%LOCALAPPDATA%/openspec/schemas/` -- All platforms: `$XDG_DATA_HOME/openspec/schemas/` (when set) - -**Why XDG?** -- Schemas are workflow definitions (data), not user preferences (config) -- Built-ins baked into package, never auto-copied -- Users customize by creating files in global data dir -- Consistent with modern CLI tooling standards - -### Template Inheritance (2 Levels Max) - -Templates are co-located with schemas in a `templates/` subdirectory: - -``` -1. ${XDG_DATA_HOME}/openspec/schemas//templates/.md # User override -2. /schemas//templates/.md # Built-in -``` - -**Rules:** -- User overrides take precedence over package built-ins -- A CLI command shows resolved paths (no guessing) -- No inheritance between schemas (copy if you need to diverge) -- Templates are always co-located with their schema - -**Why this matters:** -- Avoids "where does this come from?" debugging -- No implicit magic that works until it doesn't -- Schema + templates form a cohesive unit - ---- - -## Executive Summary - -This is an **artifact tracker with dependency awareness** that guides iterative development through a structured artifact pipeline. The core innovation is using the **filesystem as a database** - artifact completion is detected by file existence, making the system stateless and version-control friendly. - -The system answers: -- "What artifacts exist for this change?" -- "What could I create next?" (not "what must I create") -- "What's blocking X?" (informational, not prescriptive) - ---- - -## Core Components - -### 1. ArtifactGraph (Slice 1 - COMPLETE) - -The dependency graph engine with XDG-compliant schema resolution. - -| Responsibility | Approach | -|----------------|----------| -| Model artifacts as a DAG | Artifact with `requires: string[]` | -| Track completion state | `Set` for completed artifacts | -| Calculate build order | Kahn's algorithm (topological sort) | -| Find ready artifacts | Check if all dependencies are in `completed` set | -| Resolve schemas | XDG global → package built-ins | - -**Key Data Structures (Zod-validated):** - -```typescript -// Zod schemas define types + validation -const ArtifactSchema = z.object({ - id: z.string().min(1), - generates: z.string().min(1), // e.g., "proposal.md" or "specs/*.md" - description: z.string(), - template: z.string(), // path to template file - requires: z.array(z.string()).default([]), -}); - -const SchemaYamlSchema = z.object({ - name: z.string().min(1), - version: z.number().int().positive(), - description: z.string().optional(), - artifacts: z.array(ArtifactSchema).min(1), -}); - -// Derived types -type Artifact = z.infer; -type SchemaYaml = z.infer; -``` - -**Key Methods:** -- `resolveSchema(name)` - Load schema with XDG fallback -- `ArtifactGraph.fromSchema(schema)` - Build graph from schema -- `detectState(graph, changeDir)` - Scan filesystem for completion -- `getNextArtifacts(graph, completed)` - Find artifacts ready to create -- `getBuildOrder(graph)` - Topological sort of all artifacts -- `getBlocked(graph, completed)` - Artifacts with unmet dependencies - ---- - -### 2. Change Utilities (Slice 2) - -Simple utility functions for programmatic change creation. No class, no abstraction layer. - -| Responsibility | Approach | -|----------------|----------| -| Create changes | Create dirs under `openspec/changes//` with README | -| Name validation | Enforce kebab-case naming | - -**Key Paths:** - -``` -openspec/changes// → Change instances with artifacts (project-level) -``` - -**Key Functions** (`src/utils/change-utils.ts`): -- `createChange(projectRoot, name, description?)` - Create new change directory + README -- `validateChangeName(name)` - Validate kebab-case naming, returns `{ valid, error? }` - -**Note:** Existing CLI commands (`ListCommand`, `ChangeCommand`) already handle listing, path resolution, and existence checks. No need to extract that logic - it works fine as-is. - ---- - -### 3. InstructionLoader (Slice 3) - -Template resolution and instruction enrichment. - -| Responsibility | Approach | -|----------------|----------| -| Resolve templates | XDG 2-level fallback (schema-specific → shared → built-in) | -| Build dynamic context | Gather dependency status, change info | -| Enrich templates | Inject context into base templates | -| Generate status reports | Formatted markdown with progress | - -**Key Class - ChangeState:** - -``` -ChangeState { - changeName: string - changeDir: string - graph: ArtifactGraph - completed: Set - - // Methods - getNextSteps(): string[] - getStatus(artifactId): ArtifactStatus - isComplete(): boolean -} -``` - -**Key Functions:** -- `getTemplatePath(artifactId, schemaName?)` - Resolve with 2-level fallback -- `getEnrichedInstructions(artifactId, projectRoot, changeName?)` - Main entry point -- `getChangeStatus(projectRoot, changeName?)` - Formatted status report - ---- - -### 4. CLI (Slice 4) - -User interface layer. **All commands are deterministic** - require explicit `--change` parameter. - -| Command | Function | Status | -|---------|----------|--------| -| `status --change ` | Show change progress (artifact graph) | **NEW** | -| `next --change ` | Show artifacts ready to create | **NEW** | -| `instructions --change ` | Get enriched instructions for artifact | **NEW** | -| `list` | List all changes | EXISTS (`openspec change list`) | -| `new ` | Create change | **NEW** (uses `createChange()`) | -| `init` | Initialize structure | EXISTS (`openspec init`) | -| `templates --change ` | Show resolved template paths | **NEW** | - -**Note:** Commands that operate on a change require `--change`. Missing parameter → error with list of available changes. Agent infers the change from conversation and passes it explicitly. - -**Existing CLI commands** (not part of this slice): -- `openspec change list` / `openspec change show ` / `openspec change validate ` -- `openspec list --changes` / `openspec list --specs` -- `openspec view` (dashboard) -- `openspec init` / `openspec archive ` - ---- - -### 5. Claude Commands - -Integration layer for Claude Code. **Operational commands only** - artifact creation via natural language. - -| Command | Purpose | -|---------|---------| -| `/status` | Show change progress | -| `/next` | Show what's ready to create | -| `/run [artifact]` | Execute a specific step (power users) | -| `/list` | List all changes | -| `/new ` | Create a new change | -| `/init` | Initialize structure | - -**Artifact creation:** Users say "create the proposal" or "write the tests" in natural language. The agent: -1. Infers change from conversation (confirms if uncertain) -2. Infers artifact from request -3. Calls CLI with explicit `--change` parameter -4. Creates artifact following instructions - -This works for ANY artifact in ANY schema - no new slash commands needed when schemas change. - -**Note:** Legacy commands (`/openspec-proposal`, `/openspec-apply`, `/openspec-archive`) exist in the main project for backward compatibility but are separate from this architecture. - ---- - -## Component Dependency Graph - -``` -┌─────────────────────────────────────────────────────────────┐ -│ PRESENTATION LAYER │ -│ ┌──────────────┐ ┌────────────────────┐ │ -│ │ CLI │ ←─shell exec───────│ Claude Commands │ │ -│ └──────┬───────┘ └────────────────────┘ │ -└─────────┼───────────────────────────────────────────────────┘ - │ imports - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ ORCHESTRATION LAYER │ -│ ┌────────────────────┐ ┌──────────────────────────┐ │ -│ │ InstructionLoader │ │ change-utils (Slice 2) │ │ -│ │ (Slice 3) │ │ createChange() │ │ -│ └─────────┬──────────┘ │ validateChangeName() │ │ -│ │ └──────────────────────────┘ │ -└────────────┼────────────────────────────────────────────────┘ - │ uses - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ CORE LAYER │ -│ ┌──────────────────────────────────────────────────────┐ │ -│ │ ArtifactGraph (Slice 1) │ │ -│ │ │ │ -│ │ Schema Resolution (XDG) ──→ Graph ──→ State Detection│ │ -│ └──────────────────────────────────────────────────────┘ │ -└─────────────────────────────────────────────────────────────┘ - ▲ - │ reads from - ▼ -┌─────────────────────────────────────────────────────────────┐ -│ PERSISTENCE LAYER │ -│ ┌──────────────────┐ ┌────────────────────────────────┐ │ -│ │ XDG Schemas │ │ Project Artifacts │ │ -│ │ ~/.local/share/ │ │ openspec/changes// │ │ -│ │ openspec/ │ │ - proposal.md, design.md │ │ -│ │ schemas/ │ │ - specs/*.md, tasks.md │ │ -│ └──────────────────┘ └────────────────────────────────┘ │ -└─────────────────────────────────────────────────────────────┘ -``` - ---- - -## Key Design Patterns - -### 1. Filesystem as Database - -No SQLite, no JSON state files. The existence of `proposal.md` means proposal is complete. - -``` -// State detection is just file existence checking -if (exists(artifactPath)) { - completed.add(artifactId) -} -``` - -### 2. Deterministic CLI, Inferring Agent - -**CLI layer:** Always deterministic - requires explicit `--change` parameter. - -``` -openspec status --change add-auth # explicit, works -openspec status # error: "No change specified" -``` - -**Agent layer:** Infers from conversation, confirms if uncertain, passes explicit `--change`. - -This separation means: -- CLI is pure, testable, no state to corrupt -- Agent handles all "smartness" -- No config.yaml tracking of "active change" - -### 3. XDG-Compliant Schema Resolution - -``` -${XDG_DATA_HOME}/openspec/schemas//schema.yaml # User override - ↓ (not found) -/schemas//schema.yaml # Built-in - ↓ (not found) -Error (schema not found) -``` - -### 4. Two-Level Template Fallback - -``` -${XDG_DATA_HOME}/openspec/schemas//templates/.md # User override - ↓ (not found) -/schemas//templates/.md # Built-in - ↓ (not found) -Error (no silent fallback to avoid confusion) -``` - -### 5. Glob Pattern Support - -`specs/*.md` allows multiple files to satisfy a single artifact: - -``` -if (artifact.generates.includes("*")) { - const parentDir = changeDir / patternParts[0] - if (exists(parentDir) && hasFiles(parentDir)) { - completed.add(artifactId) - } -} -``` - -### 6. Stateless State Detection - -Every command re-scans the filesystem. No cached state to corrupt. - ---- - -## Artifact Pipeline (Default Schema) - -The default `spec-driven` schema: - -``` -┌──────────┐ -│ proposal │ (no dependencies) -└────┬─────┘ - │ - ▼ -┌──────────┐ -│ specs │ (requires: proposal) -└────┬─────┘ - │ - ├──────────────┐ - ▼ ▼ -┌──────────┐ ┌──────────┐ -│ design │ │ │ -│ │◄──┤ proposal │ -└────┬─────┘ └──────────┘ - │ (requires: proposal, specs) - ▼ -┌──────────┐ -│ tasks │ (requires: design) -└──────────┘ -``` - -Other schemas (TDD, prototype-first) would have different graphs. - ---- - -## Implementation Order - -Structured as **vertical slices** - each slice is independently testable. - ---- - -### Slice 1: "What's Ready?" (Core Query) ✅ COMPLETE - -**Delivers:** Types + Graph + State Detection + Schema Resolution - -**Implementation:** `src/core/artifact-graph/` -- `types.ts` - Zod schemas and derived TypeScript types -- `schema.ts` - YAML parsing with Zod validation -- `graph.ts` - ArtifactGraph class with topological sort -- `state.ts` - Filesystem-based state detection -- `resolver.ts` - XDG-compliant schema resolution -- `builtin-schemas.ts` - Package-bundled default schemas - -**Key decisions made:** -- Zod for schema validation (consistent with project) -- XDG for global schema overrides -- `Set` for completion state (immutable, functional) -- `inProgress` and `failed` states deferred (require external tracking) - ---- - -### Slice 2: "Change Creation Utilities" - -**Delivers:** Utility functions for programmatic change creation - -**Scope:** -- `createChange(projectRoot, name, description?)` → creates directory + README -- `validateChangeName(name)` → kebab-case pattern enforcement - -**Not in scope (already exists in CLI commands):** -- `listChanges()` → exists in `ListCommand` and `ChangeCommand.getActiveChanges()` -- `getChangePath()` → simple `path.join()` inline -- `changeExists()` → simple `fs.access()` inline -- `isInitialized()` → simple directory check inline - -**Why simplified:** Extracting existing CLI logic into a class would require similar refactoring of `SpecCommand` for consistency. The existing code works fine (~15 lines each). Only truly new functionality is `createChange()` + name validation. - ---- - -### Slice 3: "Get Instructions" (Enrichment) - -**Delivers:** Template resolution + context injection - -**Testable behaviors:** -- Template fallback: schema-specific → shared → built-in → error -- Context injection: completed deps show ✓, missing show ✗ -- Output path shown correctly based on change directory - ---- - -### Slice 4: "CLI + Integration" - -**Delivers:** New artifact graph commands (builds on existing CLI) - -**New commands:** -- `status --change ` - Show artifact completion state -- `next --change ` - Show ready-to-create artifacts -- `instructions --change ` - Get enriched template -- `templates --change ` - Show resolved paths -- `new ` - Create change (wrapper for `createChange()`) - -**Already exists (not in scope):** -- `openspec change list/show/validate` - change management -- `openspec list --changes/--specs` - listing -- `openspec view` - dashboard -- `openspec init` - initialization - -**Testable behaviors:** -- Each new command produces expected output -- Commands compose correctly (status → next → instructions flow) -- Error handling for missing changes, invalid artifacts, etc. - ---- - -## Directory Structure - -``` -# Global (XDG paths - user overrides) -~/.local/share/openspec/ # Unix/macOS ($XDG_DATA_HOME/openspec/) -%LOCALAPPDATA%/openspec/ # Windows -└── schemas/ # Schema overrides - └── custom-workflow/ # User-defined schema directory - ├── schema.yaml # Schema definition - └── templates/ # Co-located templates - └── proposal.md - -# Package (built-in defaults) -/ -└── schemas/ # Built-in schema definitions - ├── spec-driven/ # Default: proposal → specs → design → tasks - │ ├── schema.yaml - │ └── templates/ - │ ├── proposal.md - │ ├── design.md - │ ├── spec.md - │ └── tasks.md - └── tdd/ # TDD: tests → implementation → docs - ├── schema.yaml - └── templates/ - ├── test.md - ├── implementation.md - ├── spec.md - └── docs.md - -# Project (change instances) -openspec/ -└── changes/ # Change instances - ├── add-auth/ - │ ├── README.md # Auto-generated on creation - │ ├── proposal.md # Created artifacts - │ ├── design.md - │ └── specs/ - │ └── *.md - ├── refactor-db/ - │ └── ... - └── archive/ # Completed changes - └── 2025-01-01-add-auth/ - -.claude/ -├── settings.local.json # Permissions -└── commands/ # Slash commands - └── *.md -``` - ---- - -## Schema YAML Format - -```yaml -# Built-in: /schemas/spec-driven/schema.yaml -# Or user override: ~/.local/share/openspec/schemas/spec-driven/schema.yaml -name: spec-driven -version: 1 -description: Specification-driven development - -artifacts: - - id: proposal - generates: "proposal.md" - description: "Create project proposal document" - template: "proposal.md" # resolves from co-located templates/ directory - requires: [] - - - id: specs - generates: "specs/*.md" # glob pattern - description: "Create technical specification documents" - template: "specs.md" - requires: - - proposal - - - id: design - generates: "design.md" - description: "Create design document" - template: "design.md" - requires: - - proposal - - specs - - - id: tasks - generates: "tasks.md" - description: "Create tasks breakdown document" - template: "tasks.md" - requires: - - design -``` - ---- - -## Summary - -| Layer | Component | Responsibility | Status | -|-------|-----------|----------------|--------| -| Core | ArtifactGraph | Pure dependency logic + XDG schema resolution | ✅ Slice 1 COMPLETE | -| Utils | change-utils | Change creation + name validation only | Slice 2 (new functionality only) | -| Core | InstructionLoader | Template resolution + enrichment | Slice 3 (all new) | -| Presentation | CLI | New artifact graph commands | Slice 4 (new commands only) | -| Integration | Claude Commands | AI assistant glue | Slice 4 | - -**What already exists (not in this proposal):** -- `getActiveChangeIds()` in `src/utils/item-discovery.ts` - list changes -- `ChangeCommand.list/show/validate()` in `src/commands/change.ts` -- `ListCommand.execute()` in `src/core/list.ts` -- `ViewCommand.execute()` in `src/core/view.ts` - dashboard -- `src/core/init.ts` - initialization -- `src/core/archive.ts` - archiving - -**Key Principles:** -- **Filesystem IS the database** - stateless, version-control friendly -- **Dependencies are enablers** - show what's possible, don't force order -- **Deterministic CLI, inferring agent** - CLI requires explicit `--change`, agent infers from context -- **XDG-compliant paths** - schemas and templates use standard user data directories -- **2-level inheritance** - user override → package built-in (no deeper) -- **Schemas are versioned** - support variations by philosophy, version, language diff --git a/docs/cli.md b/docs/cli.md new file mode 100644 index 000000000..7c260c0ea --- /dev/null +++ b/docs/cli.md @@ -0,0 +1,898 @@ +# CLI Reference + +The OpenSpec CLI (`openspec`) provides terminal commands for project setup, validation, status inspection, and management. These commands complement the AI slash commands (like `/opsx:new`) documented in [Commands](commands.md). + +## Summary + +| Category | Commands | Purpose | +|----------|----------|---------| +| **Setup** | `init`, `update` | Initialize and update OpenSpec in your project | +| **Browsing** | `list`, `view`, `show` | Explore changes and specs | +| **Validation** | `validate` | Check changes and specs for issues | +| **Lifecycle** | `archive` | Finalize completed changes | +| **Workflow** | `status`, `instructions`, `templates`, `schemas` | Artifact-driven workflow support | +| **Schemas** | `schema init`, `schema fork`, `schema validate`, `schema which` | Create and manage custom workflows | +| **Config** | `config` | View and modify settings | +| **Utility** | `feedback`, `completion` | Feedback and shell integration | + +--- + +## Human vs Agent Commands + +Most CLI commands are designed for **human use** in a terminal. Some commands also support **agent/script use** via JSON output. + +### Human-Only Commands + +These commands are interactive and designed for terminal use: + +| Command | Purpose | +|---------|---------| +| `openspec init` | Initialize project (interactive prompts) | +| `openspec view` | Interactive dashboard | +| `openspec config edit` | Open config in editor | +| `openspec feedback` | Submit feedback via GitHub | +| `openspec completion install` | Install shell completions | + +### Agent-Compatible Commands + +These commands support `--json` output for programmatic use by AI agents and scripts: + +| Command | Human Use | Agent Use | +|---------|-----------|-----------| +| `openspec list` | Browse changes/specs | `--json` for structured data | +| `openspec show ` | Read content | `--json` for parsing | +| `openspec validate` | Check for issues | `--all --json` for bulk validation | +| `openspec status` | See artifact progress | `--json` for structured status | +| `openspec instructions` | Get next steps | `--json` for agent instructions | +| `openspec templates` | Find template paths | `--json` for path resolution | +| `openspec schemas` | List available schemas | `--json` for schema discovery | + +--- + +## Global Options + +These options work with all commands: + +| Option | Description | +|--------|-------------| +| `--version`, `-V` | Show version number | +| `--no-color` | Disable color output | +| `--help`, `-h` | Display help for command | + +--- + +## Setup Commands + +### `openspec init` + +Initialize OpenSpec in your project. Creates the folder structure and configures AI tool integrations. + +``` +openspec init [path] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `path` | No | Target directory (default: current directory) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--tools ` | Configure AI tools non-interactively. Use `all`, `none`, or comma-separated list | +| `--force` | Auto-cleanup legacy files without prompting | + +**Supported tools:** `amazon-q`, `antigravity`, `auggie`, `claude`, `cline`, `codex`, `codebuddy`, `continue`, `costrict`, `crush`, `cursor`, `factory`, `gemini`, `github-copilot`, `iflow`, `kilocode`, `opencode`, `qoder`, `qwen`, `roocode`, `windsurf` + +**Examples:** + +```bash +# Interactive initialization +openspec init + +# Initialize in a specific directory +openspec init ./my-project + +# Non-interactive: configure for Claude and Cursor +openspec init --tools claude,cursor + +# Configure for all supported tools +openspec init --tools all + +# Skip prompts and auto-cleanup legacy files +openspec init --force +``` + +**What it creates:** + +``` +openspec/ +├── specs/ # Your specifications (source of truth) +├── changes/ # Proposed changes +└── config.yaml # Project configuration + +.claude/skills/ # Claude Code skill files (if claude selected) +.cursor/rules/ # Cursor rules (if cursor selected) +... (other tool configs) +``` + +--- + +### `openspec update` + +Update OpenSpec instruction files after upgrading the CLI. Re-generates AI tool configuration files. + +``` +openspec update [path] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `path` | No | Target directory (default: current directory) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--force` | Force update even when files are up to date | + +**Example:** + +```bash +# Update instruction files after npm upgrade +npm update @fission-ai/openspec +openspec update +``` + +--- + +## Browsing Commands + +### `openspec list` + +List changes or specs in your project. + +``` +openspec list [options] +``` + +**Options:** + +| Option | Description | +|--------|-------------| +| `--specs` | List specs instead of changes | +| `--changes` | List changes (default) | +| `--sort ` | Sort by `recent` (default) or `name` | +| `--json` | Output as JSON | + +**Examples:** + +```bash +# List all active changes +openspec list + +# List all specs +openspec list --specs + +# JSON output for scripts +openspec list --json +``` + +**Output (text):** + +``` +Active changes: + add-dark-mode UI theme switching support + fix-login-bug Session timeout handling +``` + +--- + +### `openspec view` + +Display an interactive dashboard for exploring specs and changes. + +``` +openspec view +``` + +Opens a terminal-based interface for navigating your project's specifications and changes. + +--- + +### `openspec show` + +Display details of a change or spec. + +``` +openspec show [item-name] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `item-name` | No | Name of change or spec (prompts if omitted) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--type ` | Specify type: `change` or `spec` (auto-detected if unambiguous) | +| `--json` | Output as JSON | +| `--no-interactive` | Disable prompts | + +**Change-specific options:** + +| Option | Description | +|--------|-------------| +| `--deltas-only` | Show only delta specs (JSON mode) | + +**Spec-specific options:** + +| Option | Description | +|--------|-------------| +| `--requirements` | Show only requirements, exclude scenarios (JSON mode) | +| `--no-scenarios` | Exclude scenario content (JSON mode) | +| `-r, --requirement ` | Show specific requirement by 1-based index (JSON mode) | + +**Examples:** + +```bash +# Interactive selection +openspec show + +# Show a specific change +openspec show add-dark-mode + +# Show a specific spec +openspec show auth --type spec + +# JSON output for parsing +openspec show add-dark-mode --json +``` + +--- + +## Validation Commands + +### `openspec validate` + +Validate changes and specs for structural issues. + +``` +openspec validate [item-name] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `item-name` | No | Specific item to validate (prompts if omitted) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--all` | Validate all changes and specs | +| `--changes` | Validate all changes | +| `--specs` | Validate all specs | +| `--type ` | Specify type when name is ambiguous: `change` or `spec` | +| `--strict` | Enable strict validation mode | +| `--json` | Output as JSON | +| `--concurrency ` | Max parallel validations (default: 6, or `OPENSPEC_CONCURRENCY` env) | +| `--no-interactive` | Disable prompts | + +**Examples:** + +```bash +# Interactive validation +openspec validate + +# Validate a specific change +openspec validate add-dark-mode + +# Validate all changes +openspec validate --changes + +# Validate everything with JSON output (for CI/scripts) +openspec validate --all --json + +# Strict validation with increased parallelism +openspec validate --all --strict --concurrency 12 +``` + +**Output (text):** + +``` +Validating add-dark-mode... + ✓ proposal.md valid + ✓ specs/ui/spec.md valid + ⚠ design.md: missing "Technical Approach" section + +1 warning found +``` + +**Output (JSON):** + +```json +{ + "version": "1.0.0", + "results": { + "changes": [ + { + "name": "add-dark-mode", + "valid": true, + "warnings": ["design.md: missing 'Technical Approach' section"] + } + ] + }, + "summary": { + "total": 1, + "valid": 1, + "invalid": 0 + } +} +``` + +--- + +## Lifecycle Commands + +### `openspec archive` + +Archive a completed change and merge delta specs into main specs. + +``` +openspec archive [change-name] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Change to archive (prompts if omitted) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `-y, --yes` | Skip confirmation prompts | +| `--skip-specs` | Skip spec updates (for infrastructure/tooling/doc-only changes) | +| `--no-validate` | Skip validation (requires confirmation) | + +**Examples:** + +```bash +# Interactive archive +openspec archive + +# Archive specific change +openspec archive add-dark-mode + +# Archive without prompts (CI/scripts) +openspec archive add-dark-mode --yes + +# Archive a tooling change that doesn't affect specs +openspec archive update-ci-config --skip-specs +``` + +**What it does:** + +1. Validates the change (unless `--no-validate`) +2. Prompts for confirmation (unless `--yes`) +3. Merges delta specs into `openspec/specs/` +4. Moves change folder to `openspec/changes/archive/YYYY-MM-DD-/` + +--- + +## Workflow Commands + +These commands support the artifact-driven OPSX workflow. They're useful for both humans checking progress and agents determining next steps. + +### `openspec status` + +Display artifact completion status for a change. + +``` +openspec status [options] +``` + +**Options:** + +| Option | Description | +|--------|-------------| +| `--change ` | Change name (prompts if omitted) | +| `--schema ` | Schema override (auto-detected from change's config) | +| `--json` | Output as JSON | + +**Examples:** + +```bash +# Interactive status check +openspec status + +# Status for specific change +openspec status --change add-dark-mode + +# JSON for agent use +openspec status --change add-dark-mode --json +``` + +**Output (text):** + +``` +Change: add-dark-mode +Schema: spec-driven + +Artifacts: + ✓ proposal proposal.md exists + ✓ specs specs/ exists + ◆ design ready (requires: specs) + ○ tasks blocked (requires: design) + +Next: Create design using /opsx:continue +``` + +**Output (JSON):** + +```json +{ + "change": "add-dark-mode", + "schema": "spec-driven", + "artifacts": [ + {"id": "proposal", "status": "complete", "path": "proposal.md"}, + {"id": "specs", "status": "complete", "path": "specs/"}, + {"id": "design", "status": "ready", "requires": ["specs"]}, + {"id": "tasks", "status": "blocked", "requires": ["design"]} + ], + "next": "design" +} +``` + +--- + +### `openspec instructions` + +Get enriched instructions for creating an artifact or applying tasks. Used by AI agents to understand what to create next. + +``` +openspec instructions [artifact] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `artifact` | No | Artifact ID: `proposal`, `specs`, `design`, `tasks`, or `apply` | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--change ` | Change name (required in non-interactive mode) | +| `--schema ` | Schema override | +| `--json` | Output as JSON | + +**Special case:** Use `apply` as the artifact to get task implementation instructions. + +**Examples:** + +```bash +# Get instructions for next artifact +openspec instructions --change add-dark-mode + +# Get specific artifact instructions +openspec instructions design --change add-dark-mode + +# Get apply/implementation instructions +openspec instructions apply --change add-dark-mode + +# JSON for agent consumption +openspec instructions design --change add-dark-mode --json +``` + +**Output includes:** + +- Template content for the artifact +- Project context from config +- Content from dependency artifacts +- Per-artifact rules from config + +--- + +### `openspec templates` + +Show resolved template paths for all artifacts in a schema. + +``` +openspec templates [options] +``` + +**Options:** + +| Option | Description | +|--------|-------------| +| `--schema ` | Schema to inspect (default: `spec-driven`) | +| `--json` | Output as JSON | + +**Examples:** + +```bash +# Show template paths for default schema +openspec templates + +# Show templates for custom schema +openspec templates --schema tdd + +# JSON for programmatic use +openspec templates --json +``` + +**Output (text):** + +``` +Schema: spec-driven + +Templates: + proposal → ~/.openspec/schemas/spec-driven/templates/proposal.md + specs → ~/.openspec/schemas/spec-driven/templates/specs.md + design → ~/.openspec/schemas/spec-driven/templates/design.md + tasks → ~/.openspec/schemas/spec-driven/templates/tasks.md +``` + +--- + +### `openspec schemas` + +List available workflow schemas with their descriptions and artifact flows. + +``` +openspec schemas [options] +``` + +**Options:** + +| Option | Description | +|--------|-------------| +| `--json` | Output as JSON | + +**Example:** + +```bash +openspec schemas +``` + +**Output:** + +``` +Available schemas: + + spec-driven (package) + The default spec-driven development workflow + Flow: proposal → specs → design → tasks + + tdd (package) + Test-driven development workflow + Flow: spec → tests → implementation → docs + + my-custom (project) + Custom workflow for this project + Flow: research → proposal → tasks +``` + +--- + +## Schema Commands + +Commands for creating and managing custom workflow schemas. + +### `openspec schema init` + +Create a new project-local schema. + +``` +openspec schema init [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `name` | Yes | Schema name (kebab-case) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--description ` | Schema description | +| `--artifacts ` | Comma-separated artifact IDs (default: `proposal,specs,design,tasks`) | +| `--default` | Set as project default schema | +| `--no-default` | Don't prompt to set as default | +| `--force` | Overwrite existing schema | +| `--json` | Output as JSON | + +**Examples:** + +```bash +# Interactive schema creation +openspec schema init research-first + +# Non-interactive with specific artifacts +openspec schema init tdd-lite \ + --description "Lightweight TDD workflow" \ + --artifacts "spec,tests,implementation" \ + --default +``` + +**What it creates:** + +``` +openspec/schemas// +├── schema.yaml # Schema definition +└── templates/ + ├── proposal.md # Template for each artifact + ├── specs.md + ├── design.md + └── tasks.md +``` + +--- + +### `openspec schema fork` + +Copy an existing schema to your project for customization. + +``` +openspec schema fork [name] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `source` | Yes | Schema to copy | +| `name` | No | New schema name (default: `-custom`) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--force` | Overwrite existing destination | +| `--json` | Output as JSON | + +**Example:** + +```bash +# Fork the built-in spec-driven schema +openspec schema fork spec-driven my-workflow +``` + +--- + +### `openspec schema validate` + +Validate a schema's structure and templates. + +``` +openspec schema validate [name] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `name` | No | Schema to validate (validates all if omitted) | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--verbose` | Show detailed validation steps | +| `--json` | Output as JSON | + +**Example:** + +```bash +# Validate a specific schema +openspec schema validate my-workflow + +# Validate all schemas +openspec schema validate +``` + +--- + +### `openspec schema which` + +Show where a schema resolves from (useful for debugging precedence). + +``` +openspec schema which [name] [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `name` | No | Schema name | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--all` | List all schemas with their sources | +| `--json` | Output as JSON | + +**Example:** + +```bash +# Check where a schema comes from +openspec schema which spec-driven +``` + +**Output:** + +``` +spec-driven resolves from: package + Source: /usr/local/lib/node_modules/@fission-ai/openspec/schemas/spec-driven +``` + +**Schema precedence:** + +1. Project: `openspec/schemas//` +2. User: `~/.openspec/schemas//` +3. Package: Built-in schemas + +--- + +## Configuration Commands + +### `openspec config` + +View and modify global OpenSpec configuration. + +``` +openspec config [options] +``` + +**Subcommands:** + +| Subcommand | Description | +|------------|-------------| +| `path` | Show config file location | +| `list` | Show all current settings | +| `get ` | Get a specific value | +| `set ` | Set a value | +| `unset ` | Remove a key | +| `reset` | Reset to defaults | +| `edit` | Open in `$EDITOR` | + +**Examples:** + +```bash +# Show config file path +openspec config path + +# List all settings +openspec config list + +# Get a specific value +openspec config get telemetry.enabled + +# Set a value +openspec config set telemetry.enabled false + +# Set a string value explicitly +openspec config set user.name "My Name" --string + +# Remove a custom setting +openspec config unset user.name + +# Reset all configuration +openspec config reset --all --yes + +# Edit config in your editor +openspec config edit +``` + +--- + +## Utility Commands + +### `openspec feedback` + +Submit feedback about OpenSpec. Creates a GitHub issue. + +``` +openspec feedback [options] +``` + +**Arguments:** + +| Argument | Required | Description | +|----------|----------|-------------| +| `message` | Yes | Feedback message | + +**Options:** + +| Option | Description | +|--------|-------------| +| `--body ` | Detailed description | + +**Requirements:** GitHub CLI (`gh`) must be installed and authenticated. + +**Example:** + +```bash +openspec feedback "Add support for custom artifact types" \ + --body "I'd like to define my own artifact types beyond the built-in ones." +``` + +--- + +### `openspec completion` + +Manage shell completions for the OpenSpec CLI. + +``` +openspec completion [shell] +``` + +**Subcommands:** + +| Subcommand | Description | +|------------|-------------| +| `generate [shell]` | Output completion script to stdout | +| `install [shell]` | Install completion for your shell | +| `uninstall [shell]` | Remove installed completions | + +**Supported shells:** `bash`, `zsh`, `fish`, `powershell` + +**Examples:** + +```bash +# Install completions (auto-detects shell) +openspec completion install + +# Install for specific shell +openspec completion install zsh + +# Generate script for manual installation +openspec completion generate bash > ~/.bash_completion.d/openspec + +# Uninstall +openspec completion uninstall +``` + +--- + +## Exit Codes + +| Code | Meaning | +|------|---------| +| `0` | Success | +| `1` | Error (validation failure, missing files, etc.) | + +--- + +## Environment Variables + +| Variable | Description | +|----------|-------------| +| `OPENSPEC_CONCURRENCY` | Default concurrency for bulk validation (default: 6) | +| `EDITOR` or `VISUAL` | Editor for `openspec config edit` | +| `NO_COLOR` | Disable color output when set | + +--- + +## Related Documentation + +- [Commands](commands.md) - AI slash commands (`/opsx:new`, `/opsx:apply`, etc.) +- [Workflows](workflows.md) - Common patterns and when to use each command +- [Customization](customization.md) - Create custom schemas and templates +- [Getting Started](getting-started.md) - First-time setup guide diff --git a/docs/commands.md b/docs/commands.md new file mode 100644 index 000000000..1311bdb79 --- /dev/null +++ b/docs/commands.md @@ -0,0 +1,662 @@ +# Commands + +This is the reference for OpenSpec's slash commands. These commands are invoked in your AI coding assistant's chat interface (e.g., Claude Code, Cursor, Windsurf). + +For workflow patterns and when to use each command, see [Workflows](workflows.md). For CLI commands, see [CLI](cli.md). + +## Quick Reference + +| Command | Purpose | +|---------|---------| +| `/opsx:explore` | Think through ideas before committing to a change | +| `/opsx:new` | Start a new change | +| `/opsx:continue` | Create the next artifact based on dependencies | +| `/opsx:ff` | Fast-forward: create all planning artifacts at once | +| `/opsx:apply` | Implement tasks from the change | +| `/opsx:verify` | Validate implementation matches artifacts | +| `/opsx:sync` | Merge delta specs into main specs | +| `/opsx:archive` | Archive a completed change | +| `/opsx:bulk-archive` | Archive multiple changes at once | +| `/opsx:onboard` | Guided tutorial through the complete workflow | + +--- + +## Command Reference + +### `/opsx:explore` + +Think through ideas, investigate problems, and clarify requirements before committing to a change. + +**Syntax:** +``` +/opsx:explore [topic] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `topic` | No | What you want to explore or investigate | + +**What it does:** +- Opens an exploratory conversation with no structure required +- Investigates the codebase to answer questions +- Compares options and approaches +- Creates visual diagrams to clarify thinking +- Can transition to `/opsx:new` when insights crystallize + +**Example:** +```text +You: /opsx:explore + +AI: What would you like to explore? + +You: How should we handle authentication for the mobile app? + +AI: Let me investigate your current auth setup... + [Analyzes codebase] + + I see you're using session-based auth for the web app. + For mobile, we have three main options: + + 1. JWT tokens (stateless, works offline) + 2. OAuth2 (if you need third-party login) + 3. Extend current sessions (simpler, but requires connectivity) + + Your API already has CORS configured. Which direction interests you? + +You: Let's go with JWT. Can we start a change for that? + +AI: Ready when you are. Run /opsx:new add-jwt-auth to begin. +``` + +**Tips:** +- Use when requirements are unclear or you need to investigate +- No artifacts are created during exploration +- Good for comparing multiple approaches before deciding +- Can read files and search the codebase + +--- + +### `/opsx:new` + +Start a new change. Creates the change folder structure and scaffolds it with the selected schema. + +**Syntax:** +``` +/opsx:new [change-name] [--schema ] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Name for the change folder (prompted if not provided) | +| `--schema` | No | Workflow schema to use (default: from config or `spec-driven`) | + +**What it does:** +- Creates `openspec/changes//` directory +- Creates `.openspec.yaml` metadata file in the change folder +- Shows the first artifact template ready for creation +- Prompts for change name and schema if not provided + +**What it creates:** +``` +openspec/changes// +└── .openspec.yaml # Change metadata (schema, created date) +``` + +**Example:** +``` +You: /opsx:new add-dark-mode + +AI: Created openspec/changes/add-dark-mode/ + Schema: spec-driven + + Ready to create: proposal + Use /opsx:continue to create it, or /opsx:ff to create all artifacts. +``` + +**Example with schema:** +``` +You: /opsx:new write-tests --schema tdd + +AI: Created openspec/changes/write-tests/ + Schema: tdd + + Ready to create: spec +``` + +**Tips:** +- Use descriptive names: `add-feature`, `fix-bug`, `refactor-module` +- Avoid generic names like `update`, `changes`, `wip` +- Schema can also be set in project config (`openspec/config.yaml`) + +--- + +### `/opsx:continue` + +Create the next artifact in the dependency chain. Creates one artifact at a time for incremental progress. + +**Syntax:** +``` +/opsx:continue [change-name] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Which change to continue (inferred from context if not provided) | + +**What it does:** +- Queries the artifact dependency graph +- Shows which artifacts are ready vs blocked +- Creates the first ready artifact +- Reads dependency files for context +- Shows what becomes available after creation + +**Example:** +``` +You: /opsx:continue + +AI: Change: add-dark-mode + + Artifact status: + ✓ proposal (done) + ◆ specs (ready) + ◆ design (ready) + ○ tasks (blocked - needs: specs) + + Creating specs... + + [Reads proposal.md, creates specs based on requirements] + + ✓ Created openspec/changes/add-dark-mode/specs/ui/spec.md + + Now available: tasks + Run /opsx:continue to create the next artifact. +``` + +**Tips:** +- Use when you want to review each artifact before proceeding +- Good for complex changes where you want control +- Multiple artifacts may become ready simultaneously +- You can edit created artifacts before continuing + +--- + +### `/opsx:ff` + +Fast-forward through artifact creation. Creates all planning artifacts at once. + +**Syntax:** +``` +/opsx:ff [change-name] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Which change to fast-forward (inferred from context if not provided) | + +**What it does:** +- Creates all artifacts in dependency order +- Tracks progress via todo list +- Stops when all `apply-required` artifacts are complete +- Reads each dependency before creating the next artifact + +**Example:** +``` +You: /opsx:ff add-dark-mode + +AI: Fast-forwarding add-dark-mode... + + ✓ Creating proposal.md + ✓ Creating specs/ui/spec.md + ✓ Creating design.md + ✓ Creating tasks.md + + All planning artifacts complete! + Ready for implementation. Run /opsx:apply to begin. +``` + +**Tips:** +- Use when you have a clear picture of what you're building +- Faster than `/opsx:continue` for straightforward changes +- You can still edit artifacts afterward +- Good for small to medium features + +--- + +### `/opsx:apply` + +Implement tasks from the change. Works through the task list, writing code and checking off items. + +**Syntax:** +``` +/opsx:apply [change-name] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Which change to implement (inferred from context if not provided) | + +**What it does:** +- Reads `tasks.md` and identifies incomplete tasks +- Works through tasks one by one +- Writes code, creates files, runs tests as needed +- Marks tasks complete with checkboxes `[x]` + +**Example:** +``` +You: /opsx:apply + +AI: Implementing add-dark-mode... + + Reading tasks.md: + - [ ] 1.1 Create ThemeContext + - [ ] 1.2 Add CSS custom properties + - [ ] 1.3 Implement localStorage persistence + + Working on 1.1: Create ThemeContext... + [Creates src/context/ThemeContext.tsx] + + ✓ 1.1 Complete + + Working on 1.2: Add CSS custom properties... + [Updates src/styles/globals.css] + + ✓ 1.2 Complete + ... +``` + +**Tips:** +- Can resume where you left off if interrupted +- Use for parallel changes by specifying the change name +- Completion state is tracked in `tasks.md` checkboxes + +--- + +### `/opsx:verify` + +Validate that implementation matches your change artifacts. Checks completeness, correctness, and coherence. + +**Syntax:** +``` +/opsx:verify [change-name] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Which change to verify (inferred from context if not provided) | + +**What it does:** +- Checks three dimensions of implementation quality +- Searches codebase for implementation evidence +- Reports issues categorized as CRITICAL, WARNING, or SUGGESTION +- Does not block archive, but surfaces issues + +**Verification dimensions:** + +| Dimension | What it validates | +|-----------|-------------------| +| **Completeness** | All tasks done, all requirements implemented, scenarios covered | +| **Correctness** | Implementation matches spec intent, edge cases handled | +| **Coherence** | Design decisions reflected in code, patterns consistent | + +**Example:** +``` +You: /opsx:verify + +AI: Verifying add-dark-mode... + + COMPLETENESS + ✓ All 8 tasks in tasks.md are checked + ✓ All requirements in specs have corresponding code + ⚠ Scenario "System preference detection" has no test coverage + + CORRECTNESS + ✓ Implementation matches spec intent + ✓ Edge cases from scenarios are handled + ✓ Error states match spec definitions + + COHERENCE + ✓ Design decisions reflected in code structure + ✓ Naming conventions consistent with design.md + ⚠ Design mentions "CSS variables" but implementation uses Tailwind classes + + SUMMARY + ───────────────────────────── + Critical issues: 0 + Warnings: 2 + Ready to archive: Yes (with warnings) + + Recommendations: + 1. Add test for system preference detection + 2. Update design.md to reflect Tailwind usage, or refactor to use CSS variables +``` + +**Tips:** +- Run before archiving to catch mismatches early +- Warnings don't block archive but indicate potential issues +- Good for reviewing AI's work before committing +- Can reveal drift between artifacts and implementation + +--- + +### `/opsx:sync` + +**Optional command.** Merge delta specs from a change into main specs. Archive will prompt to sync if needed, so you typically don't need to run this manually. + +**Syntax:** +``` +/opsx:sync [change-name] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Which change to sync (inferred from context if not provided) | + +**What it does:** +- Reads delta specs from change folder +- Parses ADDED/MODIFIED/REMOVED/RENAMED sections +- Merges changes into main `openspec/specs/` directory +- Preserves existing content not mentioned in delta +- Does not archive the change (remains active) + +**Example:** +```text +You: /opsx:sync + +AI: Syncing add-dark-mode delta specs... + + Reading: openspec/changes/add-dark-mode/specs/ui/spec.md + Target: openspec/specs/ui/spec.md + + Changes to apply: + ✓ ADDED: Theme Selection requirement (2 scenarios) + ✓ ADDED: Accessibility requirement (1 scenario) + + Merging... + ✓ openspec/specs/ui/spec.md updated + + Change remains active. Run /opsx:archive when ready to complete. +``` + +**When to use manually:** + +| Scenario | Use sync? | +|----------|-----------| +| Long-running change, want specs in main before archiving | Yes | +| Multiple parallel changes need the updated base specs | Yes | +| Want to preview/review the merge separately | Yes | +| Quick change, going straight to archive | No (archive handles it) | + +**Tips:** +- Sync is intelligent, not copy-paste +- Can add scenarios to existing requirements without duplicating +- Change stays active after sync (not archived) +- Most users will never need to call this directly—archive prompts if needed + +--- + +### `/opsx:archive` + +Archive a completed change. Finalizes the change and moves it to the archive folder. + +**Syntax:** +``` +/opsx:archive [change-name] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-name` | No | Which change to archive (inferred from context if not provided) | + +**What it does:** +- Checks artifact completion status +- Checks task completion (warns if incomplete) +- Offers to sync delta specs if not already synced +- Moves change folder to `openspec/changes/archive/YYYY-MM-DD-/` +- Preserves all artifacts for audit trail + +**Example:** +```text +You: /opsx:archive + +AI: Archiving add-dark-mode... + + Artifact status: + ✓ proposal.md exists + ✓ specs/ exists + ✓ design.md exists + ✓ tasks.md exists (8/8 tasks complete) + + Delta specs: Not yet synced + → Sync now? (recommended) + +You: Yes + +AI: ✓ Synced specs to openspec/specs/ui/spec.md + ✓ Moved to openspec/changes/archive/2025-01-24-add-dark-mode/ + + Change archived successfully. +``` + +**Tips:** +- Archive won't block on incomplete tasks, but will warn +- Delta specs can be synced during archive or beforehand +- Archived changes are preserved for history +- Use `/opsx:verify` first to catch issues + +--- + +### `/opsx:bulk-archive` + +Archive multiple completed changes at once. Handles spec conflicts between changes. + +**Syntax:** +``` +/opsx:bulk-archive [change-names...] +``` + +**Arguments:** +| Argument | Required | Description | +|----------|----------|-------------| +| `change-names` | No | Specific changes to archive (prompts to select if not provided) | + +**What it does:** +- Lists all completed changes +- Validates each change before archiving +- Detects spec conflicts across changes +- Resolves conflicts by checking what's actually implemented +- Archives in chronological order + +**Example:** +``` +You: /opsx:bulk-archive + +AI: Found 3 completed changes: + - add-dark-mode (8/8 tasks complete) + - fix-login-bug (3/3 tasks complete) + - update-footer (2/2 tasks complete) + + Checking for spec conflicts... + ⚠ add-dark-mode and update-footer both touch specs/ui/ + + Inspecting codebase to resolve... + Both changes are implemented. Will merge in chronological order: + 1. add-dark-mode (created Jan 20) + 2. update-footer (created Jan 22) + + Archive all 3 changes? + +You: Yes + +AI: ✓ Archived add-dark-mode + ✓ Archived fix-login-bug + ✓ Archived update-footer + Specs merged: add-dark-mode → update-footer +``` + +**Tips:** +- Good for parallel work streams +- Conflict resolution is agentic (checks codebase) +- Changes are archived in order of creation +- Prompts before overwriting spec content + +--- + +### `/opsx:onboard` + +Guided onboarding through the complete OpenSpec workflow. An interactive tutorial using your actual codebase. + +**Syntax:** +``` +/opsx:onboard +``` + +**What it does:** +- Walks through a complete workflow cycle with narration +- Scans your codebase for real improvement opportunities +- Creates an actual change with real artifacts +- Implements actual work (small, safe changes) +- Archives the completed change +- Explains each step as it happens + +**Phases:** +1. Welcome and codebase analysis +2. Finding an improvement opportunity +3. Creating a change (`/opsx:new`) +4. Writing the proposal +5. Creating specs +6. Writing the design +7. Creating tasks +8. Implementing tasks (`/opsx:apply`) +9. Verifying implementation +10. Archiving the change +11. Summary and next steps + +**Example:** +``` +You: /opsx:onboard + +AI: Welcome to OpenSpec! + + I'll walk you through the complete workflow using your actual codebase. + We'll find something small to improve, create a proper change for it, + implement it, and archive it. + + Let me scan your codebase for opportunities... + + [Analyzes codebase] + + I found a few things we could work on: + 1. Add input validation to the contact form + 2. Improve error messages in the auth flow + 3. Add loading states to async buttons + + Which interests you? (or suggest something else) +``` + +**Tips:** +- Best for new users learning the workflow +- Uses real code, not toy examples +- Creates a real change you can keep or discard +- Takes 15-30 minutes to complete + +--- + +## Command Syntax by AI Tool + +Different AI tools use slightly different command syntax. Use the format that matches your tool: + +| Tool | Syntax Example | +|------|----------------| +| Claude Code | `/opsx:new`, `/opsx:apply` | +| Cursor | `/opsx-new`, `/opsx-apply` | +| Windsurf | `/opsx-new`, `/opsx-apply` | +| Copilot | `/opsx-new`, `/opsx-apply` | + +The functionality is identical regardless of syntax. + +--- + +## Legacy Commands + +These commands use the older "all-at-once" workflow. They still work but OPSX commands are recommended. + +| Command | What it does | +|---------|--------------| +| `/openspec:proposal` | Create all artifacts at once (proposal, specs, design, tasks) | +| `/openspec:apply` | Implement the change | +| `/openspec:archive` | Archive the change | + +**When to use legacy commands:** +- Existing projects using the old workflow +- Simple changes where you don't need incremental artifact creation +- Preference for the all-or-nothing approach + +**Migrating to OPSX:** +Legacy changes can be continued with OPSX commands. The artifact structure is compatible. + +--- + +## Troubleshooting + +### "Change not found" + +The command couldn't identify which change to work on. + +**Solutions:** +- Specify the change name explicitly: `/opsx:apply add-dark-mode` +- Check that the change folder exists: `openspec list` +- Verify you're in the right project directory + +### "No artifacts ready" + +All artifacts are either complete or blocked by missing dependencies. + +**Solutions:** +- Run `openspec status --change ` to see what's blocking +- Check if required artifacts exist +- Create missing dependency artifacts first + +### "Schema not found" + +The specified schema doesn't exist. + +**Solutions:** +- List available schemas: `openspec schemas` +- Check spelling of schema name +- Create the schema if it's custom: `openspec schema init ` + +### Commands not recognized + +The AI tool doesn't recognize OpenSpec commands. + +**Solutions:** +- Ensure OpenSpec is initialized: `openspec init` +- Regenerate skills: `openspec update` +- Check that `.claude/skills/` directory exists (for Claude Code) +- Restart your AI tool to pick up new skills + +### Artifacts not generating properly + +The AI creates incomplete or incorrect artifacts. + +**Solutions:** +- Add project context in `openspec/config.yaml` +- Add per-artifact rules for specific guidance +- Provide more detail in your change description +- Use `/opsx:continue` instead of `/opsx:ff` for more control + +--- + +## Next Steps + +- [Workflows](workflows.md) - Common patterns and when to use each command +- [CLI](cli.md) - Terminal commands for management and validation +- [Customization](customization.md) - Create custom schemas and workflows diff --git a/docs/concepts.md b/docs/concepts.md new file mode 100644 index 000000000..4972ff2b4 --- /dev/null +++ b/docs/concepts.md @@ -0,0 +1,592 @@ +# Concepts + +This guide explains the core ideas behind OpenSpec and how they fit together. For practical usage, see [Getting Started](getting-started.md) and [Workflows](workflows.md). + +## Philosophy + +OpenSpec is built around four principles: + +``` +fluid not rigid — no phase gates, work on what makes sense +iterative not waterfall — learn as you build, refine as you go +easy not complex — lightweight setup, minimal ceremony +brownfield-first — works with existing codebases, not just greenfield +``` + +### Why These Principles Matter + +**Fluid not rigid.** Traditional spec systems lock you into phases: first you plan, then you implement, then you're done. OpenSpec is more flexible — you can create artifacts in any order that makes sense for your work. + +**Iterative not waterfall.** Requirements change. Understanding deepens. What seemed like a good approach at the start might not hold up after you see the codebase. OpenSpec embraces this reality. + +**Easy not complex.** Some spec frameworks require extensive setup, rigid formats, or heavyweight processes. OpenSpec stays out of your way. Initialize in seconds, start working immediately, customize only if you need to. + +**Brownfield-first.** Most software work isn't building from scratch — it's modifying existing systems. OpenSpec's delta-based approach makes it easy to specify changes to existing behavior, not just describe new systems. + +## The Big Picture + +OpenSpec organizes your work into two main areas: + +``` +┌─────────────────────────────────────────────────────────────────┐ +│ openspec/ │ +│ │ +│ ┌─────────────────────┐ ┌──────────────────────────────┐ │ +│ │ specs/ │ │ changes/ │ │ +│ │ │ │ │ │ +│ │ Source of truth │◄─────│ Proposed modifications │ │ +│ │ How your system │ merge│ Each change = one folder │ │ +│ │ currently works │ │ Contains artifacts + deltas │ │ +│ │ │ │ │ │ +│ └─────────────────────┘ └──────────────────────────────┘ │ +│ │ +└─────────────────────────────────────────────────────────────────┘ +``` + +**Specs** are the source of truth — they describe how your system currently behaves. + +**Changes** are proposed modifications — they live in separate folders until you're ready to merge them. + +This separation is key. You can work on multiple changes in parallel without conflicts. You can review a change before it affects the main specs. And when you archive a change, its deltas merge cleanly into the source of truth. + +## Specs + +Specs describe your system's behavior using structured requirements and scenarios. + +### Structure + +``` +openspec/specs/ +├── auth/ +│ └── spec.md # Authentication behavior +├── payments/ +│ └── spec.md # Payment processing +├── notifications/ +│ └── spec.md # Notification system +└── ui/ + └── spec.md # UI behavior and themes +``` + +Organize specs by domain — logical groupings that make sense for your system. Common patterns: + +- **By feature area**: `auth/`, `payments/`, `search/` +- **By component**: `api/`, `frontend/`, `workers/` +- **By bounded context**: `ordering/`, `fulfillment/`, `inventory/` + +### Spec Format + +A spec contains requirements, and each requirement has scenarios: + +```markdown +# Auth Specification + +## Purpose +Authentication and session management for the application. + +## Requirements + +### Requirement: User Authentication +The system SHALL issue a JWT token upon successful login. + +#### Scenario: Valid credentials +- GIVEN a user with valid credentials +- WHEN the user submits login form +- THEN a JWT token is returned +- AND the user is redirected to dashboard + +#### Scenario: Invalid credentials +- GIVEN invalid credentials +- WHEN the user submits login form +- THEN an error message is displayed +- AND no token is issued + +### Requirement: Session Expiration +The system MUST expire sessions after 30 minutes of inactivity. + +#### Scenario: Idle timeout +- GIVEN an authenticated session +- WHEN 30 minutes pass without activity +- THEN the session is invalidated +- AND the user must re-authenticate +``` + +**Key elements:** + +| Element | Purpose | +|---------|---------| +| `## Purpose` | High-level description of this spec's domain | +| `### Requirement:` | A specific behavior the system must have | +| `#### Scenario:` | A concrete example of the requirement in action | +| SHALL/MUST/SHOULD | RFC 2119 keywords indicating requirement strength | + +### Why Structure Specs This Way + +**Requirements are the "what"** — they state what the system should do without specifying implementation. + +**Scenarios are the "when"** — they provide concrete examples that can be verified. Good scenarios: +- Are testable (you could write an automated test for them) +- Cover both happy path and edge cases +- Use Given/When/Then or similar structured format + +**RFC 2119 keywords** (SHALL, MUST, SHOULD, MAY) communicate intent: +- **MUST/SHALL** — absolute requirement +- **SHOULD** — recommended, but exceptions exist +- **MAY** — optional + +## Changes + +A change is a proposed modification to your system, packaged as a folder with everything needed to understand and implement it. + +### Change Structure + +``` +openspec/changes/add-dark-mode/ +├── proposal.md # Why and what +├── design.md # How (technical approach) +├── tasks.md # Implementation checklist +├── .openspec.yaml # Change metadata (optional) +└── specs/ # Delta specs + └── ui/ + └── spec.md # What's changing in ui/spec.md +``` + +Each change is self-contained. It has: +- **Artifacts** — documents that capture intent, design, and tasks +- **Delta specs** — specifications for what's being added, modified, or removed +- **Metadata** — optional configuration for this specific change + +### Why Changes Are Folders + +Packaging a change as a folder has several benefits: + +1. **Everything together.** Proposal, design, tasks, and specs live in one place. No hunting through different locations. + +2. **Parallel work.** Multiple changes can exist simultaneously without conflicting. Work on `add-dark-mode` while `fix-auth-bug` is also in progress. + +3. **Clean history.** When archived, changes move to `changes/archive/` with their full context preserved. You can look back and understand not just what changed, but why. + +4. **Review-friendly.** A change folder is easy to review — open it, read the proposal, check the design, see the spec deltas. + +## Artifacts + +Artifacts are the documents within a change that guide the work. + +### The Artifact Flow + +``` +proposal ──────► specs ──────► design ──────► tasks ──────► implement + │ │ │ │ + why what how steps + + scope changes approach to take +``` + +Artifacts build on each other. Each artifact provides context for the next. + +### Artifact Types + +#### Proposal (`proposal.md`) + +The proposal captures **intent**, **scope**, and **approach** at a high level. + +```markdown +# Proposal: Add Dark Mode + +## Intent +Users have requested a dark mode option to reduce eye strain +during nighttime usage and match system preferences. + +## Scope +In scope: +- Theme toggle in settings +- System preference detection +- Persist preference in localStorage + +Out of scope: +- Custom color themes (future work) +- Per-page theme overrides + +## Approach +Use CSS custom properties for theming with a React context +for state management. Detect system preference on first load, +allow manual override. +``` + +**When to update the proposal:** +- Scope changes (narrowing or expanding) +- Intent clarifies (better understanding of the problem) +- Approach fundamentally shifts + +#### Specs (delta specs in `specs/`) + +Delta specs describe **what's changing** relative to the current specs. See [Delta Specs](#delta-specs) below. + +#### Design (`design.md`) + +The design captures **technical approach** and **architecture decisions**. + +```markdown +# Design: Add Dark Mode + +## Technical Approach +Theme state managed via React Context to avoid prop drilling. +CSS custom properties enable runtime switching without class toggling. + +## Architecture Decisions + +### Decision: Context over Redux +Using React Context for theme state because: +- Simple binary state (light/dark) +- No complex state transitions +- Avoids adding Redux dependency + +### Decision: CSS Custom Properties +Using CSS variables instead of CSS-in-JS because: +- Works with existing stylesheet +- No runtime overhead +- Browser-native solution + +## Data Flow +``` +ThemeProvider (context) + │ + ▼ +ThemeToggle ◄──► localStorage + │ + ▼ +CSS Variables (applied to :root) +``` + +## File Changes +- `src/contexts/ThemeContext.tsx` (new) +- `src/components/ThemeToggle.tsx` (new) +- `src/styles/globals.css` (modified) +``` + +**When to update the design:** +- Implementation reveals the approach won't work +- Better solution discovered +- Dependencies or constraints change + +#### Tasks (`tasks.md`) + +Tasks are the **implementation checklist** — concrete steps with checkboxes. + +```markdown +# Tasks + +## 1. Theme Infrastructure +- [ ] 1.1 Create ThemeContext with light/dark state +- [ ] 1.2 Add CSS custom properties for colors +- [ ] 1.3 Implement localStorage persistence +- [ ] 1.4 Add system preference detection + +## 2. UI Components +- [ ] 2.1 Create ThemeToggle component +- [ ] 2.2 Add toggle to settings page +- [ ] 2.3 Update Header to include quick toggle + +## 3. Styling +- [ ] 3.1 Define dark theme color palette +- [ ] 3.2 Update components to use CSS variables +- [ ] 3.3 Test contrast ratios for accessibility +``` + +**Task best practices:** +- Group related tasks under headings +- Use hierarchical numbering (1.1, 1.2, etc.) +- Keep tasks small enough to complete in one session +- Check tasks off as you complete them + +## Delta Specs + +Delta specs are the key concept that makes OpenSpec work for brownfield development. They describe **what's changing** rather than restating the entire spec. + +### The Format + +```markdown +# Delta for Auth + +## ADDED Requirements + +### Requirement: Two-Factor Authentication +The system MUST support TOTP-based two-factor authentication. + +#### Scenario: 2FA enrollment +- GIVEN a user without 2FA enabled +- WHEN the user enables 2FA in settings +- THEN a QR code is displayed for authenticator app setup +- AND the user must verify with a code before activation + +#### Scenario: 2FA login +- GIVEN a user with 2FA enabled +- WHEN the user submits valid credentials +- THEN an OTP challenge is presented +- AND login completes only after valid OTP + +## MODIFIED Requirements + +### Requirement: Session Expiration +The system MUST expire sessions after 15 minutes of inactivity. +(Previously: 30 minutes) + +#### Scenario: Idle timeout +- GIVEN an authenticated session +- WHEN 15 minutes pass without activity +- THEN the session is invalidated + +## REMOVED Requirements + +### Requirement: Remember Me +(Deprecated in favor of 2FA. Users should re-authenticate each session.) +``` + +### Delta Sections + +| Section | Meaning | What Happens on Archive | +|---------|---------|------------------------| +| `## ADDED Requirements` | New behavior | Appended to main spec | +| `## MODIFIED Requirements` | Changed behavior | Replaces existing requirement | +| `## REMOVED Requirements` | Deprecated behavior | Deleted from main spec | + +### Why Deltas Instead of Full Specs + +**Clarity.** A delta shows exactly what's changing. Reading a full spec, you'd have to diff it mentally against the current version. + +**Conflict avoidance.** Two changes can touch the same spec file without conflicting, as long as they modify different requirements. + +**Review efficiency.** Reviewers see the change, not the unchanged context. Focus on what matters. + +**Brownfield fit.** Most work modifies existing behavior. Deltas make modifications first-class, not an afterthought. + +## Schemas + +Schemas define the artifact types and their dependencies for a workflow. + +### How Schemas Work + +```yaml +# openspec/schemas/spec-driven/schema.yaml +name: spec-driven +artifacts: + - id: proposal + generates: proposal.md + requires: [] # No dependencies, can create first + + - id: specs + generates: specs/**/*.md + requires: [proposal] # Needs proposal before creating + + - id: design + generates: design.md + requires: [proposal] # Can create in parallel with specs + + - id: tasks + generates: tasks.md + requires: [specs, design] # Needs both specs and design first +``` + +**Artifacts form a dependency graph:** + +``` + proposal + (root node) + │ + ┌─────────────┴─────────────┐ + │ │ + ▼ ▼ + specs design + (requires: (requires: + proposal) proposal) + │ │ + └─────────────┬─────────────┘ + │ + ▼ + tasks + (requires: + specs, design) +``` + +**Dependencies are enablers, not gates.** They show what's possible to create, not what you must create next. You can skip design if you don't need it. You can create specs before or after design — both depend only on proposal. + +### Built-in Schemas + +**spec-driven** (default) + +The standard workflow for spec-driven development: + +``` +proposal → specs → design → tasks → implement +``` + +Best for: Most feature work where you want to agree on specs before implementation. + +**tdd** + +Test-driven development workflow: + +``` +spec → tests → implementation → docs +``` + +Best for: Teams practicing TDD who write tests before implementation. + +### Custom Schemas + +Create custom schemas for your team's workflow: + +```bash +# Create from scratch +openspec schema init research-first + +# Or fork an existing one +openspec schema fork spec-driven research-first +``` + +**Example custom schema:** + +```yaml +# openspec/schemas/research-first/schema.yaml +name: research-first +artifacts: + - id: research + generates: research.md + requires: [] # Do research first + + - id: proposal + generates: proposal.md + requires: [research] # Proposal informed by research + + - id: tasks + generates: tasks.md + requires: [proposal] # Skip specs/design, go straight to tasks +``` + +See [Customization](customization.md) for full details on creating and using custom schemas. + +## Archive + +Archiving completes a change by merging its delta specs into the main specs and preserving the change for history. + +### What Happens When You Archive + +``` +Before archive: + +openspec/ +├── specs/ +│ └── auth/ +│ └── spec.md ◄────────────────┐ +└── changes/ │ + └── add-2fa/ │ + ├── proposal.md │ + ├── design.md │ merge + ├── tasks.md │ + └── specs/ │ + └── auth/ │ + └── spec.md ─────────┘ + + +After archive: + +openspec/ +├── specs/ +│ └── auth/ +│ └── spec.md # Now includes 2FA requirements +└── changes/ + └── archive/ + └── 2025-01-24-add-2fa/ # Preserved for history + ├── proposal.md + ├── design.md + ├── tasks.md + └── specs/ + └── auth/ + └── spec.md +``` + +### The Archive Process + +1. **Merge deltas.** Each delta spec section (ADDED/MODIFIED/REMOVED) is applied to the corresponding main spec. + +2. **Move to archive.** The change folder moves to `changes/archive/` with a date prefix for chronological ordering. + +3. **Preserve context.** All artifacts remain intact in the archive. You can always look back to understand why a change was made. + +### Why Archive Matters + +**Clean state.** Active changes (`changes/`) shows only work in progress. Completed work moves out of the way. + +**Audit trail.** The archive preserves the full context of every change — not just what changed, but the proposal explaining why, the design explaining how, and the tasks showing the work done. + +**Spec evolution.** Specs grow organically as changes are archived. Each archive merges its deltas, building up a comprehensive specification over time. + +## How It All Fits Together + +``` +┌─────────────────────────────────────────────────────────────────────────────┐ +│ OPENSPEC FLOW │ +│ │ +│ ┌────────────────┐ │ +│ │ 1. START │ /opsx:new creates a change folder │ +│ │ CHANGE │ │ +│ └───────┬────────┘ │ +│ │ │ +│ ▼ │ +│ ┌────────────────┐ │ +│ │ 2. CREATE │ /opsx:ff or /opsx:continue │ +│ │ ARTIFACTS │ Creates proposal → specs → design → tasks │ +│ │ │ (based on schema dependencies) │ +│ └───────┬────────┘ │ +│ │ │ +│ ▼ │ +│ ┌────────────────┐ │ +│ │ 3. IMPLEMENT │ /opsx:apply │ +│ │ TASKS │ Work through tasks, checking them off │ +│ │ │◄──── Update artifacts as you learn │ +│ └───────┬────────┘ │ +│ │ │ +│ ▼ │ +│ ┌────────────────┐ │ +│ │ 4. VERIFY │ /opsx:verify (optional) │ +│ │ WORK │ Check implementation matches specs │ +│ └───────┬────────┘ │ +│ │ │ +│ ▼ │ +│ ┌────────────────┐ ┌──────────────────────────────────────────────┐ │ +│ │ 5. ARCHIVE │────►│ Delta specs merge into main specs │ │ +│ │ CHANGE │ │ Change folder moves to archive/ │ │ +│ └────────────────┘ │ Specs are now the updated source of truth │ │ +│ └──────────────────────────────────────────────┘ │ +│ │ +└─────────────────────────────────────────────────────────────────────────────┘ +``` + +**The virtuous cycle:** + +1. Specs describe current behavior +2. Changes propose modifications (as deltas) +3. Implementation makes the changes real +4. Archive merges deltas into specs +5. Specs now describe the new behavior +6. Next change builds on updated specs + +## Glossary + +| Term | Definition | +|------|------------| +| **Artifact** | A document within a change (proposal, design, tasks, or delta specs) | +| **Archive** | The process of completing a change and merging its deltas into main specs | +| **Change** | A proposed modification to the system, packaged as a folder with artifacts | +| **Delta spec** | A spec that describes changes (ADDED/MODIFIED/REMOVED) relative to current specs | +| **Domain** | A logical grouping for specs (e.g., `auth/`, `payments/`) | +| **Requirement** | A specific behavior the system must have | +| **Scenario** | A concrete example of a requirement, typically in Given/When/Then format | +| **Schema** | A definition of artifact types and their dependencies | +| **Spec** | A specification describing system behavior, containing requirements and scenarios | +| **Source of truth** | The `openspec/specs/` directory, containing the current agreed-upon behavior | + +## Next Steps + +- [Getting Started](getting-started.md) - Practical first steps +- [Workflows](workflows.md) - Common patterns and when to use each +- [Commands](commands.md) - Full command reference +- [Customization](customization.md) - Create custom schemas and configure your project diff --git a/docs/customization.md b/docs/customization.md new file mode 100644 index 000000000..cd64bb7fb --- /dev/null +++ b/docs/customization.md @@ -0,0 +1,184 @@ +# Customization + +OpenSpec provides two levels of customization: + +1. **Project Config** (`openspec/config.yaml`) - Lightweight per-project customization for default schemas, shared context, and per-artifact rules +2. **Schema Overrides** - Full schema and template customization via XDG directories + +--- + +## Project Configuration + +The `openspec/config.yaml` file provides a lightweight customization layer that lets teams: + +- **Set a default schema** - New changes automatically use this schema instead of specifying `--schema` every time +- **Inject project context** - Shared context (tech stack, conventions) shown to AI when creating any artifact +- **Add per-artifact rules** - Custom rules that only apply to specific artifacts (e.g., proposal, specs) + +### Creating a Config + +You can create the config through the interactive setup: + +```bash +openspec init +``` + +Or create it manually: + +```yaml +# openspec/config.yaml +schema: spec-driven + +context: | + Tech stack: TypeScript, React, Node.js, PostgreSQL + API style: RESTful, documented in docs/api.md + Testing: Jest + React Testing Library + We value backwards compatibility for all public APIs + +rules: + proposal: + - Include rollback plan + - Identify affected teams + specs: + - Use Given/When/Then format + - Reference existing patterns before inventing new ones +``` + +### How Config Affects Workflows + +**Default schema selection:** + +```bash +# Without config: must specify schema +openspec new change my-feature --schema spec-driven + +# With config: schema is automatic +openspec new change my-feature +``` + +**Context and rules injection:** + +When generating instructions for an artifact, context and rules are injected: + +```xml + +Tech stack: TypeScript, React, Node.js, PostgreSQL +API style: RESTful, documented in docs/api.md +... + + + +- Include rollback plan +- Identify affected teams + + + +``` + +- **Context** appears in ALL artifacts +- **Rules** ONLY appear for the matching artifact + +### Schema Resolution Precedence + +1. CLI flag wins: `openspec new change feature --schema tdd` +2. Change metadata (if `.openspec.yaml` specifies schema) +3. Project config (`openspec/config.yaml`) +4. Default schema (`spec-driven`) + +### Error Handling + +The config provides graceful error handling: + +```bash +# Typo in schema name - shows suggestions +# Schema 'spec-drivne' not found +# Did you mean: spec-driven (built-in) + +# Unknown artifact ID in rules - warns but continues +# ⚠️ Unknown artifact ID in rules: "testplan". Valid IDs for schema "spec-driven": ... +``` + +--- + +## Schema Overrides + +For deeper customization, you can override entire schemas or templates. + +### How Schema Resolution Works + +OpenSpec uses a 2-level schema resolution system following the XDG Base Directory Specification: + +1. **User override**: `${XDG_DATA_HOME}/openspec/schemas//` +2. **Package built-in**: `/schemas//` + +When a schema is requested, the resolver checks the user directory first. If found, that entire schema directory is used. Otherwise, it falls back to the package's built-in schema. + +### Override Directories + +| Platform | Path | +|----------|------| +| macOS/Linux | `~/.local/share/openspec/schemas/` | +| Windows | `%LOCALAPPDATA%\openspec\schemas\` | +| All (if set) | `$XDG_DATA_HOME/openspec/schemas/` | + +### Manual Schema Override + +To override the default `spec-driven` schema: + +**1. Create the directory structure:** + +```bash +# macOS/Linux +mkdir -p ~/.local/share/openspec/schemas/spec-driven/templates +``` + +**2. Find and copy the default schema files:** + +```bash +# Find the package location +npm list -g openspec --parseable + +# Copy files from the package's schemas/ directory +cp /schemas/spec-driven/schema.yaml ~/.local/share/openspec/schemas/spec-driven/ +cp /schemas/spec-driven/templates/*.md ~/.local/share/openspec/schemas/spec-driven/templates/ +``` + +**3. Modify the copied files:** + +Edit `schema.yaml` to change the workflow structure: + +```yaml +name: spec-driven +version: 1 +description: My custom workflow +artifacts: + - id: proposal + generates: proposal.md + description: Initial proposal + template: proposal.md + requires: [] + # Add, remove, or modify artifacts... +``` + +Edit templates in `templates/` to customize the content guidance. + +### Current Limitations + +| Issue | Impact | +|-------|--------| +| **Path discovery** | Users must know XDG conventions and platform-specific paths | +| **Package location** | Finding the npm package path varies by install method | +| **No scaffolding** | Users must manually create directories and copy files | +| **No verification** | No way to confirm which schema is actually being resolved | +| **Full copy required** | Must copy entire schema even to change one template | + +### Related Files + +| File | Purpose | +|------|---------| +| `src/core/artifact-graph/resolver.ts` | Schema resolution logic | +| `src/core/artifact-graph/instruction-loader.ts` | Template loading | +| `src/core/global-config.ts` | XDG path helpers | +| `schemas/spec-driven/` | Default schema and templates | diff --git a/docs/experimental-release-plan.md b/docs/experimental-release-plan.md deleted file mode 100644 index 387b48cff..000000000 --- a/docs/experimental-release-plan.md +++ /dev/null @@ -1,926 +0,0 @@ -# OpenSpec Experimental Release Plan - -This document outlines the plan to release the experimental artifact workflow system for user testing. - -## Overview - -The goal is to allow users to test the new artifact-driven workflow system alongside the existing OpenSpec commands. This experimental system (`opsx`) provides a more granular, step-by-step approach to creating change artifacts. - -## Three Workflow Modes - -### 1. Old Workflow (Current Production) -- **Commands**: `/openspec:proposal`, `/openspec:apply`, `/openspec:archive` -- **Behavior**: Hardcoded slash commands that generate all artifacts in one command -- **Status**: Production, unchanged - -### 2. New Artifact System - Batch Mode (Future) -- **Commands**: Refactored `/openspec:proposal` using schemas -- **Behavior**: Schema-driven but generates all artifacts at once (like legacy) -- **Status**: Not in scope for this experimental release -- **Note**: This is a future refactor to unify the old system with schemas - -### 3. New Artifact System - Granular Mode (Experimental) -- **Commands**: `/opsx:new`, `/opsx:continue` -- **Behavior**: One artifact at a time, dependency-driven, iterative -- **Status**: Target for this experimental release - ---- - -## Work Items - -### 1. Rename AWF to OPSX - -**Current State:** -- Commands: `/awf:start`, `/awf:continue` -- Files: `.claude/commands/awf/start.md`, `.claude/commands/awf/continue.md` - -**Target State:** -- Commands: `/opsx:new`, `/opsx:continue` -- Files: `.claude/commands/opsx/new.md`, `.claude/commands/opsx/continue.md` - -**Tasks:** -- [x] Create `.claude/commands/opsx/` directory -- [x] Rename `start.md` → `new.md` and update content -- [x] Copy `continue.md` with updated references -- [x] Update all references from "awf" to "opsx" in command content -- [x] Update frontmatter (name, description) to use "opsx" naming -- [x] Remove `.claude/commands/awf/` directory - -**CLI Commands:** -The underlying CLI commands (`openspec status`, `openspec instructions`, etc.) remain unchanged. Only the slash command names change. - ---- - -### 2. Remove WF Skill Files - -**Current State:** -- `.claude/commands/wf/start.md` - References non-existent `openspec wf` commands -- `.claude/commands/wf/continue.md` - References non-existent `openspec wf` commands - -**Target State:** -- Directory and files removed - -**Tasks:** -- [x] Delete `.claude/commands/wf/start.md` -- [x] Delete `.claude/commands/wf/continue.md` -- [x] Delete `.claude/commands/wf/` directory - ---- - -### 3. Add Agent Skills for Experimental Workflow - -**Purpose:** -Generate experimental workflow skills using the [Agent Skills](https://agentskills.io/specification) open standard. - -**Why Skills Instead of Slash Commands:** -- **Cross-editor compatibility**: Skills work in Claude Code, Cursor, Windsurf, and other compatible editors automatically -- **Simpler implementation**: Single directory (`.claude/skills/`) instead of 18+ editor-specific configurators -- **Standard format**: Open standard with simple YAML frontmatter + markdown -- **User invocation**: Users explicitly invoke skills when they want to use them - -**Behavior:** -1. Create `.claude/skills/` directory if it doesn't exist -2. Generate two skills using the Agent Skills specification: - - `openspec-new-change/SKILL.md` - Start a new change with artifact workflow - - `openspec-continue-change/SKILL.md` - Continue working on a change (create next artifact) -3. Skills are added **alongside** existing `/openspec:*` commands (not replacing) - -**Supported Editors:** -- Claude Code (native support) -- Cursor (native support via Settings → Rules → Import Settings) -- Windsurf (imports `.claude` configs) -- Cline, Codex, and other Agent Skills-compatible editors - -**Tasks:** -- [x] Create skill template content for `openspec-new-change` (based on current opsx:new) -- [x] Create skill template content for `openspec-continue-change` (based on current opsx:continue) -- [x] Add temporary `artifact-experimental-setup` command to CLI -- [x] Implement skill file generation (YAML frontmatter + markdown body) -- [x] Add success message with usage instructions - -**Note:** The `artifact-experimental-setup` command is temporary and will be merged into `openspec init` once the experimental workflow is promoted to stable. - -**Skill Format:** -Each skill is a directory with a `SKILL.md` file: -``` -.claude/skills/ -├── openspec-new-change/ -│ └── SKILL.md # name, description, instructions -├── openspec-continue-change/ -│ └── SKILL.md # name, description, instructions -└── openspec-apply-change/ - └── SKILL.md # name, description, instructions -``` - -**CLI Interface:** -```bash -openspec artifact-experimental-setup - -# Output: -# 🧪 Experimental Artifact Workflow Skills Created -# -# ✓ .claude/skills/openspec-new-change/SKILL.md -# ✓ .claude/skills/openspec-continue-change/SKILL.md -# ✓ .claude/skills/openspec-apply-change/SKILL.md -# -# 📖 Usage: -# -# Skills work automatically in compatible editors: -# • Claude Code - Auto-detected, ready to use -# • Cursor - Enable in Settings → Rules → Import Settings -# • Windsurf - Auto-imports from .claude directory -# -# Ask Claude naturally: -# • "I want to start a new OpenSpec change to add " -# • "Continue working on this change" -# -# Claude will automatically use the appropriate skill. -# -# 💡 This is an experimental feature. -# Feedback welcome at: https://github.com/Fission-AI/OpenSpec/issues -``` - -**Implementation Notes:** -- Simple file writing: Create directories and write templated `SKILL.md` files (no complex logic) -- Use existing `FileSystemUtils.writeFile()` pattern like slash command configurators -- Template structure: YAML frontmatter + markdown body -- Keep existing `/opsx:*` slash commands for now (manual cleanup later) -- Skills use invocation model (user explicitly asks Claude to use them) -- Skill `description` field guides when Claude suggests using the skill -- Each `SKILL.md` has required fields: `name` (matches directory) and `description` - ---- - -### 4. Update `/opsx:new` Command Content - -**Current Behavior (awf:start):** -1. Ask user what they want to build (if no input) -2. Create change directory -3. Show artifact status -4. Show what's ready -5. Get instructions for proposal -6. STOP and wait - -**New Behavior (opsx:new):** -Same flow but with updated naming: -- References to "awf" → "opsx" -- References to `/awf:continue` → `/opsx:continue` -- Update frontmatter name/description - -**Tasks:** -- [x] Update all "awf" references to "opsx" -- [x] Update command references in prompt text -- [x] Verify CLI commands still work (they use `openspec`, not `awf`) - ---- - -### 5. Update `/opsx:continue` Command Content - -**Current Behavior (awf:continue):** -1. Prompt for change selection (if not provided) -2. Check current status -3. Create ONE artifact based on what's ready -4. Show progress and what's unlocked -5. STOP - -**New Behavior (opsx:continue):** -Same flow with updated naming. - -**Tasks:** -- [x] Update all "awf" references to "opsx" -- [x] Update command references in prompt text - ---- - -### 6. End-to-End Testing - -**Objective:** -Run through a complete workflow with Claude using the new skills to create a real feature, validating the entire flow works. - -**Test Scenario:** -Use a real OpenSpec feature as the test case (dog-fooding). - -**Test Flow:** -1. Run `openspec artifact-experimental-setup` to create skills -2. Verify `.claude/skills/openspec-new-change/SKILL.md` created -3. Verify `.claude/skills/openspec-continue-change/SKILL.md` created -4. Verify `.claude/skills/openspec-apply-change/SKILL.md` created -5. Ask Claude: "I want to start a new OpenSpec change to add feature X" -6. Verify Claude invokes the `openspec-new-change` skill -7. Verify change directory created at `openspec/changes/add-feature-x/` -8. Verify proposal template shown -9. Ask Claude: "Continue working on this change" -10. Verify Claude invokes the `openspec-continue-change` skill -11. Verify `proposal.md` created with content -12. Ask Claude: "Continue" (create specs) -13. Verify `specs/*.md` created -14. Ask Claude: "Continue" (create design) -15. Verify `design.md` created -16. Ask Claude: "Continue" (create tasks) -17. Verify `tasks.md` created -18. Verify status shows 4/4 complete -19. Implement the feature based on tasks -20. Run `/openspec:archive` to archive the change - -**Validation Checklist:** -- [ ] `openspec artifact-experimental-setup` creates correct directory structure -- [ ] Skills are auto-detected in Claude Code -- [ ] Skill descriptions trigger appropriate invocations -- [ ] Skills create change directory and show proposal template -- [ ] Skills correctly identify ready artifacts -- [ ] Skills create artifacts with meaningful content -- [ ] Dependency detection works (specs requires proposal, etc.) -- [ ] Progress tracking is accurate -- [ ] Template content is useful and well-structured -- [ ] Error handling works (invalid names, missing changes, etc.) -- [ ] Works with different schemas (spec-driven, tdd) -- [ ] Test in Cursor (Settings → Rules → Import Settings) - -**Document Results:** -- Create test log documenting what worked and what didn't -- Note any friction points or confusing UX -- Identify bugs or improvements needed before user release - ---- - -### 7. Documentation for Users - -**Create user-facing documentation explaining:** - -1. **What is the experimental workflow?** - - A new way to create OpenSpec changes step-by-step using Agent Skills - - One artifact at a time with dependency tracking - - More interactive and iterative than the batch approach - - Works across Claude Code, Cursor, Windsurf, and other compatible editors - -2. **How to set up experimental workflow** - ```bash - openspec artifact-experimental-setup - ``` - - Note: This is a temporary command that will be integrated into `openspec init` once promoted to stable. - -3. **Available skills** - - `openspec-new-change` - Start a new change with artifact workflow - - `openspec-continue-change` - Continue working (create next artifact) - -4. **How to use** - - **Claude Code**: Skills are auto-detected, just ask Claude naturally - - "I want to start a new OpenSpec change to add X" - - "Continue working on this change" - - **Cursor**: Enable in Settings → Rules → Import Settings - - **Windsurf**: Auto-imports `.claude` directory - -5. **Example workflow** - - Step-by-step walkthrough with natural language interactions - - Show how Claude invokes skills based on user requests - -6. **Feedback mechanism** - - GitHub issue template for feedback - - What to report (bugs, UX issues, suggestions) - -**Tasks:** -- [ ] Create `docs/experimental-workflow.md` user guide -- [ ] Add GitHub issue template for experimental feedback -- [ ] Update README with mention of experimental features - ---- - -## Dependency Graph - -``` -1. Remove WF skill files - └── (no dependencies) - -2. Rename AWF to OPSX - └── (no dependencies) - -3. Add Agent Skills - └── Depends on: Rename AWF to OPSX (uses opsx content as templates) - -4. Update opsx:new content - └── Depends on: Rename AWF to OPSX - -5. Update opsx:continue content - └── Depends on: Rename AWF to OPSX - -6. E2E Testing - └── Depends on: Add Agent Skills (tests the skills workflow) - -7. User Documentation - └── Depends on: E2E Testing (need to know final behavior) -``` - ---- - -## Out of Scope - -The following are explicitly NOT part of this experimental release: - -1. **Batch mode refactor** - Making legacy `/openspec:proposal` use schemas -2. **New schemas** - Only shipping with existing `spec-driven` and `tdd` -3. **Schema customization UI** - No `openspec schema list` or similar -4. **Multiple editor support in CLI** - Skills work cross-editor automatically via `.claude/skills/` -5. **Replacing existing commands** - Skills are additive, not replacing `/openspec:*` or `/opsx:*` - ---- - -## Success Criteria - -The experimental release is ready when: - -1. `openspec-new-change`, `openspec-continue-change`, and `openspec-apply-change` skills work end-to-end -2. `openspec artifact-experimental-setup` creates skills in `.claude/skills/` -3. Skills work in Claude Code and are compatible with Cursor/Windsurf -4. At least one complete workflow has been tested manually -5. User documentation exists explaining how to generate and use skills -6. Feedback mechanism is in place -7. WF skill files are removed -8. No references to "awf" remain in user-facing content - ---- - -## Open Questions - -1. **Schema selection** - Should `opsx:new` allow selecting a schema, or always use `spec-driven`? - - Current: Always uses `spec-driven` as default - - Consider: Add `--schema tdd` option or prompt - -2. **Namespace in CLI** - Should experimental CLI commands be namespaced? - - Current: `openspec status`, `openspec instructions` (no namespace) - - Alternative: `openspec opsx status` (explicit experimental namespace) - - Recommendation: Keep current, less typing for users - -3. **Deprecation path** - If opsx becomes the default, how do we migrate? - - Not needed for experimental release - - Document that command names may change - ---- - -## Estimated Work Breakdown - -| Item | Complexity | Notes | -|------|------------|-------| -| Remove WF files | Trivial | Just delete 2 files + directory | -| Rename AWF → OPSX | Low | File renames + content updates | -| Add Agent Skills | **Low** | **Simple: 3-4 files, single output directory, standard format** | -| Update opsx:new content | Low | Text replacements | -| Update opsx:continue content | Low | Text replacements | -| E2E Testing | Medium | Manual testing, documenting results | -| User Documentation | Medium | New docs, issue template | - -**Key Improvement:** Switching to Agent Skills reduces complexity significantly: -- **Before:** 20+ files (type definitions, 18+ editor configurators, editor selection UI) -- **After:** 3-4 files (skill templates, simple CLI command) -- **Cross-editor:** Works automatically in Claude Code, Cursor, Windsurf without extra code - ---- - -## User Feedback from E2E Testing - -### What Worked Well - -1. **Clear dependency graph** ⭐ HIGH PRIORITY - KEEP - - The status command showing blocked/unblocked artifacts was intuitive: - ``` - [x] proposal - [ ] design - [-] tasks (blocked by: design, specs) - ``` - - Users always knew what they could work on next - - **Relevance**: Core UX strength to preserve - -2. **Structured instructions output** ⭐ HIGH PRIORITY - KEEP - - `openspec instructions ` gave templates, output paths, and context in one call - - Very helpful for understanding what to create - - **Relevance**: Essential for agent-driven workflow - -3. **Simple scaffolding** ✅ WORKS WELL - - `openspec new change "name"` just worked - created directory structure without fuss - - **Relevance**: Good baseline, room for improvement (see pain points) - ---- - -### Pain Points & Confusion - -1. **Redundant CLI calls** ⚠️ MEDIUM PRIORITY - - Users called both `status` AND `next` every time, but they overlap significantly - - `status` already shows what's blocked - - **Recommendation**: Consider merging or making `next` give actionable guidance beyond just listing names - - **Relevance**: Reduces friction in iterative workflow - -2. **Specs directory structure was ambiguous** 🔥 HIGH PRIORITY - FIX - - Instructions said: `Write to: .../specs/**/*.md` - - Users had to guess: `specs/spec.md`? `specs/game/spec.md`? `specs/tic-tac-toe/spec.md`? - - Users ended up doing manual `mkdir -p .../specs/tic-tac-toe` then writing `spec.md` inside - - **Recommendation**: CLI should scaffold this directory structure automatically - - **Relevance**: Critical agent UX - ambiguous paths cause workflow friction - -3. **Repetitive --change flag** ⚠️ MEDIUM PRIORITY - - Every command needed `--change "tic-tac-toe-game"` - - After 10+ calls, this felt verbose - - **Recommendation**: `openspec use "tic-tac-toe-game"` to set context, then subsequent commands assume that change - - **Relevance**: Quality of life improvement for iterative sessions - -4. **No validation feedback** 🔥 HIGH PRIORITY - ADD - - After writing each artifact, users just ran `status` hoping it would show `[x]` - - Questions raised: - - How did it know the artifact was "done"? File existence? - - What if spec format was wrong (e.g., wrong heading levels)? - - **Recommendation**: Add `openspec validate --change "name"` to check content quality - - **Relevance**: Critical for user confidence and catching errors early - -5. **Query-heavy, action-light CLI** 🔥 HIGH PRIORITY - ENHANCE - - Most commands retrieve info. The only "action" is `new change` - - Artifact creation is manual Write to guessed paths - - **Recommendation**: `openspec create proposal --change "name"` could scaffold the file with template pre-filled, then user just edits - - **Relevance**: Directly impacts agent productivity - reduce manual file writing - -6. **Instructions output was verbose** ⚠️ LOW PRIORITY - - XML-style output (``, `