Communitygithub.com

tcut: 将增量规范同步至主规范

将变更中的增量规范同步到主规范。当用户希望将增量规范的更改更新到主规范,同时保留该变更时使用。

tcut: 将增量规范同步至主规范 是什么?

该技能(tcut)用于将增量规范(delta spec)中的变更同步至主规范(main spec),而无需归档原始变更。它特别适合需要智能合并的场景,例如在不复制整个需求的前提下添加一个测试场景。支持 `openspec` 工具链,并通过 `--store` 参数管理存储在独立 OpenSpec 仓库中的规范。工作流程包括:解析变更状态、查找增量规范、智能应用添加/修改/删除/重命名需求,最后汇总更新的能力模块和具体改动。该操作是幂等的——多次运行结果一致。用户可指定变更名称,否则需从对话上下文推断或通过列表提示用户选择。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/AmanVarshney01/tcut/tree/HEAD/.claude/skills/openspec-sync-specs

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

将增量规范从变更同步至主规范。

这是一个由代理驱动的操作——您将读取增量规范并直接编辑主规范以应用变更。这允许智能合并(例如,添加一个场景而不复制整个需求)。

存储选择: 如果用户命名了一个存储(存储是在此机器上注册的独立 OpenSpec 仓库),或者工作存在于某个存储中,请运行 openspec store list --json 发现已注册的存储 ID,然后在读取或写入规范和变更的命令(new change, status, instructions, list, show, validate, archive, doctor, context)中传递 --store <id>。其他命令不接受此标志。命令输出的提示信息已包含该标志;请在后续操作中保留它。没有存储时,命令作用于最近的本地 openspec/ 根目录。

输入:可选择指定变更名称。如果省略,则检查是否可以从对话上下文中推断。如果模糊或不明确,您必须提示用户选择可用的变更。

步骤

  1. 如果未提供变更名称,提示用户选择

    运行 openspec list --json 获取可用变更。使用 AskUserQuestion 工具 让用户选择。

    显示包含增量规范(位于 specs/ 目录下)的变更。

    重要:不要猜测或自动选择变更。始终让用户选择。

  2. 解析变更上下文

    运行:

    openspec status --change "<名称>" --json
    
  3. 查找增量规范

    使用状态 JSON 中的 artifactPaths.specs.existingOutputPaths 作为增量规范文件列表。

    每个增量规范文件包含以下部分:

    • ## ADDED Requirements - 需要添加的新需求
    • ## MODIFIED Requirements - 对现有需求的更改
    • ## REMOVED Requirements - 需要删除的需求
    • ## RENAMED Requirements - 需要重命名的需求(FROM:/TO: 格式)

    如果未找到增量规范,请通知用户并停止。

  4. 对于每个增量规范,将变更应用到主规范

    对于 CLI 返回的每个仓库本地能力增量规范路径:

    a. 读取增量规范 以了解预期的变更

    b. 读取主规范 openspec/specs/<能力>/spec.md(可能尚不存在)

    c. 智能应用变更:

    ADDED Requirements:

    • 如果主规范中不存在该需求 → 添加它
    • 如果需求已存在 → 更新以匹配(视为隐式 MODIFIED)

    MODIFIED Requirements:

    • 在主规范中找到该需求
    • 应用变更——可以是:
      • 添加新场景(无需复制现有场景)
      • 修改现有场景
      • 更改需求描述
    • 保留增量中未提及的场景/内容

    REMOVED Requirements:

    • 从主规范中删除整个需求块

    RENAMED Requirements:

    • 找到 FROM 需求,重命名为 TO

    d. 如果能力尚不存在,创建新的主规范:

    • 创建 openspec/specs/<能力>/spec.md
    • 添加 Purpose 部分(可以简短,标记为 TBD)
    • 添加 Requirements 部分,包含 ADDED 需求
  5. 显示摘要

    应用所有变更后,汇总:

    • 更新了哪些能力模块
    • 做了哪些更改(添加/修改/删除/重命名的需求)

增量规范格式参考

## ADDED Requirements

### Requirement: New Feature
系统应当做某事。

#### Scenario: Basic case
- **WHEN** 用户执行 X
- **THEN** 系统执行 Y

## MODIFIED Requirements

### Requirement: Existing Feature
#### Scenario: New scenario to add
- **WHEN** 用户执行 A
- **THEN** 系统执行 B

## REMOVED Requirements

### Requirement: Deprecated Feature

## RENAMED Requirements

- FROM: `### Requirement: Old Name`
- TO: `### Requirement: New Name`

关键原则:智能合并

与程序化合并不同,您可以应用部分更新:

  • 要添加一个场景,只需在 MODIFIED 下包含该场景——不要复制现有场景
  • 增量代表意图,而不是整体替换
  • 使用您的判断力合理合并变更

成功时的输出

## Specs Synced: <变更名称>

更新的主规范:

**<能力1>**:
- 添加了需求:“新功能”
- 修改了需求:“现有功能”(添加了 1 个场景)

**<能力2>**:
- 创建了新规范文件
- 添加了需求:“另一个功能”

主规范现已更新。该变更仍处于活跃状态——实现完成后请归档。

防护措施

  • 在进行更改前,读取增量规范和主规范
  • 保留增量中未提及的现有内容
  • 如果某些内容不清楚,请询问澄清
  • 在操作过程中显示您正在更改的内容
  • 该操作应该是幂等的——运行两次应得到相同结果

Individual skills in this repo

This repo contains 7 individual skills — each has its own dedicated page.

AmanVarshney01/tcut

Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.

AmanVarshney01/tcut

Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.

AmanVarshney01/tcut

Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.

AmanVarshney01/tcut

Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.

AmanVarshney01/tcut

Update an OpenSpec change by revising its existing planning artifacts and keeping them coherent with one another. Use when the user wants to revise a change's plan, fold new decisions into it, or reconcile its artifacts after an edit. Never edits code.

AmanVarshney01/tcut

Combine tcut terminal recordings with Remotion to produce polished, motion-designed launch/promo videos (title cards, animated captions, layered terminal footage). Use when the user wants a product video, launch video, or social video that features terminal/CLI footage.

AmanVarshney01/tcut

Record reproducible terminal videos (MP4/GIF/SVG/HTML) from TypeScript scripts or live sessions with the tcut CLI. Use when the user wants a terminal demo, CLI screencast, TUI recording, or animated terminal GIF for a README, website, or social post.

相关技能