spec-research

A requirements-research command that turns a request into a set of constraints and checkable success criteria. It explores the relevant parts of a project in parallel and creates a structured proposal.

In plain words
What is it for?
Use it to research a feature request, identify technical limits, and prepare a specification for later planning and implementation.
Why use it?
It reduces guesswork before planning or coding by recording what the solution must satisfy and which directions should be ruled out.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/fengshao1227/ccg-workflow/spec-research
Clone the repo
git clone --depth 1 https://github.com/fengshao1227/ccg-workflow
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,971 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00016 $0.01971
Opus 5 $0.00008 $0.00986
Sonnet 5 $0.00003 $0.00394
Haiku 4.5 $0.00002 $0.00197

Measured yesterday against content hash 7f9a11366362, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

spec-research scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

templates/commands/spec-research.md · 157 lines

How it starts

The opening of the file, as written. The whole thing — 157 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Core Philosophy

  • Research produces constraint sets, not information dumps. Each constraint narrows the solution space.
  • Constraints tell subsequent stages "don't consider this direction," enabling mechanical execution without decisions.
  • Output: 约束集合 + 可验证的成功判据 (constraint sets + verifiable success criteria).
  • Strictly adhere to OPSX rules when writing spec-structured documents.

Guardrails

  • STOP! BEFORE ANY OTHER ACTION: You MUST perform Prompt Enhancement FIRST. This is NON-NEGOTIABLE.
  • NEVER divide subagent tasks by roles (e.g., "架构师agent", "安全专家agent").
  • ALWAYS divide by context boundaries (e.g., "user-related code", "authentication logic").
  • Each subagent context must be self-contained with independent output.
  • Use {{MCP_SEARCH_TOOL}} to minimize grep/find operations.
  • Do not make architectural decisions—surface constraints that guide decisions.
  • USER GUIDANCE RULE: When suggesting next steps to the user, ALWAYS use CCG commands (/ccg:spec-research, /ccg:spec-plan, /ccg:spec-impl, /ccg:spec-review). NEVER suggest /opsx:* commands to the user. If OpenSpec CLI returns error messages referencing OPSX skills, translate them to CCG equivalents.
  • PHASE BOUNDARY: This phase ONLY generates the OPSX proposal artifact. Do NOT modify any source code. Do NOT proceed to planning or implementation. After the proposal is generated, STOP and inform the user: "Research complete. Run /ccg:spec-plan to continue."

Steps 0. MANDATORY: Enhance Requirement FIRST

  • DO THIS IMMEDIATELY. DO NOT SKIP.
  • Prompt 增强(按 /ccg:enhance 的逻辑执行):分析 $ARGUMENTS 的意图、缺失信息、隐含假设,补全为结构化需求(明确目标、技术约束、范围边界、验收标准)。
  • Use enhanced prompt for ALL subsequent steps.
  1. Generate OPSX Change

    • Check if change already exists:
      openspec list --json
      
    • If change doesn't exist, create it:
      openspec new change "<brief-descriptive-name>"
      
    • This scaffolds openspec/changes/<name>/ with proposal.md.
    • If change already exists, continue with existing change.
  2. Initial Codebase Assessment

    • Use {{MCP_SEARCH_TOOL}} to scan codebase.
    • Determine project scale: single vs multi-directory structure.
    • Decision: If multi-directory → enable parallel Explore subagents.
  3. Define Exploration Boundaries (Context-Based)

    • Identify natural context boundaries (NOT functional roles):
      • Subagent 1: User domain code (models, services, UI)
      • Subagent 2: Auth & authorization (middleware, session, tokens)
      • Subagent 3: Infrastructure (configs, deployments, builds)
    • Each boundary should be self-contained: no cross-communication needed.
  4. Parallel Multi-Model Exploration

    • CRITICAL: You MUST launch BOTH {{BACKEND_PRIMARY}} AND {{FRONTEND_PRIMARY}} in a SINGLE message with TWO Bash tool calls.
    • DO NOT call one model first and wait. Launch BOTH simultaneously with run_in_background: true.
    • 工作目录{{WORKDIR}} 必须通过 Bash 执行 pwd(Unix)或 cd(Windows CMD)获取当前工作目录的绝对路径,禁止从 $HOME 或环境变量推断。如果用户通过 /add-dir 添加了多个工作区,先确定任务相关的工作区。

    Output Template (instruct both models to use this format):

    {
      "module_name": "context boundary explored",
      "existing_structures": ["key patterns found"],
      "existing_conventions": ["standards in use"],
      "constraints_discovered": ["hard constraints limiting solution space"],
      "open_questions": ["ambiguities requiring user input"],
      "dependencies": ["cross-module dependencies"],
      "risks": ["potential blockers"],
      "success_criteria_hints": ["observable success behaviors"]
    }
    

    Step 4.1: In ONE message, make TWO parallel Bash calls:

    FIRST Bash call ({{BACKEND_PRIMARY}} — backend boundaries):

    Bash({
      command: "~/.claude/bin/codeagent-wrapper --progress --backend {{BACKEND_PRIMARY}} {{GEMINI_MODEL_FLAG}}{{GROK_MODEL_FLAG}}{{KIMI_MODEL_FLAG}}{{OPENCODE_MODEL_FLAG}}- \"{{WORKDIR}}\" <<'EOF'\nExplore backend context boundaries for <change description>:\n- Existing structures and patterns\n- Conventions in use\n- Hard constraints limiting solution space\n- Dependencies and risks\nOUTPUT: JSON using the output template above\nEOF",
      run_in_background: true,
      timeout: 300000,
      description: "{{BACKEND_PRIMARY}}: backend boundary exploration"
    })
    

Read the full file on GitHub · 157 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 157 lines · 16 tokens per session scan A 7f9a11366362

Subscribe to this mod's changes

spec-research is a command published in the GitHub repository fengshao1227/ccg-workflow (5,865 stars, last pushed 2d ago), licensed MIT. It adds 16 tokens to every session and 1,971 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.