Conversation
…utput Previously, project config context and rules were prepended to the template field in artifact instructions. This caused AI assistants to literally copy these constraint blocks into generated artifact files, rather than treating them as instructions. Changes: - Add `context` and `rules` as separate fields in ArtifactInstructions interface - Update generateInstructions() to populate these as distinct fields - Update CLI output to display context/rules with clear "do not include" comments - Rename <context> (dependencies) to <dependencies> to avoid confusion - Update tests for new structure The JSON output from `openspec instructions` now clearly separates: - `context`: Project background (constraints for AI) - `rules`: Artifact-specific rules (constraints for AI) - `template`: The actual structure for the output file
📝 WalkthroughWalkthroughThe PR separates artifact "context" and "rules" out of embedded template text into new optional Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as Artifact CLI
participant Loader as InstructionLoader
participant Config as ProjectConfig
participant Renderer as ArtifactWorkflow
participant FS as FileSystem
User->>CLI: request generate artifact
CLI->>Loader: generateInstructions(artifactId)
Loader->>Config: read project config
Config-->>Loader: config (context, rules, dependencies)
Loader-->>CLI: ArtifactInstructions { template, context?, rules?, dependencies }
CLI->>Renderer: printInstructionsText(ArtifactInstructions)
Renderer->>FS: read dependencies (if any)
Renderer->>FS: write artifact to outputPath using template (apply constraints from context/rules)
Renderer-->>User: artifact created
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
…entation Update generated skill templates (continue-change, ff-change) to document that context and rules are separate JSON fields that should NOT be copied into artifact output files. Users running `openspec update` will get the updated skill instructions.
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
Greptile SummaryFixed a bug where project configuration Key Changes
ImpactBefore: JSON output had constraints embedded in template, making it ambiguous what was structure vs constraints: { "template": "<context>\nTech stack...\n</context>\n\n## Why\n..." }After: Clean separation makes AI behavior unambiguous: { "context": "Tech stack...", "rules": ["Rule 1"], "template": "## Why\n..." }Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CLI as artifact-workflow.ts
participant Gen as generateInstructions()
participant Config as readProjectConfig()
participant Template as loadTemplate()
User->>CLI: openspec create <artifact> --json
CLI->>Gen: generateInstructions(context, artifactId)
Gen->>Config: readProjectConfig(projectRoot)
Config-->>Gen: { context, rules }
Gen->>Template: loadTemplate(schemaName, templatePath)
Template-->>Gen: templateContent
Note over Gen: Extract fields separately<br/>(not prepended to template)
Gen->>Gen: configContext = context?.trim() || undefined
Gen->>Gen: configRules = rules[artifactId] || undefined
Gen-->>CLI: { context, rules, template, ... }
alt JSON output
CLI->>User: JSON.stringify({ context, rules, template })
Note over User: AI sees separate fields<br/>Won't include in output
else Text output
CLI->>CLI: printInstructionsText()
CLI->>User: <project_context>...do not include...</project_context>
CLI->>User: <rules>...do not include...</rules>
CLI->>User: <template>...fill in sections...</template>
Note over User: Clear comments prevent<br/>constraint inclusion
end
|
Additional commit: Skill template updatesThe second commit updates the skill templates in Updates to skill templates:
How users get this fix:
|
|
Correction: Users get this fix by running The skill templates are generated by the experimental workflow setup, so existing users of the experimental workflow need to re-run: openspec artifact-experimental-setupThis will regenerate the skills in |
Summary
contextandruleswere being prepended to thetemplatefield in artifact instructions<context>and<rules>blocks into generated artifact filesChanges
contextandrulesas separate fields inArtifactInstructionsinterfacegenerateInstructions()to populate these as distinct fields (not prepended to template)<context>(for dependencies) to<dependencies>to avoid confusionJSON Output Structure
Before:
{ "template": "<context>\nTech stack...\n</context>\n\n<rules>\n- Rule 1\n</rules>\n\n## Why\n..." }After:
{ "context": "Tech stack...", "rules": ["Rule 1"], "template": "## Why\n..." }Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.