spec-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSpec 上下文定位(FEATURE_DIR)
Spec Context Localization (FEATURE_DIR)
概览
Overview
在任何 Spec 命令/技能里,只要会读写 ,就必须先确定 。本仓库以 当前 Git 分支名作为 spec pack 的定位锚点,禁止猜路径。
requirements/*.md{FEATURE_DIR}In any Spec command/skill, whenever you need to read or write , you must first determine . This repository uses the current Git branch name as the anchor for locating the spec pack; path guessing is strictly prohibited.
requirements/*.md{FEATURE_DIR}何时使用
When to Use
- 你将要读/写:
{FEATURE_DIR}/requirements/raw.md | clarify.md | competitors.md | solutions.md | prd.md - 你不确定当前处于哪个 spec pack(担心读写错目录)
- 你看到“分支名不规范 / 目录结构不完整 / 缺 .aisdlc”之类上下文错误
- You are about to read/write:
{FEATURE_DIR}/requirements/raw.md | clarify.md | competitors.md | solutions.md | prd.md - You are unsure which spec pack you are currently in (worried about reading/writing to the wrong directory)
- You encounter context errors such as "non-compliant branch name/incomplete directory structure/missing .aisdlc"
唯一做法(PowerShell)
The Only Correct Approach (PowerShell)
powershell
. ".\spec-common.ps1"
$context = Get-SpecContext
$FEATURE_DIR = $context.FEATURE_DIR
Write-Host "FEATURE_DIR=$FEATURE_DIR"powershell
. ".\spec-common.ps1"
$context = Get-SpecContext
$FEATURE_DIR = $context.FEATURE_DIR
Write-Host "FEATURE_DIR=$FEATURE_DIR"硬规则(必须遵守)
Hard Rules (Must Follow)
- 先定位再读写:任何读/写 之前,必须先运行上面的脚本并回显
requirements/*.md。FEATURE_DIR=... - 失败就停止:报错时,必须立刻停止,不得继续生成/写文件内容(否则几乎必然跑偏上下文)。
Get-SpecContext - 只用 FEATURE_DIR 拼路径:后续所有路径都必须以 为前缀(禁止用当前工作目录做相对路径猜测)。
$FEATURE_DIR
- Locate first, then read/write: Before any read/write operation on , you must run the above script and echo
requirements/*.md.FEATURE_DIR=... - Stop on failure: When reports an error, you must stop immediately and must not continue generating/writing file content (otherwise, you will almost certainly deviate from the correct context).
Get-SpecContext - Only use FEATURE_DIR to construct paths: All subsequent paths must use as the prefix (guessing relative paths using the current working directory is prohibited).
$FEATURE_DIR
常见错误
Common Mistakes
- 在非 spec 分支上执行:分支名不符合 ,会导致无法定位 spec pack。
{num}-{short-name} - 手写 路径:人会写错,AI 更容易写错;必须以脚本输出为准。
.aisdlc/specs/... - 继续执行“生成文档”:只要上下文失败,就停止并先修复分支/目录结构。
- Executing on a non-spec branch: If the branch name does not conform to the format, the spec pack cannot be located.
{num}-{short-name} - Manually writing paths like : Humans make mistakes, and AI is even more prone to errors; you must rely on the script's output.
.aisdlc/specs/... - Continuing to "generate documents": As long as the context validation fails, stop and first fix the branch/directory structure.