Skip to content
/

opencode-plugin-openspec

opcode-plugin-openspec · Octane0411/opencode-plugin-openspec · ★ 109 · last commit 2026-03-24

Prevent premature code implementation during OpenSpec planning by injecting a write-restricted planning agent into OpenCode.

Best whenPlanning-implementation separation requires mechanical permission enforcement, not just prompting.
Skip ifStarting code implementation before planning is complete, Modifying *.spec.md files directly during planning
vs seeds
openspectargets OpenCode exclusively, making it the only OpenCode-specific tool in this batch. Its two-layer enforcement (prompt…
Primitive shape 1 total
Subagents 1
00

Summary

opencode-plugin-openspec — Summary

opencode-plugin-openspec is an OpenCode plugin that adds a dedicated openspec-plan agent mode to OpenCode for the planning phase of spec-driven development. The core problem it solves is that OpenCode's default "Build mode" agent starts implementing code immediately when working with OpenSpec planning documents, before the planning phase is complete. The plugin auto-detects OpenSpec projects, injects a specialized "OpenSpec Architect" agent with a distinctive system prompt that enforces planning-only behavior (no code implementation), and applies smart permission rules (read-only on source code; write access only to project.md, AGENTS.md, openspec/**, specs/**). It is installed by adding the package name to opencode.json — no npm install required. The plugin is TypeScript/Bun compiled.

differs_from_seeds: All seed frameworks work with Claude Code; this is the only framework in this batch targeting OpenCode specifically. It is analogous to opcode-plugin-openspec within the OpenCode ecosystem as superpowers is within the Claude Code ecosystem — a behavioral constraint layer for the planning phase. However, it adds only a single specialized agent rather than a full skill set.

01

Overview

opencode-plugin-openspec — Overview

Origin

Published by Octane0411, v0.1.4, MIT license. Built against OpenCode plugin API v1.1.19+ (@opencode-ai/plugin, @opencode-ai/sdk). TypeScript + Bun.

Philosophy

From the README: "The Problem: When using OpenCode's standard 'Build mode' to create or modify OpenSpec planning documents, AI agents often attempt to start implementing code changes immediately, before the planning phase is complete. This can lead to premature coding and a lack of focus on the architectural design."

The solution is a clean planning-implementation separation enforced by the plugin: the openspec-plan agent is allowed to write to spec files but not to implementation code. This is "permission-enforced phase separation" — not just instructional, but mechanically enforced through OpenCode's permission system.

Manifesto-style statements

  • "Allow creating and editing OpenSpec documents. Prevent modifications to the implementation code."
  • "Auto-Detection: Automatically detects if the current workspace is an OpenSpec project."
  • "Read-Only Safety: Keeps the rest of the codebase read-only when using the openspec-plan agent."

Target user

Developers using OpenCode as their primary AI coding tool who also use OpenSpec for spec-driven development. The plugin bridges these two tools.

Agent color

#FF6B6B (distinctive coral/red) — visually distinguishes the OpenSpec Architect agent in the OpenCode agent selector.

02

Architecture

opencode-plugin-openspec — Architecture

Distribution

  • npm package: opencode-plugin-openspec (v0.1.4)
  • Referenced in opencode.json — OpenCode auto-downloads on next run

Install method

Add to ~/.config/opencode/opencode.json or .opencode/opencode.json:

{
  "plugin": ["opencode-plugin-openspec"]
}

No npm install required. OpenCode fetches the plugin automatically.

Build

  • TypeScript → compiled to dist/index.js via Bun
  • bun build ./src/index.ts --outfile ./dist/index.js --target node

Directory structure

opencode-plugin-openspec/
├── src/
│   ├── index.ts        # Plugin entry point (Plugin function)
│   ├── config.ts       # createConfigHook (agent injection)
│   ├── prompts.ts      # OPENSPEC_SYSTEM_PROMPT constant
│   └── utils/
│       └── detection.ts  # isOpenSpecProject() detection
├── dist/index.js        # Compiled output
├── package.json
└── tsconfig.json

Plugin API usage

import type { Plugin } from "@opencode-ai/plugin";

const OpenSpecPlugin: Plugin = async (ctx) => {
  const isActive = await isOpenSpecProject(ctx);
  if (!isActive) return {};
  return { config: createConfigHook(ctx) };
};

Peer dependencies

  • @opencode-ai/plugin: ^1.1.19
  • @opencode-ai/sdk: ^1.1.19

Required runtime

  • Node.js (any version supporting ESM)
  • OpenCode (any version supporting plugin API v1.1.19+)

Activation condition

Plugin is active only when isOpenSpecProject(ctx) returns true (checks for openspec/ directory or similar OpenSpec project markers).

03

Components

opencode-plugin-openspec — Components

Plugin: OpenSpecPlugin (src/index.ts)

  • Detects OpenSpec projects via isOpenSpecProject
  • Returns config hook when active, empty object otherwise

Config hook: createConfigHook (src/config.ts)

  • Injects the openspec-plan agent definition into OpenCode configuration
  • Sets agent name, mode: "primary", description, prompt, permission rules, and color

Agent: openspec-plan

  • Name: openspec-plan
  • Mode: primary
  • Color: #FF6B6B
  • Description: "OpenSpec Architect - Plan and specify software architecture."
  • Prompt: OPENSPEC_SYSTEM_PROMPT (see prompts.md)

Permission rules (src/config.ts)

read: { "*": "allow" }           # Full read on entire project
glob: allow, grep: allow, list: allow, lsp: allow
todoread: allow, todowrite: allow
webfetch: allow, websearch: allow, codesearch: allow
task: allow, skill: allow, question: allow
doom_loop: ask, external_directory: ask
edit: { "*": "deny", "project.md": "allow", "AGENTS.md": "allow", "openspec/**": "allow", "specs/**": "allow" }
bash: { "*": "deny", 
        "openspec": "allow", "openspec *": "allow",
        "grep *": "allow", "ls": "allow", "ls *": "allow", "cat *": "allow",
        "find *": "allow", "echo": "allow", "echo *": "allow", "pwd": "allow",
        "which *": "allow", "env": "allow", "printenv *": "allow",
        "git status*": "allow", "git log*": "allow", "git diff*": "allow", "git show*": "allow" }

Detection utility: isOpenSpecProject (src/utils/detection.ts)

  • Checks if the current workspace is an OpenSpec project
  • Content not fetched but inferred to check for openspec/ directory or openspec/config.yaml

No hooks, skills, commands (AI-facing), or MCP servers

The plugin's entire contribution is the single injected agent definition.

05

Prompts

opencode-plugin-openspec — Prompts

Verbatim excerpt 1: OPENSPEC_SYSTEM_PROMPT (src/prompts.ts)

<Role>
You are the **OpenSpec Architect**.
Your goal is to design, specify, and document software architecture using the OpenSpec standard.
You work primarily with Markdown files in the `openspec/` and `specs/` directories.
</Role>

<Context>
This project follows the OpenSpec standard for documentation-driven development.
Key files:
- `project.md`: High-level project vision, goals, and scope.
- `openspec/AGENTS.md` (or `AGENTS.md`): Definitions of agents and their roles.
- `specs/**/*.spec.md`: Detailed specifications for components or features.
</Context>

<Rules>
1. **Context First**: ALWAYS read the content of `openspec/AGENTS.md` first. This is the most
   important context for understanding the project's agents and roles.
2. **No Direct Document Generation**: Do NOT generate or modify `*.spec.md` files directly.
   Your role is to discuss and plan.
3. **No Implementation**: Do NOT write implementation code (TypeScript, Python, etc.) unless
   explicitly requested to "implement" or "prototype". Your job is to *plan*, not to *build*.
4. **Structure**:
   - Plan for new spec files in `specs/<feature-name>/spec.md`.
   - Ensure alignment with `project.md`.
5. **Format**: Follow the existing Markdown structure found in the project. Use clear headers,
   bullet points, and diagrams (Mermaid) where appropriate.
6. **Workflow**:
   - **Collaborate**: Discuss the user's ideas and refine them together.
   - **Clarify**: Proactively ask questions to clarify requirements and ensure the design is sound.
   - **Finalize**: Once the plan is solid, instruct the user to run `/openspec.proposal` to
     generate the formal specification documents.
</Rules>

Prompting technique: XML-tagged role/context/rules structure. Uses absolute prohibitions ("Do NOT") for anti-patterns. Context-first mandate ("ALWAYS read openspec/AGENTS.md first"). Explicit handoff instruction to human-triggered command rather than autonomous generation. Role-persona injection ("You are the OpenSpec Architect").

Analysis

This prompt enforces planning-implementation separation through instruction, reinforced by the separate permission rules in config.ts. The system uses two layers: (1) the system prompt tells the agent what it should and shouldn't do, and (2) the OpenCode permission rules mechanically prevent certain file edits. The combination of instructional and mechanical enforcement is the distinctive pattern.

09

Uniqueness

opencode-plugin-openspec — Uniqueness & Positioning

differs_from_seeds

This is the only framework in this batch targeting OpenCode (not Claude Code). All 11 seed frameworks target Claude Code or are multi-tool. The plugin's architecture mirrors the seed pattern of kiro (IDE extension that injects behavior into a specific AI coding tool) but implemented for OpenCode rather than an IDE. The permission-based planning-implementation separation (write access only to spec files) is mechanically enforced through OpenCode's permission system, which is stronger than prompt-only enforcement used by most seed frameworks. No seed framework implements this two-layer enforcement (prompt instruction + mechanical permission).

Positioning

  • Category: OpenCode plugin — OpenSpec planning phase enforcement
  • User: OpenCode users who also use OpenSpec for spec-driven development
  • Integration: Transparent — auto-detected, auto-injected; no manual setup beyond opencode.json entry
  • Value: Prevents premature implementation during the planning phase through mechanical permission enforcement

Observable failure modes

  1. Single-agent limitation: The plugin adds only the planning agent; no implementation agent or workflow automation
  2. isOpenSpecProject() detection: If detection logic is strict, non-standard OpenSpec setups may not trigger the plugin
  3. Permission rules are last-match-wins: The edit: { "*": "deny", "project.md": "allow", ... } pattern depends on OpenCode's rule evaluation order — undocumented edge cases possible
  4. OpenCode-specific: Zero portability to Claude Code, Cursor, or other tools

Notable meta-pattern

The README has a dedicated "For LLM Agents" section with different installation instructions than the "For Humans" section — "IMPORTANT: Do NOT run npm install... You only need to edit the configuration file." This shows the plugin author anticipates AI agents installing tools autonomously and writes installation docs for both audiences.

Cross-references

  • Extends: OpenCode (AI coding tool)
  • Integrates with: OpenSpec
  • Analogous to intellij-openspec (this batch) — same intent, different target IDE/tool
04

Workflow

opencode-plugin-openspec — Workflow

Setup workflow

Step Actor Action Artifact
1 Human Add opencode-plugin-openspec to opencode.json Config updated
2 OpenCode Download plugin on next run Plugin loaded
3 Plugin isOpenSpecProject() check Agent injected if true

Planning phase workflow

Step Actor Action Artifact
1 Human Switch to openspec-plan agent in OpenCode OpenSpec Architect active
2 Human Describe desired change Agent discusses and plans
3 Agent Read openspec/AGENTS.md (required first) Project context loaded
4 Agent Discuss and refine requirements Collaborative planning
5 Agent Write/update planning documents openspec/**, specs/** modified
6 Agent Instruct user to run /openspec.proposal Formal spec documents generated

Approval gates

The agent's system prompt includes an explicit gate: "Once the plan is solid, instruct the user to run /openspec.proposal to generate the formal specification documents." The agent does not generate specs unilaterally — it defers the formal generation step to a human-triggered command.

Phase-to-artifact map

Phase Artifact
Plugin load openspec-plan agent available in agent selector
Planning session Updated openspec/** planning documents
Formal generation trigger Human runs /openspec.proposal

Key constraint

The agent system prompt explicitly bans: "Do NOT generate or modify *.spec.md files directly" and "Do NOT write implementation code unless explicitly requested to 'implement' or 'prototype'."

06

Memory Context

opencode-plugin-openspec — Memory & Context

State storage

None at the plugin level. The plugin injects an agent definition into OpenCode's config; all state lives in the OpenSpec project files.

Context injection

The agent's system prompt is injected at session start. The first thing the agent does is read openspec/AGENTS.md to load project context — this is the "memory" mechanism (file-based, read at session start).

Persistence

OpenSpec files (openspec/**, specs/**) persist between sessions.

Cross-session handoff

Implicit — the agent reads OpenSpec files at the start of each session, so any planning state written in previous sessions is available.

Context compaction

Not applicable.

07

Orchestration

opencode-plugin-openspec — Orchestration

Multi-agent support

Single agent (openspec-plan) injected. OpenCode may support multi-agent workflows but the plugin contributes only one agent.

Orchestration pattern

None — the plugin adds a single specialized agent mode, not an orchestration layer.

Isolation mechanism

OpenCode's permission system provides mechanical isolation: the openspec-plan agent cannot write to implementation files. This is permission-based isolation, not git-branch or container-based.

Multi-model support

None from the plugin itself. OpenCode may route to different models but the plugin does not configure this.

Execution mode

Interactive-loop (the agent runs within OpenCode's chat session).

Subagents

None.

Crash recovery

Not applicable.

08

Ui Cli Surface

opencode-plugin-openspec — UI & CLI Surface

CLI binary

None. The plugin is consumed by OpenCode at runtime.

Local UI surface

The plugin contributes to OpenCode's existing UI:

  • Agent selector: openspec-plan agent appears in OpenCode's agent selection UI with coral color (#FF6B6B)
  • OpenCode chat: The agent operates within OpenCode's normal chat interface

IDE integration

OpenCode is the IDE/agent host. The plugin extends OpenCode's behavior without adding a separate UI.

Observability

None. The plugin's only observable output is the presence of the openspec-plan agent in OpenCode's agent selector.

Installation surface

opencode.json — the plugin is declared here and OpenCode handles fetching. No npm install, no build step from the user's perspective.

For LLM agents installing the plugin

The README includes specific instructions for AI agents: "IMPORTANT: Do NOT run npm install or any terminal commands. You only need to edit the configuration file." — This is a notable meta-pattern: the README is written for both human and AI readers, with explicit different instructions for each.

Related frameworks

same archetype · same primary tool · same memory type

BMAD-METHOD ★ 48k

Provides a full agile delivery lifecycle with named expert-persona AI collaborators that elicit the human's best thinking rather…

Agent OS ★ 4.6k

Extracts implicit codebase conventions into token-efficient markdown standards files and injects them selectively into AI agent…

Claude Conductor ★ 367

Gives Claude Code a persistent, cross-linked, auto-analyzed documentation system so it retains codebase context across sessions.

Spec-Driver (Greenfield Spec-Driven Development) ★ 25

Prevents spec rot in AI-assisted development by making implementation changes flow back into evergreen, authoritative specs via…

Anthropic Knowledge Work Plugins ★ 16k

Role-specialized plugin bundles with live MCP connectors that turn Claude into a domain expert for enterprise knowledge workers.

Codex Integration for Claude Code (skill-codex) ★ 1.3k

Single Claude Code skill that handles Codex CLI invocation correctly (stdin blocking, thinking token suppression, session resume)…