Skip to content

fix: add workflow phase boundary guardrails to prevent spec-phase code changes #92

Closed

Description

@jflowers

Problem

During a /speckit.clarify session (Spec 028), the agent updated the spec correctly but then also modified Go source code (internal/sandbox/config.go) and test files (internal/sandbox/sandbox_test.go). The clarify command is a specification phase — it should only modify spec artifacts, not implementation code.

The root cause is that no command or behavioral rule explicitly prevents code changes during spec phases. The /speckit.clarify command instructions focus on the spec update workflow but don't include a guardrail saying "do NOT modify source code."

Proposed Fix

1. Add Guardrails section to /speckit.clarify command

Add to .opencode/command/speckit.clarify.md:

## Guardrails

- **NEVER modify source code** — this command updates
  spec.md ONLY. Implementation changes belong in
  /speckit.implement, /unleash, or /cobalt-crush.
- **NEVER modify test files** — same reason.
- **NEVER modify Go source, Markdown agents, or config
  files** outside the specs/NNN-*/ feature directory.
- The ONLY files this command may write are:
  - FEATURE_SPEC (the spec.md file)
  - Files within FEATURE_DIR (spec artifacts)

2. Add Guardrails to other spec-phase commands

Apply the same guardrail to:

  • .opencode/command/speckit.specify.md
  • .opencode/command/speckit.plan.md
  • .opencode/command/speckit.tasks.md
  • .opencode/command/speckit.analyze.md
  • .opencode/command/speckit.checklist.md

Each should state that it may only write to the specs/NNN-*/ feature directory.

3. Add Workflow Phase Boundaries to AGENTS.md

Add to AGENTS.md Behavioral Constraints:

### Workflow Phase Boundaries

Agents MUST NOT cross workflow phase boundaries:
- **Specify/Clarify/Plan/Tasks/Analyze/Checklist** phases:
  spec artifacts ONLY (specs/NNN-*/ directory). No source
  code changes.
- **Implement** phase: source code changes allowed, guided
  by spec artifacts.
- **Review** phase: findings and minor fixes only. No new
  features.

4. Add Phase Discipline to constitution

Add to .specify/memory/constitution.md Development Workflow:

- **Phase Discipline**: Each pipeline phase (specify,
  clarify, plan, tasks, implement, review) MUST produce
  only its designated artifacts. Implementation code
  MUST NOT be written during specification phases.

Scope

  • ~6 Markdown command files updated (add Guardrails section)
  • AGENTS.md updated (add Workflow Phase Boundaries subsection)
  • constitution.md updated (add Phase Discipline rule)
  • Scaffold asset copies synced (~6 files)
  • No Go code changes
  • OpenSpec tactical change (opsx/workflow-phase-boundaries)

Activity

  1. added a commit that references this issue on Apr 13, 2026
    c00bb81
  2. added a commit that references this issue on Apr 14, 2026
    641a5af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions