spec-research

spec-research is a command for Claude Code from qinye6/pi-ccg. It costs 16 tokens per session (1,947 once invoked), scanned A, a copy of spec-research, MIT.

A research command that turns a software request into constraints and checkable success conditions. OpenSpec is a framework for organizing software changes as structured proposals, specifications, and tasks.

In plain words
What is it for?
Use it to explore a requested change in parallel across parts of a codebase and prepare an OpenSpec proposal for the next planning stage.
Why use it?
It reduces guesswork by identifying what the implementation must and must not do before planning begins. It also separates gathering constraints from making design decisions.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: reads .claude/ paths; mentions subagents; names the AskUserQuestion tool.

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/qinye6/pi-ccg/spec-research
Clone the repo
git clone --depth 1 https://github.com/qinye6/pi-ccg

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for spec-research

README.md
[![agentmods](https://agentmods.dev/badge/commands/qinye6/pi-ccg/spec-research.svg)](https://agentmods.dev/commands/qinye6/pi-ccg/spec-research)
Your own site
<a href="https://agentmods.dev/commands/qinye6/pi-ccg/spec-research"><img src="https://agentmods.dev/badge/commands/qinye6/pi-ccg/spec-research.svg" alt="Measured on agentmods" height="20"></a>
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,947 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.1 $0.00016 $0.01947
Opus 5 $0.00008 $0.00974
Sonnet 5 $0.00003 $0.00389
Haiku 4.5 $0.00002 $0.00195

Measured 6d ago against content hash d7c6f543b5ba, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 6d ago.

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

This is a copy

100% identical to spec-research — 4 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

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}}- \"{{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. 6d ago First seen · 157 lines · 16 tokens per session scan A d7c6f543b5ba

Subscribe to this mod's changes

spec-research is a command published in the GitHub repository qinye6/pi-ccg (10 stars, last pushed 11d ago), licensed MIT. It adds 16 tokens to every session and 1,947 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to spec-research, differing in 4 lines, and is treated as a copy.