Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Spec Coding

把一句模糊的编码需求,收敛成可以直接实现和验收的规格

Turn ambiguous coding requests into implementation-ready specifications

Codex Skill Bilingual Question Budget

中文 · English


中文说明

很多 AI 编程请求只有一句话:

“这里优化一下。”
“把这个模块改得更好。”
“登录功能帮我加一下。”

问题不在于 AI 不会写代码,而在于这些说法可能对应多种完全不同的实现。spec-coding 会先检查项目现状,找出真正会改变实现结果的模糊点,再通过少量、有取舍说明的问题,把请求收敛成可实现、可测试、可确认的技术规格。

它不是一套沉重的 PRD 流程,也不会为了显得严谨而把每个小改动都变成需求访谈。

核心能力

  • 先查项目,再问用户:能从代码、配置、测试和现有文档中找到的答案,不重复询问。
  • 只问关键分叉:只有不同答案会改变行为、接口、数据、安全、兼容性或验收方式时才提问。
  • 最多五问,不要求问满:每次回答后重新判断;信息足够就立即停止。
  • 帮助非技术用户做决定:把框架和底层术语翻译成结果、风险与取舍,并给出推荐选项。
  • 明确就绪状态:使用 READY 和 NEEDS_DECISION 区分“可以实施”与“仍有关键决策”。
  • 确认后才改代码:先展示完整规格,用户确认后才进入实施。

工作方式

flowchart LR
    A[模糊的编码请求] --> B[检查项目现状]
    B --> C{存在关键实现分叉?}
    C -- 否 --> D[生成精简规格]
    C -- 是 --> E[提出高影响问题]
    E --> F{信息是否足够?}
    F -- 否且未到5问 --> E
    F -- 是 --> G[READY 规格]
    F -- 5问后仍不明确 --> H[NEEDS_DECISION]
    D --> I[展示给用户确认]
    G --> I
    I --> J[规划或实施]
Loading

前后对比

模糊请求 Spec Coding 关注的问题 可验收结果示例
“优化一下接口” 当前基准、目标延迟、负载、允许的数据新鲜度 P95 延迟在指定负载下低于目标值,结果正确性不变
“重构这个模块” 重构目的、必须保持的行为、兼容边界 公共接口不变,现有回归测试全部通过
“增加登录” 身份来源、会话行为、保护范围、安全失败场景 未登录访问受保护页面时得到明确且可测试的结果
“按钮改成蓝色” 若目标和样式规范已明确,则不提问 指定按钮采用项目现有的蓝色设计令牌

安装

方法一:下载 ZIP

  1. 点击仓库右上角的 Code → Download ZIP。

  2. 解压后,将文件夹重命名为 spec-coding。

  3. 把整个文件夹复制到:

    Windows

    %USERPROFILE%\.codex\skills\spec-coding
    

    macOS / Linux

    ~/.codex/skills/spec-coding
    
  4. 确认 SKILL.md 直接位于 spec-coding 文件夹内,而不是多嵌套了一层目录。

  5. 重新打开 Codex 或开始一个新任务。

方法二:Git Clone

git clone https://github.com/Zyc20010326/spec-coding.git ~/.codex/skills/spec-coding

使用

显式调用:

$spec-coding 请先把“优化这个接口”收敛成可实施规格,再开始修改。

也可以直接提出模糊的编码请求。Skill 已允许选择性自动触发:明确、低风险的一步修改不会强制进入访谈。

输出规格会按任务需要选用以下内容,而不是机械填满模板:

  • 目标与范围
  • 当前状态与必须保持的行为
  • 技术方案、接口和数据变化
  • 异常与边界行为
  • 性能、安全、兼容和迁移要求
  • 验收场景、已确认决策和默认假设

状态含义

  • READY:剩余未知不会实质改变实现或验收,可以交给开发者或编码代理执行。
  • NEEDS_DECISION:最多五问后仍有关键分叉;Skill 会列出阻塞项和推荐方案,但不会假装需求已经明确。

适用边界

spec-coding 适合功能开发、性能优化、重构、迁移、集成和其他存在实质歧义的编码任务。它不会:

  • 替代完整的产品调研或架构评审;
  • 强迫简单修改生成独立规格文件;
  • 在用户确认前修改代码;
  • 因为用户没指定框架,就无视项目现有技术栈重新选型。

English

Many AI coding requests begin with a single vague sentence:

“Optimize this.”
“Make this module better.”
“Add login.”

The problem is not whether the model can write code. The problem is that each request can lead to several valid—but incompatible—implementations. spec-coding inspects the project first, identifies only the ambiguities that materially affect the result, and turns them into a small number of decision-oriented questions.

The result is an implementation-ready, testable specification without forcing every small change through a heavyweight requirements process.

Highlights

  • Inspect before asking — derive answers from code, configuration, tests, and existing specifications whenever possible.
  • Ask only consequential questions — clarify decisions that change behavior, interfaces, data, security, compatibility, or acceptance.
  • Up to five questions, not five required — reassess after every answer and stop as soon as the request is sufficiently specified.
  • Accessible to nontechnical users — translate technology choices into outcomes, risks, and tradeoffs, with a recommended option.
  • Explicit readiness states — distinguish an actionable READY specification from unresolved NEEDS_DECISION work.
  • Confirm before implementation — show the complete specification before modifying code.

How it works

  1. Inspect the minimum relevant repository context.
  2. Separate discoverable facts, safe defaults, user decisions, and irrelevant gaps.
  3. Rank unresolved decisions by impact, uncertainty, and irreversibility.
  4. Ask only the highest-value questions, stopping early when enough information is available.
  5. Produce a compact specification with a READY or NEEDS_DECISION status.
  6. Wait for confirmation before planning or implementation continues.

Installation

Download this repository and place it at:

~/.codex/skills/spec-coding

On Windows, the equivalent location is:

%USERPROFILE%\.codex\skills\spec-coding

Make sure SKILL.md is directly inside that directory. Reopen Codex or start a new task after installation.

Alternatively:

git clone https://github.com/Zyc20010326/spec-coding.git ~/.codex/skills/spec-coding

Usage

Use $spec-coding to clarify “optimize this endpoint” into an implementation-ready specification before making changes.

The skill also supports selective automatic invocation for materially ambiguous coding requests. Clear, low-risk, one-step changes should remain lightweight.

Readiness states

  • READY — no remaining unknown materially changes implementation or acceptance.
  • NEEDS_DECISION — an important fork remains after the question ceiling; implementation must not begin yet.

Project structure

spec-coding/
├── SKILL.md
├── README.md
├── agents/
│   └── openai.yaml
└── references/
    └── readiness-model.md

Design references

The workflow is informed by established specification and clarification practices, including:

Contributing

Issues and pull requests are welcome. Useful contributions include realistic ambiguous coding requests, examples of unnecessary questions, missed implementation forks, and improvements to the readiness criteria.

Clear enough to build. Small enough to use.
足够明确,可以开工;足够轻量,愿意使用。

About

Codex 需求澄清 Skill:让你提需求不再迷茫,也让 Agent 别再对着模糊要求一顿脑补,最后写出幻觉还要挨骂。A Codex requirements clarification skill that helps you say what you actually want—so agents stop hallucinating their way through vague requests and getting yelled at afterward.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors