Skip to content

Conversation

@TabishB
Copy link
Contributor

@TabishB TabishB commented Dec 30, 2025

Summary

  • Add instruction field to schema artifacts for inline creation guidance
  • Enhance openspec instructions output with XML-style format for better AI parsing
  • Enrich dependency information with full paths and descriptions

Schema Changes

Added detailed instruction fields to artifacts in both spec-driven and tdd schemas:

  • proposal: Guidelines for Why/What Changes/Impact sections
  • specs: Delta operations format, requirement/scenario structure
  • design: Technical decisions, architecture documentation
  • tasks: Task breakdown from specs

Instruction Loader

  • Returns new instruction field from schema
  • Includes changeDir for full path resolution
  • Enriched DependencyInfo with path and description

CLI Output (XML Format)

New structured output for openspec instructions:

<artifact id="design" change="add-feature" schema="spec-driven">

<task>
Create the design artifact for change "add-feature".
Technical design decisions and architecture.
</task>

<context>
<dependency id="proposal" status="done">
  <path>/full/path/to/proposal.md</path>
  <description>Initial proposal document</description>
</dependency>
</context>

<output>
Write to: /full/path/to/design.md
</output>

<template>
...template content...
</template>

</artifact>

Test plan

  • Schema validation passes with new instruction fields
  • openspec instructions shows XML format
  • openspec instructions --json includes new fields
  • Tests updated and passing

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Added guides on schema customization and workflow gap analysis for artifact workflows.
  • New Features

    • Artifact instructions now emit a structured, hierarchical output for clearer guidance.
    • Schemas include richer instructional metadata to help create proposals, specs, tests, implementations, and docs.
  • Tests

    • Updated tests to match new output format and verify list sorting behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

Schema changes:
- Add `instruction` field to artifacts for inline creation guidance
- Include detailed instructions for proposal, specs, design, and tasks

Instruction loader enhancements:
- Return `instruction` field from schema
- Include `changeDir` for full path resolution
- Enrich dependency info with `path` and `description` fields

CLI output improvements:
- New XML-style format for `openspec instructions` (better for AI parsing)
- Structured tags: <artifact>, <task>, <context>, <output>, <template>
- Dependencies now show full paths for easy file reading
- JSON output includes all new fields
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Adds documentation for schema customization and workflow gaps; embeds instructional metadata into schemas; enriches artifact instruction model with changeDir, instruction, and detailed dependency info (DependencyInfo with path and description); renames exported type to DependencyInfo; and changes artifact workflow output to an XML-like block format with corresponding test updates.

Changes

Cohort / File(s) Summary
Documentation & Planning
docs/schema-customization.md, docs/schema-workflow-gaps.md
New design and workflow docs describing schema customization, project-local schemas, gap analysis, user stories, and phased implementation/CLI proposals.
Schema Instruction Metadata
schemas/spec-driven/schema.yaml, schemas/tdd/schema.yaml
Added multi-line instruction/guidance blocks to artifact definitions describing expected content, formatting, examples, and workflow notes.
Artifact Graph Types & Export
src/core/artifact-graph/types.ts, src/core/artifact-graph/index.ts
Added optional instruction to ArtifactSchema; public export renamed from DependencyStatusDependencyInfo (API surface change).
Instruction Loader & Dependency Model
src/core/artifact-graph/instruction-loader.ts
ArtifactInstructions now includes changeDir: string and instruction?: string; replaced DependencyStatus[] with DependencyInfo[] (fields: id, done, path, description); getDependencyStatusgetDependencyInfo and call sites updated to populate path and description.
Artifact Workflow Output
src/commands/artifact-workflow.ts
Reworked console output from plain text to structured XML-like blocks (artifact tag, warnings, task description, contextual dependencies, output location, instruction, template, success criteria/unlocks).
Tests Updated
test/commands/artifact-workflow.test.ts, test/core/list.test.ts
Tests adjusted for new XML-like output tags and updated sort option usage in list tests; expectations updated to match new formatted output and sorting behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Possibly related PRs

Poem

🐰 I nibbled through schemas late at night,

I stitched instructions, made formats tight,
Paths and descriptions now hop in a row,
XML tags gleam where the workflows go,
Hooray — a tidy trail for every rabbit’s plight!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and concisely describes the main changes: enhancing artifact instructions with inline guidance and converting output to XML format.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee517e5 and 53e137a.

📒 Files selected for processing (1)
  • test/core/list.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
test/core/list.test.ts (1)
src/core/list.ts (1)
  • ListCommand (77-194)
🔇 Additional comments (1)
test/core/list.test.ts (1)

118-134: LGTM! Test correctly verifies alphabetical sorting behavior.

The test properly exercises the sort: 'name' option by creating directories in non-alphabetical order (zebra, alpha, middle) and asserting that the output is sorted alphabetically. The API usage matches the documented function signature, and the assertions correctly verify the expected behavior.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- schema-customization.md: Guide for customizing artifact schemas
- schema-workflow-gaps.md: Analysis of current workflow limitations
@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/commands/artifact-workflow.ts (1)

387-389: Consider implementing success_criteria validation.

Lines 387-389 include a placeholder comment "To be defined in schema validation rules" for success criteria. This suggests planned future work.

Would you like me to open an issue to track the implementation of schema validation rules and success criteria? This could include:

  • Defining validation rules in artifact schemas
  • Implementing runtime validation
  • Providing clear success/failure feedback in the CLI
docs/schema-workflow-gaps.md (1)

131-147: Add language specifiers to code blocks for better rendering.

Several code blocks lack language specifiers, which can affect syntax highlighting and rendering in some Markdown viewers.

🔎 Proposed fix to add language specifiers
-```
+```plaintext
 openspec/
 ├── config.yaml                 # Project config (NEW)
-```
+```plaintext
 1. ./openspec/schemas/<name>/                    # Project-local
-```
+```plaintext
 1. --schema CLI flag                    # Explicit override
-```
+```plaintext
 1. ./openspec/schemas/<name>/           # Project-local (NEW)

Also applies to: 172-177, 182-187, 311-315

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb7ff52 and ee517e5.

📒 Files selected for processing (9)
  • docs/schema-customization.md
  • docs/schema-workflow-gaps.md
  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
  • src/commands/artifact-workflow.ts
  • src/core/artifact-graph/index.ts
  • src/core/artifact-graph/instruction-loader.ts
  • src/core/artifact-graph/types.ts
  • test/commands/artifact-workflow.test.ts
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/*.md : Scaffold proposal using `proposal.md`, `tasks.md`, optional `design.md`, and delta specs under `openspec/changes/<id>/`
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/*.md : Scaffold proposal using `proposal.md`, `tasks.md`, optional `design.md`, and delta specs under `openspec/changes/<id>/`

Applied to files:

  • docs/schema-customization.md
  • docs/schema-workflow-gaps.md
  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Create `design.md` only when needed: cross-cutting changes, new external dependencies, significant data model changes, security/performance complexity, or pre-coding ambiguity

Applied to files:

  • docs/schema-workflow-gaps.md
  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/*/proposal.md : Ensure `proposal.md` includes sections: Why (1-2 sentences), What Changes (bullet list with breaking change markers), and Impact (affected specs and code)

Applied to files:

  • docs/schema-workflow-gaps.md
  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED|MODIFIED|REMOVED|RENAMED Requirements` headers in spec delta files

Applied to files:

  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/*/tasks.md : Ensure `tasks.md` contains implementation checklist with numbered sections and checkbox items

Applied to files:

  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Include at least one `#### Scenario:` per requirement in spec delta files

Applied to files:

  • schemas/spec-driven/schema.yaml
  • schemas/tdd/schema.yaml
📚 Learning: 2025-11-25T01:08:02.839Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:02.839Z
Learning: Use `@/openspec/AGENTS.md` to learn how to create and apply change proposals, spec format and conventions, and project structure and guidelines

Applied to files:

  • schemas/spec-driven/schema.yaml
📚 Learning: 2025-11-25T01:08:19.004Z
Learnt from: CR
Repo: Fission-AI/OpenSpec PR: 0
File: openspec/AGENTS.md:0-0
Timestamp: 2025-11-25T01:08:19.004Z
Learning: Applies to openspec/changes/**/specs/**/spec.md : Use `## ADDED Requirements` for new orthogonal capabilities that can stand alone; use `## MODIFIED Requirements` for behavior changes of existing requirements

Applied to files:

  • schemas/tdd/schema.yaml
🧬 Code graph analysis (1)
src/core/artifact-graph/instruction-loader.ts (1)
src/core/artifact-graph/types.ts (2)
  • Artifact (22-22)
  • CompletedSet (28-28)
🪛 LanguageTool
docs/schema-customization.md

[style] ~93-~93: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... — requires manual copy and edit 2. "I want to customize just the proposal template" ...

(REP_WANT_TO_VB)


[style] ~94-~94: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...late"* — must copy entire schema 3. *"I want to see what the default schema looks like"...

(REP_WANT_TO_VB)


[style] ~95-~95: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... like"* — must find package path 4. "I want to revert to defaults" — must delete file...

(REP_WANT_TO_VB)

docs/schema-workflow-gaps.md

[style] ~61-~61: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...2: Customizing a Schema Goal: User wants to add a "research" artifact before "propo...

(REP_WANT_TO_VB)


[style] ~305-~305: ‘first priority’ might be wordy. Consider a shorter alternative.
Context: ...openspec/schemas/to resolution order (first priority) -openspec schema copy [new-na...

(EN_WORDINESS_PREMIUM_FIRST_PRIORITY)

🪛 markdownlint-cli2 (0.18.1)
docs/schema-workflow-gaps.md

131-131: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


172-172: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


182-182: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


311-311: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (26)
schemas/spec-driven/schema.yaml (5)

9-22: LGTM! Instruction guidance aligns with established conventions.

The proposal instruction block correctly documents the Why/What Changes/Impact structure and emphasizes keeping implementation details in design.md. This matches the learnings for proposal.md structure.

Based on learnings, the proposal structure and guidance are consistent with project conventions.


29-74: Comprehensive spec guidance with correct delta operations.

The instruction block properly documents ADDED/MODIFIED/REMOVED/RENAMED operations and the requirement for at least one scenario per requirement. The MODIFIED workflow guidance (lines 47-54) is particularly helpful.

Based on learnings, the delta operations and scenario format align with established conventions.


82-102: Clear guidance on when and how to create design documents.

The instruction appropriately emphasizes creating design.md only when needed (lines 85-89) and provides comprehensive section guidance. This aligns with the principle that not all changes require upfront design documentation.

Based on learnings, the design.md criteria match established guidelines for when design documents are beneficial.


110-133: Well-structured task breakdown guidance.

The instruction provides clear guidelines for organizing tasks with numbered sections and checkboxes, matching the established convention for tasks.md structure.

Based on learnings, the tasks structure follows the expected implementation checklist format.


44-44: Error message is not "silent"—validation already catches incorrect scenario formatting and reports it.

The warning about "fail silently" is misleading. When scenarios use 3 hashtags or bullets instead of 4, the validator's countScenarios() method finds zero scenarios (which matches only ^####) and produces an explicit ERROR: "must include at least one scenario." However, the error message is indirect—it doesn't explicitly state that the issue is an incorrect hashtag count. Consider improving the error message to directly report: "Scenarios must use exactly 4 hashtags (####), not 3. Found: ### Scenario: format" to make the diagnosis clearer for developers.

Likely an incorrect or invalid review comment.

src/core/artifact-graph/types.ts (1)

9-9: LGTM! Clean schema extension using Zod v4.

The addition of the optional instruction field to ArtifactSchema is straightforward and follows Zod v4 conventions correctly.

test/commands/artifact-workflow.test.ts (3)

262-264: Test expectations correctly updated for XML-like output format.

The test expectations now match the new structured output format with opening tags for artifacts and templates.


274-276: Consistent XML-style formatting in design artifact test.

Test expectations properly updated to match the structured output.


287-288: Blocked artifact warning now uses structured tags.

The update from plain text warning to <warning> with status="missing" aligns with the new structured output approach.

docs/schema-customization.md (1)

1-210: Comprehensive documentation of schema customization workflow.

This documentation effectively captures the current manual process, identifies pain points, and proposes a well-thought-out CLI solution. The 2-level resolution model (user override → package built-in) is clearly explained, and the proposed openspec schema commands address real user needs.

The implementation considerations section (lines 165-196) provides valuable technical context for future development.

src/commands/artifact-workflow.ts (4)

315-327: Clean destructuring of enhanced instruction fields.

The function now accepts the new changeDir and instruction fields from ArtifactInstructions, aligning with the enriched data model.


329-340: Well-structured opening and warning sections.

The XML-like opening tag includes helpful context attributes (id, change, schema), and the blocked warning clearly identifies missing dependencies.


350-364: Rich dependency context with full paths and descriptions.

The context section now includes:

  • Full file paths (line 356)
  • Descriptions for each dependency (line 359)
  • Status indicators (done/missing)

This provides significantly more context than the previous implementation.


373-378: Optional instruction block handles missing instructions gracefully.

The conditional rendering ensures the <instruction> block only appears when instruction content is available.

schemas/tdd/schema.yaml (4)

9-43: Clear specification guidance for TDD workflow.

The spec instruction appropriately focuses on WHAT to build with testable requirements and scenarios. The warning on line 21 about using exactly 4 hashtags for scenarios is consistent with the spec-driven schema.


50-94: Excellent TDD test-first guidance.

The tests instruction emphasizes writing tests BEFORE implementation (line 51) and provides comprehensive coverage requirements (lines 63-68). The Given/When/Then structure (line 59) aligns well with the spec scenarios.


102-140: Implementation guidance follows TDD principles.

The implementation instruction correctly describes the red-green-refactor cycle (lines 105-110) and emphasizes minimal code to pass tests. The warning "Don't over-engineer - implement only what tests require" (line 140) is excellent advice for TDD.


148-204: User-focused documentation guidance.

The docs instruction appropriately emphasizes writing for users (line 158) and provides a clear structure with Overview, Getting Started, Examples, and Reference sections.

docs/schema-workflow-gaps.md (3)

1-126: Thorough analysis of current workflow gaps.

The document effectively captures three key pain points:

  1. Schema not persisted with changes (lines 32-56)
  2. Manual schema customization process (lines 60-95)
  3. No team-sharing mechanism (lines 98-112)

Each scenario includes concrete examples showing the user experience problems.


129-188: Well-designed 3-level resolution architecture.

The proposed architecture with:

  • Project-local schemas (.openspec/schemas/)
  • Change metadata (change.yaml)
  • Project config (config.yaml)

...is a sensible progression that addresses all identified gaps. The resolution order (lines 172-176) and schema selection order (lines 182-187) are clearly defined.


273-363: Pragmatic phased implementation plan.

The 4-phase approach prioritizes high-value features:

  1. Phase 1 (High): Change metadata - solves the "forgot --schema" problem
  2. Phase 2 (High): Project-local schemas - enables team sharing
  3. Phase 3 (Medium): Schema management CLI - improves DX
  4. Phase 4 (Low): Project config - adds convenience

The backwards compatibility section (lines 354-363) demonstrates careful consideration of migration concerns.

src/core/artifact-graph/index.ts (1)

39-39: No action needed. The export is currently named DependencyInfo, and there is no evidence of a previous DependencyStatus export in the codebase or git history. No external consumers are affected, and no breaking change has occurred.

Likely an incorrect or invalid review comment.

src/core/artifact-graph/instruction-loader.ts (4)

47-58: LGTM!

The interface additions are well-documented and appropriately typed. Using string | undefined for instruction correctly reflects that it's an optional schema field.


64-75: LGTM!

The enriched DependencyInfo interface provides useful metadata (path and description) that will help consumers understand dependencies better. The field names and types are appropriate.


186-201: LGTM!

The function correctly populates the new changeDir and instruction fields, and uses the updated getDependencyInfo helper. The implementation aligns with the interface changes.


207-221: Defensive fallbacks are appropriate—schema validation guarantees safety.

The validateRequiresReferences() function in schema.ts validates at load time that all artifact IDs referenced in the requires field exist in the schema. This validation throws SchemaValidationError if any reference is invalid, ensuring depArtifact will never be undefined at runtime. The optional chaining fallbacks (depArtifact?.generates ?? id and depArtifact?.description ?? '') are sound defensive coding and will never silently mask configuration errors.

TabishB and others added 2 commits December 30, 2025 22:06
Update test to explicitly use sort='name' since the default
changed from alphabetical to most-recently-modified.
@TabishB TabishB merged commit ea5aa0e into main Dec 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants