Skip to content

Conversation

@jax-max
Copy link
Contributor

@jax-max jax-max commented Nov 14, 2025

Fix Slash Command Instructions to Prevent Code Writing in Proposal Phase

Problem

I encountered two issues when using OpenSpec:

  1. Code writing during proposal phase: Code writing started during the /openspec-proposal phase, while the expectation was to only draft design documents (proposal.md, tasks.md, design.md, and spec deltas).

  2. Missing project.md reference in apply phase: During the /openspec-apply phase, the LLM overlooked the content in project.md (I'm using the GLM-4.6 model, which has moderate capabilities). This could lead to implementations that don't follow project conventions.

Solution

This PR optimizes the prompt content in slash command templates to address both issues:

Changes Made

  • Added explicit guardrail in proposal phase: Added instructions to proposalGuardrails to avoid writing any code during the proposal stage and focus on creating design documents only. Implementation should happen in the apply stage after approval.

  • Emphasized design phase: Added a reminder in proposalSteps to clarify that this is a design phase and no implementation code should be written.

  • Updated apply phase validation: Modified applySteps to require reading openspec/project.md first to understand project conventions before proceeding with implementation tasks. This ensures the LLM follows project conventions even with moderate-capability models.

Technical Details

  • Modified src/core/templates/slash-command-templates.ts:
    • Enhanced proposalGuardrails with explicit code-writing prohibition
    • Added design phase reminder to proposalSteps
    • Updated applySteps to include project.md reading as the first step

Impact

These changes ensure that:

  • AI assistants will not write code during the proposal phase, only creating design documents
  • AI assistants will read project.md during the apply phase to follow project conventions
  • The workflow clearly separates design (proposal) from implementation (apply) stages

Summary by CodeRabbit

  • Chores
    • Enforced a design-only proposal stage with explicit reminders not to produce code during proposal development.
    • Expanded guidance to include reviewing the codebase and project conventions earlier in intake to better align proposals with current implementation; minor formatting polish to guidance text.

- Added instructions to avoid writing code during the proposal stage and focus on creating design documents.
- Emphasized the design phase by including a reminder not to implement code until the apply stage.
- Updated validation steps to clarify the importance of confirming project conventions before proceeding with tasks.
@jax-max jax-max requested a review from TabishB as a code owner November 14, 2025 08:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Adds explicit design-only guardrail forbidding writing implementation code during the proposal stage, extends proposal references to instruct exploring the codebase for alignment, and inserts a minor formatting blank line; changes are confined to a single slash-command template file.

Changes

Cohort / File(s) Summary
Slash command template
src/core/templates/slash-command-templates.ts
Expanded proposalGuardrails to explicitly prohibit writing implementation code during the proposal stage and to emphasize a design-only workflow; extended proposalReferences to instruct exploring the codebase to align proposals with implementation; minor blank-line formatting added before the references block.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ProposalCmd as "proposalSteps / guardrails"

  note right of ProposalCmd `#FFF3E0`: New guardrail — design-only, no implementation code
  User->>ProposalCmd: invoke /proposal
  ProposalCmd-->>User: step-by-step instructions
  ProposalCmd-->>User: "Design-only: do not write implementation code in this stage."
  ProposalCmd->>User: "Check codebase to align proposals with current implementation."
Loading
sequenceDiagram
  participant User
  participant ApplyCmd as "applySteps (template)"
  participant ProjectDoc as "openspec/project.md"
  participant ProposalFiles as "proposal files"

  note right of ApplyCmd `#E8F5E9`: Updated flow — read project conventions first
  User->>ApplyCmd: invoke /apply
  ApplyCmd->>ProjectDoc: read project conventions
  ProjectDoc-->>ApplyCmd: conventions/context
  ApplyCmd->>ProposalFiles: open review artifacts
  ProposalFiles-->>ApplyCmd: proposal content
  ApplyCmd-->>User: guidance + review checklist
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Review exact phrasing in proposalGuardrails to ensure no ambiguity about "no code" constraint.
  • Verify proposalReferences wording correctly directs readers to explore the codebase and that links/path fragments render as intended.
  • Check template string formatting and surrounding whitespace to avoid accidental template literal or escaping issues.

Poem

🐰
I hopped through lines of spec and text,
Saying "Design first—no code next",
Read the project, then check the plan,
A tidy hop, from rabbit to man. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enhancing proposal guidelines in the slash-command-templates.ts file, which aligns with the PR's core objective of improving proposal phase handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 34a9ed9 and f80e99a.

📒 Files selected for processing (1)
  • src/core/templates/slash-command-templates.ts (2 hunks)
🔇 Additional comments (4)
src/core/templates/slash-command-templates.ts (4)

8-9: Clear separation between design and implementation phases.

The explicit no-code guardrail is clear and well-scoped. It properly lists the allowed outputs (proposal.md, tasks.md, design.md, spec deltas) and explains when implementation should occur.


21-24: Helpful reference guidance for the proposal phase.

The reference section provides concrete, actionable commands for validating proposals and exploring the codebase. Line 24's emphasis on aligning proposals with current implementation realities directly supports the PR's goal of improving proposal quality.


53-53: Correct integration of the new reference section.

The proposalReferences section is properly integrated into the proposal command body, maintaining consistency with the structure of other commands.


26-32: PR description claims changes to applySteps that are not present in the code.

The PR description states: "modifying applySteps so the LLM must read openspec/project.md first to understand project conventions before implementing changes." However, the applySteps section (lines 26-32) shows no modifications in this diff.

Based on the past review discussion where TabishB questioned the redundancy of re-reading project context during implementation, it appears this change may have been discussed but not implemented. Please update the PR description to accurately reflect the actual changes in the code.


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.

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: 1

📜 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 17d7e59 and 091d1fc.

📒 Files selected for processing (1)
  • src/core/templates/slash-command-templates.ts (3 hunks)
🔇 Additional comments (2)
src/core/templates/slash-command-templates.ts (2)

8-9: Excellent addition to enforce design-only work in proposals.

The explicit guardrail clearly separates design from implementation and lists the expected deliverables for the proposal stage. This should help prevent premature code generation, especially with moderate-capability models.


28-28: No changes needed—code improvement verified.

The change at line 28 is well-founded: openspec/project.md exists, is automatically created during init, recreated if deleted in extend mode, and referenced consistently across templates, tests, and documentation. Prioritizing project conventions before reading proposal files is a sound structural improvement.

…hat no implementation code should be written during the design phase.
Copy link
Contributor

@TabishB TabishB left a comment

Choose a reason for hiding this comment

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

A few questions below :)

- Refer to \`openspec/AGENTS.md\` (located inside the \`openspec/\` directory—run \`ls openspec\` or \`openspec update\` if you don't see it) if you need additional OpenSpec conventions or clarifications.`;

const proposalGuardrails = `${baseGuardrails}\n- Identify any vague or ambiguous details and ask the necessary follow-up questions before editing files.`;
const proposalGuardrails = `${baseGuardrails}\n- Identify any vague or ambiguous details and ask the necessary follow-up questions before editing files.
Copy link
Contributor

Choose a reason for hiding this comment

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

@jax-max How has this updated instruction been working for you? Do you feel like this has COMPLETELY stopped the agent from writing code?

Will try it out, but keen to hear your experience first?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mainly asking to just get a sense of whether this actually works, i'm ok with the change itself, because I agree that it's a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TabishB Hi there! Our team (not only me) has noticed that code automatically starts being written during the proposal phase. We’ve checked the system prompt of the tool being used and found no issues—it’s a rather odd problem.
Adding a clarifying note here might theoretically help a bit, but the LLM will probably still not behave as intended, haha.
We’re wondering if you’ve encountered this issue before?

5. Draft spec deltas in \`changes/<id>/specs/<capability>/spec.md\` (one folder per capability) using \`## ADDED|MODIFIED|REMOVED Requirements\` with at least one \`#### Scenario:\` per requirement and cross-reference related capabilities when relevant.
6. Draft \`tasks.md\` as an ordered list of small, verifiable work items that deliver user-visible progress, include validation (tests, tooling), and highlight dependencies or parallelizable work.
7. Validate with \`openspec validate <id> --strict\` and resolve every issue before sharing the proposal.`;
7. Validate with \`openspec validate <id> --strict\` and resolve every issue before sharing the proposal.
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting you decided to add this here as well. Any particular reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify again—our model’s compliance is really subpar. Feel free to delete this if you find it redundant.

const applySteps = `**Steps**
Track these steps as TODOs and complete them one by one.
1. Read \`changes/<id>/proposal.md\`, \`design.md\` (if present), and \`tasks.md\` to confirm scope and acceptance criteria.
1. Read \`openspec/project.md\` to understand project conventions, then read \`changes/<id>/proposal.md\`, \`design.md\` (if present), and \`tasks.md\` to confirm scope and acceptance criteria.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, I'm not too sure if this makes sense. The idea is using the project context to create the plan and then using the plan to implement.

project context -> plan -> implement

If you've used the project context to create the plan then you most likely don't need to read the context again during the implementation stage. The plan should already be created with the project context in mind.

So IMO, it's a bit redundant here to read the context again and possibly using more tokens than we need.

If you've had a different experience here, let me know!

Copy link
Contributor Author

@jax-max jax-max Nov 15, 2025

Choose a reason for hiding this comment

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

@TabishB Greetings! It may be that the limited number of chapters in the OpenSpec document template leads to significant information loss during the project context → plan phase, which in turn affects the code accuracy in the plan → implement phase.
From our practice, a simple fix is to revisit and re-read the project context during the plan → implement phase. A more elegant solution could be supporting custom plan templates : #307
I'd love to hear your thoughts. Looking forward to your reply!

- Removed redundant instruction in proposal steps to streamline the process.
- Clarified the initial reading order for apply steps by omitting the project conventions document, focusing on the proposal and design documents instead.
…pec into feat/ImproveGenCodeQuality

# Conflicts:
#	src/core/templates/slash-command-templates.ts
Copy link
Contributor

@TabishB TabishB left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@TabishB TabishB merged commit 1050e57 into Fission-AI:main Nov 19, 2025
7 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 19, 2025
Balancor pushed a commit to Balancor/OpenSpec that referenced this pull request Nov 29, 2025
…#306)

* Enhance proposal guidelines in slash-command-templates.ts

- Added instructions to avoid writing code during the proposal stage and focus on creating design documents.
- Emphasized the design phase by including a reminder not to implement code until the apply stage.
- Updated validation steps to clarify the importance of confirming project conventions before proceeding with tasks.

* Update proposal guidelines in slash-command-templates.ts to clarify that no implementation code should be written during the design phase.

* Refine proposal and apply steps in slash-command-templates.ts

- Removed redundant instruction in proposal steps to streamline the process.
- Clarified the initial reading order for apply steps by omitting the project conventions document, focusing on the proposal and design documents instead.
fenghaitao pushed a commit to fenghaitao/OpenSpec that referenced this pull request Dec 10, 2025
…#306)

* Enhance proposal guidelines in slash-command-templates.ts

- Added instructions to avoid writing code during the proposal stage and focus on creating design documents.
- Emphasized the design phase by including a reminder not to implement code until the apply stage.
- Updated validation steps to clarify the importance of confirming project conventions before proceeding with tasks.

* Update proposal guidelines in slash-command-templates.ts to clarify that no implementation code should be written during the design phase.

* Refine proposal and apply steps in slash-command-templates.ts

- Removed redundant instruction in proposal steps to streamline the process.
- Clarified the initial reading order for apply steps by omitting the project conventions document, focusing on the proposal and design documents instead.
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