Specify

From ZaxbyHub/opencode-swarm · View interactive version

Specify is an AI agent skill from the GitHub repository ZaxbyHub/opencode-swarm. Full execution protocol for MODE: SPECIFY -- spec creation, codebase reality checks, SME input, QA gate persistence, and optional council spec review.

How to use this skill

Skill file

Specify Protocol

This protocol is loaded on demand by the architect runtime. The architect prompt keeps only activation, action, and hard safety constraints; the full execution details live here.

MODE: SPECIFY

Activates when: user asks to "specify", "define requirements", "write a spec", or "define a feature"; OR /swarm specify is invoked; OR no EFFECTIVE spec exists and no .swarm/plan.md exists (use /swarm sdd status to determine effective-spec existence — native .swarm/spec.md, OpenSpec openspec/, or Spec-Kit .specify/).

1. Run /swarm sdd status to determine whether an effective spec exists and, if so, how it should be handled. An effective spec exists iff /swarm sdd status reports a resolved spec. /swarm sdd status reflects readEffectiveSpecSync, which returns null (NO effective spec) for: no sources, multiple competing sources (openspec+speckit), multi-feature Spec-Kit without a selected feature, or any unresolvable state. When /swarm sdd status reports a resolved spec, classify it as NATIVE (native .swarm/spec.md) vs NON-NATIVE (projected). When it reports NO resolved spec, do NOT treat any source as an effective spec. Based on this classification, branch to the appropriate sub-step:

1a. NATIVE SPEC — overwrite/refine/archive. Ask the user "A spec already exists. Do you want to overwrite it or refine it?"

1b. NON-NATIVE SPEC — non-shadowing check (FR-002). The effective spec comes from openspec/ or .specify/ sources with no native .swarm/spec.md. Do NOT silently author a competing native spec. Instead OFFER the user a choice:

1c. AMBIGUOUS — multiple SDD sources detected. Both openspec/ AND .specify/ exist with no native .swarm/spec.md. Per readEffectiveSpecSync semantics this is NOT an effective spec (the function returns null). Do NOT treat this as a single-source NON-NATIVE choice. Instead:

1d. NO EFFECTIVE SPEC. Proceed directly to generation (step 2).

1e. Run CODEBASE REALITY CHECK for any codebase references mentioned by the user or implied by the feature. Skip if work is purely greenfield (no existing codebase to check). Report discrepancies before proceeding to explorer.

  1. Delegate to the active swarm's explorer agent to scan the codebase for relevant context (existing patterns, related code, affected areas).
  2. Delegate to the active swarm's sme agent for domain research on the feature area to surface known constraints, best practices, and integration concerns.
  3. Generate .swarm/spec.md capturing:

5. Write the spec to .swarm/spec.md.

5b. DEFER QA AND EXECUTION PROFILE SELECTION.

SPECIFY does not collect, infer, or stage QA gates, parallel coder count, commit frequency, or auto_proceed. Those choices depend on the drafted task graph and its exact plan identity. MODE: PLAN freezes the exact swarm_id and plan title, presents the unified four-choice dialogue, persists the gate profile, and saves the execution profile. Do not write execution choices to .swarm/context.md.

General Council advisory input is offered as an early workflow option in MODE: BRAINSTORM (Phase 1b) and MODE: PLAN before save_plan, not as a SPECIFY step. If the user wants council input during SPECIFY, they can use /swarm council <question> manually.

  1. Report a summary to the user (MUST count, SHALL count, scenario count, clarification markers) and suggest the next step: CLARIFY-SPEC (if markers exist) or PLAN.

SPEC CONTENT RULES — the spec MUST NOT contain:

Each functional requirement MUST be independently testable.

Focus on WHAT users need and WHY — never HOW to implement.

No technology stack, APIs, or code structure in the spec.

Each requirement must be independently testable.

Prefer informed defaults over asking the user — use [NEEDS CLARIFICATION] only when uncertainty could change scope, security, or core behavior.

EXTERNAL PLAN IMPORT PATH — when the user provides an existing implementation plan (markdown content, pasted text, or a reference to a file):

  1. Run CODEBASE REALITY CHECK scoped to every file, function, API, and behavioral assumption in the provided plan. Report discrepancies to user before proceeding.
  2. Read and parse the provided plan content.
  3. Reverse-engineer .swarm/spec.md from the plan:
  1. Validate the provided plan against swarm task format requirements:
  1. Report gaps, format issues, and improvement suggestions to the user.
  2. Ask: "Should I also flesh out any areas that seem underspecified?"
  1. Output: both a .swarm/spec.md (extracted from the plan) and a validated version of the user's plan.

EXTERNAL PLAN RULES:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.