cc-devflow 1.0.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/.claude/CLAUDE.md +123 -4
  2. package/.claude/agents/code-quality-reviewer.md +205 -0
  3. package/.claude/agents/spec-reviewer.md +221 -0
  4. package/.claude/commands/cancel-ralph.md +59 -0
  5. package/.claude/commands/flow-dev.md +202 -21
  6. package/.claude/commands/flow-epic.md +33 -0
  7. package/.claude/commands/flow-fix.md +138 -20
  8. package/.claude/commands/flow-init.md +104 -15
  9. package/.claude/commands/flow-new.md +84 -35
  10. package/.claude/commands/flow-prd.md +16 -3
  11. package/.claude/commands/flow-release.md +33 -0
  12. package/.claude/commands/flow-review.md +257 -0
  13. package/.claude/docs/templates/ATTEMPT_TEMPLATE.md +156 -0
  14. package/.claude/docs/templates/BRAINSTORM_TEMPLATE.md +148 -0
  15. package/.claude/docs/templates/ERROR_LOG_TEMPLATE.md +80 -0
  16. package/.claude/docs/templates/INIT_FLOW_TEMPLATE.md +22 -14
  17. package/.claude/guides/workflow-guides/flow-orchestrator.md +2 -2
  18. package/.claude/hooks/hooks.json +15 -0
  19. package/.claude/hooks/ralph-stop-hook.sh +190 -0
  20. package/.claude/rules/devflow-conventions.md +3 -1
  21. package/.claude/rules/project-constitution.md +256 -2
  22. package/.claude/rules/rationalization-library.md +282 -0
  23. package/.claude/scripts/create-requirement.sh +19 -6
  24. package/.claude/scripts/setup-ralph-loop.sh +155 -0
  25. package/.claude/scripts/verify-gate.sh +269 -0
  26. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +70 -20
  27. package/.claude/skills/file-header-guardian/SKILL.md +56 -0
  28. package/.claude/skills/flow-attention-refresh/SKILL.md +170 -0
  29. package/.claude/skills/flow-brainstorming/SKILL.md +161 -0
  30. package/.claude/skills/flow-debugging/SKILL.md +221 -0
  31. package/.claude/skills/flow-finishing-branch/SKILL.md +189 -0
  32. package/.claude/skills/flow-receiving-review/SKILL.md +153 -0
  33. package/.claude/skills/flow-tdd/SKILL.md +218 -0
  34. package/.claude/skills/fractal-docs-generator/SKILL.md +45 -0
  35. package/.claude/skills/skill-rules.json +75 -0
  36. package/.claude/skills/verification-before-completion/SKILL.md +158 -0
  37. package/README.md +104 -19
  38. package/README.zh-CN.md +79 -1
  39. package/docs/commands/flow-init.md +3 -1
  40. package/docs/commands/flow-init.zh-CN.md +3 -1
  41. package/package.json +1 -1
  42. package/.claude/tsc-cache/777aa1de-497e-411b-a40f-13b74efcec58/affected-repos.txt +0 -1
@@ -0,0 +1,269 @@
1
+ #!/bin/bash
2
+ # ============================================================
3
+ # Verification Gate Script
4
+ # Enforces "Evidence before assertions" principle
5
+ # ============================================================
6
+
7
+ set -e
8
+
9
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+
11
+ # Colors
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ NC='\033[0m'
16
+
17
+ usage() {
18
+ echo "Usage: $0 --type TYPE [OPTIONS]"
19
+ echo ""
20
+ echo "Types:"
21
+ echo " prd Verify PRD completion"
22
+ echo " epic Verify EPIC completion"
23
+ echo " dev Verify development completion"
24
+ echo " qa Verify QA completion"
25
+ echo " release Verify release readiness"
26
+ echo ""
27
+ echo "Options:"
28
+ echo " --req-dir DIR Requirement directory"
29
+ echo " --verbose Show detailed output"
30
+ echo " --json Output as JSON"
31
+ }
32
+
33
+ verify_prd() {
34
+ local req_dir="$1"
35
+ local errors=0
36
+
37
+ echo -e "${YELLOW}Verifying PRD completion...${NC}"
38
+
39
+ # Check PRD.md exists
40
+ if [[ ! -f "${req_dir}/PRD.md" ]]; then
41
+ echo -e "${RED}ERROR: PRD.md not found${NC}"
42
+ ((errors++))
43
+ else
44
+ echo -e "${GREEN}✓ PRD.md exists${NC}"
45
+ fi
46
+
47
+ # Check BRAINSTORM.md exists
48
+ if [[ ! -f "${req_dir}/BRAINSTORM.md" ]]; then
49
+ echo -e "${RED}ERROR: BRAINSTORM.md not found${NC}"
50
+ ((errors++))
51
+ else
52
+ echo -e "${GREEN}✓ BRAINSTORM.md exists${NC}"
53
+ fi
54
+
55
+ # Check for TODO/FIXME in PRD
56
+ if grep -q "TODO\|FIXME\|{{" "${req_dir}/PRD.md" 2>/dev/null; then
57
+ echo -e "${RED}ERROR: PRD.md contains TODO/FIXME/placeholders${NC}"
58
+ ((errors++))
59
+ else
60
+ echo -e "${GREEN}✓ PRD.md has no placeholders${NC}"
61
+ fi
62
+
63
+ return $errors
64
+ }
65
+
66
+ verify_epic() {
67
+ local req_dir="$1"
68
+ local errors=0
69
+
70
+ echo -e "${YELLOW}Verifying EPIC completion...${NC}"
71
+
72
+ # Check EPIC.md exists
73
+ if [[ ! -f "${req_dir}/EPIC.md" ]]; then
74
+ echo -e "${RED}ERROR: EPIC.md not found${NC}"
75
+ ((errors++))
76
+ else
77
+ echo -e "${GREEN}✓ EPIC.md exists${NC}"
78
+ fi
79
+
80
+ # Check TASKS.md exists
81
+ if [[ ! -f "${req_dir}/TASKS.md" ]]; then
82
+ echo -e "${RED}ERROR: TASKS.md not found${NC}"
83
+ ((errors++))
84
+ else
85
+ echo -e "${GREEN}✓ TASKS.md exists${NC}"
86
+ fi
87
+
88
+ return $errors
89
+ }
90
+
91
+ verify_dev() {
92
+ local req_dir="$1"
93
+ local errors=0
94
+
95
+ echo -e "${YELLOW}Verifying development completion...${NC}"
96
+
97
+ # Run tests
98
+ echo "Running tests..."
99
+ if npm test 2>/dev/null; then
100
+ echo -e "${GREEN}✓ Tests pass${NC}"
101
+ else
102
+ echo -e "${RED}ERROR: Tests failed${NC}"
103
+ ((errors++))
104
+ fi
105
+
106
+ # Run build
107
+ echo "Running build..."
108
+ if npm run build 2>/dev/null; then
109
+ echo -e "${GREEN}✓ Build succeeds${NC}"
110
+ else
111
+ echo -e "${RED}ERROR: Build failed${NC}"
112
+ ((errors++))
113
+ fi
114
+
115
+ # Run lint
116
+ echo "Running lint..."
117
+ if npm run lint 2>/dev/null; then
118
+ echo -e "${GREEN}✓ Lint passes${NC}"
119
+ else
120
+ echo -e "${YELLOW}WARNING: Lint issues found${NC}"
121
+ fi
122
+
123
+ return $errors
124
+ }
125
+
126
+ verify_qa() {
127
+ local req_dir="$1"
128
+ local errors=0
129
+
130
+ echo -e "${YELLOW}Verifying QA completion...${NC}"
131
+
132
+ # Check TEST_REPORT.md exists
133
+ if [[ ! -f "${req_dir}/TEST_REPORT.md" ]]; then
134
+ echo -e "${RED}ERROR: TEST_REPORT.md not found${NC}"
135
+ ((errors++))
136
+ else
137
+ echo -e "${GREEN}✓ TEST_REPORT.md exists${NC}"
138
+ fi
139
+
140
+ # Check SECURITY_REPORT.md exists
141
+ if [[ ! -f "${req_dir}/SECURITY_REPORT.md" ]]; then
142
+ echo -e "${RED}ERROR: SECURITY_REPORT.md not found${NC}"
143
+ ((errors++))
144
+ else
145
+ echo -e "${GREEN}✓ SECURITY_REPORT.md exists${NC}"
146
+ fi
147
+
148
+ return $errors
149
+ }
150
+
151
+ verify_release() {
152
+ local req_dir="$1"
153
+ local errors=0
154
+
155
+ echo -e "${YELLOW}Verifying release readiness...${NC}"
156
+
157
+ # Check RELEASE_PLAN.md exists
158
+ if [[ ! -f "${req_dir}/RELEASE_PLAN.md" ]]; then
159
+ echo -e "${RED}ERROR: RELEASE_PLAN.md not found${NC}"
160
+ ((errors++))
161
+ else
162
+ echo -e "${GREEN}✓ RELEASE_PLAN.md exists${NC}"
163
+ fi
164
+
165
+ # Check git status
166
+ if [[ -n "$(git status --porcelain)" ]]; then
167
+ echo -e "${RED}ERROR: Uncommitted changes exist${NC}"
168
+ ((errors++))
169
+ else
170
+ echo -e "${GREEN}✓ Git working directory clean${NC}"
171
+ fi
172
+
173
+ # Check PR status if on feature branch
174
+ local branch=$(git branch --show-current)
175
+ if [[ "$branch" == feature/* ]] || [[ "$branch" == bugfix/* ]]; then
176
+ echo "Checking PR status..."
177
+ if gh pr checks 2>/dev/null; then
178
+ echo -e "${GREEN}✓ PR checks pass${NC}"
179
+ else
180
+ echo -e "${YELLOW}WARNING: PR checks not available or failing${NC}"
181
+ fi
182
+ fi
183
+
184
+ return $errors
185
+ }
186
+
187
+ # Main
188
+ TYPE=""
189
+ REQ_DIR=""
190
+ VERBOSE=false
191
+ JSON=false
192
+
193
+ while [[ $# -gt 0 ]]; do
194
+ case $1 in
195
+ --type)
196
+ TYPE="$2"
197
+ shift 2
198
+ ;;
199
+ --req-dir)
200
+ REQ_DIR="$2"
201
+ shift 2
202
+ ;;
203
+ --verbose)
204
+ VERBOSE=true
205
+ shift
206
+ ;;
207
+ --json)
208
+ JSON=true
209
+ shift
210
+ ;;
211
+ --help|-h)
212
+ usage
213
+ exit 0
214
+ ;;
215
+ *)
216
+ echo "Unknown option: $1"
217
+ usage
218
+ exit 1
219
+ ;;
220
+ esac
221
+ done
222
+
223
+ if [[ -z "$TYPE" ]]; then
224
+ echo "Error: --type is required"
225
+ usage
226
+ exit 1
227
+ fi
228
+
229
+ # Default req_dir to current directory
230
+ REQ_DIR="${REQ_DIR:-.}"
231
+
232
+ case "$TYPE" in
233
+ prd)
234
+ verify_prd "$REQ_DIR"
235
+ ;;
236
+ epic)
237
+ verify_epic "$REQ_DIR"
238
+ ;;
239
+ dev)
240
+ verify_dev "$REQ_DIR"
241
+ ;;
242
+ qa)
243
+ verify_qa "$REQ_DIR"
244
+ ;;
245
+ release)
246
+ verify_release "$REQ_DIR"
247
+ ;;
248
+ *)
249
+ echo "Unknown type: $TYPE"
250
+ usage
251
+ exit 1
252
+ ;;
253
+ esac
254
+
255
+ exit_code=$?
256
+
257
+ if [[ $exit_code -eq 0 ]]; then
258
+ echo ""
259
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
260
+ echo -e "${GREEN}VERIFICATION PASSED${NC}"
261
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
262
+ else
263
+ echo ""
264
+ echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
265
+ echo -e "${RED}VERIFICATION FAILED - ${exit_code} error(s)${NC}"
266
+ echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
267
+ fi
268
+
269
+ exit $exit_code
@@ -16,38 +16,51 @@ Guide users to the correct agent/command WITHOUT duplicating their detailed stan
16
16
  /core-roadmap → ROADMAP.md + BACKLOG.md (产品路线图)
17
17
  /core-architecture → ARCHITECTURE.md (系统架构设计)
18
18
  /core-guidelines → frontend-guidelines.md / backend-guidelines.md (项目规范)
19
- /core-style → STYLE.md (设计风格指南) ⭐ 新增
19
+ /core-style → STYLE.md (设计风格指南)
20
20
  ```
21
21
 
22
22
  ### 📦 需求级工作流(Requirement-Level, 每个需求执行一次)
23
23
 
24
24
  ```
25
- /flow-init → research.md + tasks.json (研究初始化)
25
+ /flow-init → research.md + tasks.json + BRAINSTORM.md (研究初始化 + 头脑风暴)
26
26
 
27
- /flow-clarify → clarifications/*.md (11 维度歧义扫描, 可选) ⭐ 新增
27
+ /flow-clarify → clarifications/*.md (11 维度歧义扫描, 可选)
28
28
 
29
- /flow-prd → PRD.md (invoke prd-writer agent)
29
+ /flow-prd → PRD.md (invoke prd-writer agent, 需 BRAINSTORM.md 对齐)
30
30
 
31
- /flow-checklist → checklists/*.md (需求质量检查, 可选) ⭐ 新增
31
+ /flow-checklist → checklists/*.md (需求质量检查, 可选)
32
32
 
33
33
  /flow-tech → TECH_DESIGN.md + data-model + contracts (invoke tech-architect agent)
34
34
 
35
- /flow-ui → UI_PROTOTYPE.html (invoke ui-designer agent, 可选, 引用 STYLE.md) ⭐ 变更
35
+ /flow-ui → UI_PROTOTYPE.html (invoke ui-designer agent, 可选, 引用 STYLE.md)
36
36
 
37
- /flow-epic → EPIC.md + TASKS.md (invoke planner agent with PRD+TECH+UI)
37
+ /flow-epic → EPIC.md + TASKS.md (invoke planner, bite-sized tasks)
38
38
 
39
- /flow-dev → TASKS.md execution (TDD order enforced, 引用 STYLE.md) ⭐ 变更
39
+ /flow-dev → TASKS.md execution (TDD + Autonomous mode default)
40
+
41
+ /flow-review → SPEC_REVIEW.md + CODE_QUALITY_REVIEW.md (Two-Stage Review)
40
42
 
41
43
  /flow-qa → QA reports (invoke qa-tester + security-reviewer agents)
42
44
 
43
- /flow-release → PR creation + deployment
45
+ /flow-release → PR creation + deployment (分支完成决策)
44
46
 
45
47
  /flow-verify → consistency check (invoke consistency-checker agent, 任意阶段可调用)
46
48
  ```
47
49
 
50
+ ### 🐛 Bug 修复工作流
51
+
52
+ ```
53
+ /flow-fix "BUG-123|描述" → 系统化调试 (4阶段: Root Cause → Pattern → Hypothesis → TDD Fix)
54
+ ```
55
+
48
56
  **说明**:
49
57
  - 项目级命令建立全局标准(SSOT),需求级命令引用这些标准
58
+ - `/flow-init` 包含 Brainstorming 阶段,生成 BRAINSTORM.md 作为需求「北极星」
59
+ - `/flow-prd` 需要 BRAINSTORM.md 对齐检查
50
60
  - `/flow-clarify` 在 PRD 前可选执行,消除 research.md 中的歧义
61
+ - `/flow-epic` 使用 bite-sized tasks 原则 (2-5分钟/任务)
62
+ - `/flow-dev` 默认 Autonomous 模式(自动重试),使用 `--manual` 退出到 Manual 模式
63
+ - `/flow-review` 是新增的两阶段审查 (Spec Compliance → Code Quality)
51
64
  - `/flow-ui` 和 `/flow-dev` 自动加载 `devflow/STYLE.md`(如存在)
52
65
  - 项目级命令可按需执行,无严格顺序要求
53
66
 
@@ -104,26 +117,43 @@ Guide users to the correct agent/command WITHOUT duplicating their detailed stan
104
117
  - **DON'T**: Duplicate QA standards (qa-tester agent has ~300 lines)
105
118
  - **Link**: See [.claude/agents/qa-tester.md](.claude/agents/qa-tester.md) for QA details
106
119
 
120
+ ### When User Asks About Code Review (v2.1.0 新增)
121
+ - **DO**: Recommend `/flow-review` command → invokes spec-reviewer + code-quality-reviewer agents
122
+ - **DON'T**: Duplicate review standards (Two-Stage Review)
123
+ - **Link**: See [.claude/commands/flow-review.md](.claude/commands/flow-review.md) for details
124
+ - **Features**: Stage 1 (Spec Compliance) → Stage 2 (Code Quality), 不信任实现者报告
125
+
126
+ ### When User Asks About Bug Fix (v2.1.0 新增)
127
+ - **DO**: Recommend `/flow-fix` command → 4-phase systematic debugging
128
+ - **DON'T**: Guess and fix without investigation
129
+ - **Link**: See [.claude/commands/flow-fix.md](.claude/commands/flow-fix.md) for details
130
+ - **Features**: Root Cause → Pattern → Hypothesis → TDD Fix, Iron Law enforcement
131
+
107
132
  ## Phase Gates (Quick Reference Only)
108
133
 
109
134
  ### Entry Gates
135
+ - **flow-init Entry**: Git 工作区干净, main 分支
110
136
  - **flow-clarify Entry**: research.md 存在, phase0_complete == true
111
- - **flow-prd Entry**: research.md 无 TODO placeholder, phase0_complete == true (clarify 可选)
137
+ - **flow-prd Entry**: BRAINSTORM.md 存在, research.md 无 TODO placeholder
112
138
  - **flow-checklist Entry**: PRD.md 必须完成 (prd_complete == true)
113
139
  - **flow-tech Entry**: PRD.md 必须完成
114
140
  - **flow-ui Entry**: PRD.md 必须完成(可与 tech 并行)
115
141
  - **flow-epic Entry**: PRD 完成,tech/ui 推荐但可选,Checklist Gate (如存在 checklists/)
116
142
  - **flow-dev Entry**: EPIC.md + TASKS.md 存在
117
- - **flow-qa Entry**: development_complete == true
143
+ - **flow-review Entry**: development_complete == true
144
+ - **flow-qa Entry**: review_complete == true (或 development_complete)
145
+ - **flow-release Entry**: qa_complete == true
118
146
 
119
147
  ### Exit Gates
120
- - **flow-init Exit**: research.md 5-level quality check
148
+ - **flow-init Exit**: research.md 5-level quality check, BRAINSTORM.md 完整
121
149
  - **flow-clarify Exit**: clarification report 完整, orchestration_status.clarify_complete == true
122
- - **flow-prd Exit**: PRD.md 无 placeholder, Constitution 合规
150
+ - **flow-prd Exit**: PRD.md 无 placeholder, Constitution 合规, BRAINSTORM 对齐
123
151
  - **flow-tech Exit**: TECH_DESIGN.md + data-model + contracts 完整
124
- - **flow-epic Exit**: TASKS.md TDD 顺序正确, Phase -1 Gates 通过
125
- - **flow-dev Exit**: 所有 TASKS 完成, 测试通过
152
+ - **flow-epic Exit**: TASKS.md TDD 顺序正确, bite-sized tasks, Phase -1 Gates 通过
153
+ - **flow-dev Exit**: 所有 TASKS 完成, TDD Checkpoint 通过, 测试通过
154
+ - **flow-review Exit**: SPEC_REVIEW.md + CODE_QUALITY_REVIEW.md 均 PASS
126
155
  - **flow-qa Exit**: 无 high-severity 漏洞
156
+ - **flow-release Exit**: PR 创建成功, 分支决策完成
127
157
 
128
158
  **For Details**: See [orchestration_status.json](devflow/requirements/REQ-XXX/orchestration_status.json) and [EXECUTION_LOG.md](devflow/requirements/REQ-XXX/EXECUTION_LOG.md)
129
159
 
@@ -135,6 +165,7 @@ Read `orchestration_status.json` to determine current phase:
135
165
  status: "initialized"
136
166
  → Recommend: /flow-clarify (optional, clarify ambiguities)
137
167
  → Alternative: /flow-prd (skip clarification, generate PRD directly)
168
+ → Note: BRAINSTORM.md 已在 /flow-init 生成
138
169
 
139
170
  status: "clarify_complete" OR "clarify_skipped"
140
171
  → Recommend: /flow-prd (generate PRD)
@@ -148,9 +179,14 @@ status: "tech_design_complete"
148
179
  → Else: /flow-epic (generate EPIC and TASKS)
149
180
 
150
181
  status: "epic_complete"
151
- → Recommend: /flow-dev (start TDD development)
182
+ → Recommend: /flow-dev (TDD development, Autonomous mode default)
183
+ → Alternative: /flow-dev --manual (Manual mode for complex requirements)
152
184
 
153
185
  status: "development_complete"
186
+ → Recommend: /flow-review (Two-Stage Code Review)
187
+ → Alternative: /flow-qa (skip review, go directly to QA)
188
+
189
+ status: "review_complete"
154
190
  → Recommend: /flow-qa (quality assurance and security review)
155
191
 
156
192
  status: "qa_complete"
@@ -181,11 +217,13 @@ status: "released"
181
217
  ### Constitution violation?
182
218
  - **Real-time check**: constitution-guardian guardrail (PreToolUse hook)
183
219
  - **Batch validation**: Run `.claude/scripts/validate-constitution.sh`
184
- - **Reference**: See `.claude/rules/project-constitution.md` v2.0.0
220
+ - **Reference**: See `.claude/rules/project-constitution.md`
221
+ - **Rationalization Library**: See `.claude/rules/rationalization-library.md`
185
222
 
186
223
  ### TDD order violated?
187
224
  - **Real-time check**: devflow-tdd-enforcer guardrail (PreToolUse hook)
188
225
  - **Manual check**: See TASKS.md, tests MUST be marked [x] before implementation
226
+ - **TDD Skill**: See `.claude/skills/flow-tdd/SKILL.md`
189
227
 
190
228
  ## Auxiliary Commands
191
229
 
@@ -200,16 +238,28 @@ status: "released"
200
238
  - `/flow-verify "REQ-123"` - Comprehensive consistency verification
201
239
 
202
240
  ### Bug Fix
203
- - `/flow-fix "BUG-123|登录超时"` - One-shot BUG fix workflow
241
+ - `/flow-fix "BUG-123|登录超时"` - 系统化 BUG 修复 (4阶段调试法)
204
242
  - `/problem-analyzer "<issue>"` - Problem diagnosis
205
243
 
206
244
  ### Code Review
245
+ - `/flow-review "REQ-123"` - Two-Stage Code Review (Spec → Quality)
207
246
  - `/code-review-high "<diff>"` - High-rigor code review
208
247
 
209
248
  ## Integration with Other Skills
210
249
 
211
- - **devflow-tdd-enforcer**: Enforces TDD order in TASKS.md (Guardrail, blocks)
212
- - **constitution-guardian**: Enforces Constitution compliance (Guardrail, blocks)
250
+ ### Guardrails (实时阻断)
251
+ - **devflow-tdd-enforcer**: Enforces TDD order in TASKS.md
252
+ - **constitution-guardian**: Enforces Constitution compliance
253
+
254
+ ### Workflow Skills
255
+ - **flow-brainstorming**: 需求头脑风暴,生成 BRAINSTORM.md
256
+ - **flow-tdd**: TDD Iron Law 执行
257
+ - **flow-debugging**: 4阶段系统化调试
258
+ - **flow-receiving-review**: 处理代码审查反馈
259
+ - **flow-finishing-branch**: 分支完成决策
260
+ - **verification-before-completion**: 验证闸门
261
+
262
+ ### Reference Skills
213
263
  - **devflow-file-standards**: File naming and directory structure reference
214
264
  - **devflow-constitution-quick-ref**: Constitution quick reference
215
265
 
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: file-header-guardian
3
+ description: 文件头三行契约注释。触发:create file、新建文件、编写代码。
4
+ ---
5
+
6
+ # 文件头注释守护者
7
+
8
+ 触发:创建代码文件,修改文件后检查头注释准确性。
9
+
10
+ ## 模板
11
+
12
+ **TS/JS:**
13
+ ```typescript
14
+ /**
15
+ * @input 依赖什么
16
+ * @output 提供什么
17
+ * @pos 系统地位
18
+ * ⚠️ 修改后同步:文件头 + 目录 CLAUDE.md
19
+ */
20
+ ```
21
+
22
+ **Python:**
23
+ ```python
24
+ """
25
+ @input 依赖什么
26
+ @output 提供什么
27
+ @pos 系统地位
28
+ ⚠️ 修改后同步:文件头 + 目录 CLAUDE.md
29
+ """
30
+ ```
31
+
32
+ **Shell:**
33
+ ```bash
34
+ # @input 依赖什么
35
+ # @output 提供什么
36
+ # @pos 系统地位
37
+ # ⚠️ 修改后同步:文件头 + 目录 CLAUDE.md
38
+ ```
39
+
40
+ ## 示例
41
+
42
+ ```typescript
43
+ /**
44
+ * @input prisma.service 数据库连接
45
+ * @output UserService: create/update/delete
46
+ * @pos 用户模块核心
47
+ * ⚠️ 修改后同步:文件头 + 目录 CLAUDE.md
48
+ */
49
+ export class UserService { }
50
+ ```
51
+
52
+ ## 豁免
53
+
54
+ 配置文件(json/yaml)、样式(css)、生成文件(*.d.ts)、node_modules。
55
+
56
+ 协作:本 skill 管文件,fractal-docs-generator 管目录。
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: flow-attention-refresh
3
+ description: "注意力刷新协议。在关键时刻强制读取核心文档,防止目标遗忘。被 flow-dev, flow-ralph 等命令引用。"
4
+ ---
5
+
6
+ # Flow Attention Refresh - 注意力刷新协议
7
+
8
+ ## Overview
9
+
10
+ 解决 "Lost in the Middle" 效应:当上下文过长时,原始目标被"推出"注意力窗口。
11
+
12
+ ```
13
+ 问题:
14
+ 上下文开始: [原始目标 - 距离很远,被"遗忘"]
15
+
16
+ ... 50+ 工具调用 ...
17
+
18
+ 上下文末尾: [最近的工具输出 - 在注意力窗口]
19
+
20
+ 解决:
21
+ 在关键时刻强制读取目标文档 → 将目标"拉回"注意力窗口
22
+ ```
23
+
24
+ ## The Iron Law
25
+
26
+ ```
27
+ BEFORE MAJOR DECISION → READ GOAL FILES → THEN ACT
28
+ ```
29
+
30
+ ## Refresh Protocols
31
+
32
+ ### Protocol 1: Flow Entry (每个 flow-* 命令开始)
33
+
34
+ **触发点**: 任何 `/flow-*` 命令的 Entry Gate
35
+
36
+ **动作**:
37
+ ```yaml
38
+ read:
39
+ - BRAINSTORM.md "成功标准" 章节
40
+ - TASKS.md 当前阶段任务列表
41
+ focus: 本次命令要达成什么?
42
+ ```
43
+
44
+ **实现**: 已由现有 Brainstorm Alignment Check 覆盖
45
+
46
+ ---
47
+
48
+ ### Protocol 2: Task Start (flow-dev 每个任务开始)
49
+
50
+ **触发点**: `flow-dev` TDD 循环中,每个任务执行前
51
+
52
+ **动作**:
53
+ ```yaml
54
+ read:
55
+ - TASKS.md 当前任务 T### 段落 + DoD
56
+ - quickstart.md 相关命令
57
+ focus: 这个任务的验收标准是什么?
58
+ ```
59
+
60
+ **实现位置**: flow-dev.md 阶段 3 TDD 循环
61
+
62
+ **代码片段**:
63
+ ```markdown
64
+ **注意力刷新** (Protocol 2):
65
+ → Read: TASKS.md 当前任务 T### 段落
66
+ → Focus: 任务目标和 DoD
67
+ → Then: 开始执行任务
68
+ ```
69
+
70
+ ---
71
+
72
+ ### Protocol 3: Ralph Iteration (Ralph 循环每次迭代)
73
+
74
+ **触发点**: `/flow-ralph` 每次迭代开始
75
+
76
+ **动作**:
77
+ ```yaml
78
+ read:
79
+ - TASKS.md 第一个未完成任务
80
+ - ERROR_LOG.md 最近 5 条记录
81
+ focus: 下一步行动 + 避免重复错误
82
+ ```
83
+
84
+ **实现位置**: flow-ralph.md Ralph Loop 开始处
85
+
86
+ **代码片段**:
87
+ ```markdown
88
+ **注意力刷新** (Protocol 3):
89
+ → Read: TASKS.md 找到第一个 `- [ ]` 任务
90
+ → Read: ERROR_LOG.md 最近 5 条(如存在)
91
+ → Focus: 下一步行动是什么?有什么错误需要避免?
92
+ → Then: 执行任务
93
+ ```
94
+
95
+ ---
96
+
97
+ ### Protocol 4: Error Recovery (遇到错误后)
98
+
99
+ **触发点**: 测试失败、构建错误、运行时异常后
100
+
101
+ **动作**:
102
+ ```yaml
103
+ read:
104
+ - ERROR_LOG.md 当前错误记录
105
+ - TASKS.md 当前任务定义
106
+ focus: 错误根因 + 解决方案
107
+ ```
108
+
109
+ **实现位置**: flow-tdd skill 错误处理部分
110
+
111
+ **代码片段**:
112
+ ```markdown
113
+ **错误恢复刷新** (Protocol 4):
114
+ → Record: 将错误追加到 ERROR_LOG.md
115
+ → Read: ERROR_LOG.md 当前错误 + 历史相似错误
116
+ → Read: TASKS.md 当前任务
117
+ → Focus: 根因分析,避免盲目修复
118
+ → Then: 有针对性地修复
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Integration Map
124
+
125
+ ```
126
+ 现有机制:
127
+ ┌──────────────────────────────────────┐
128
+ │ flow-brainstorming skill │
129
+ │ ↓ 触发于 /flow-init │
130
+ │ ↓ 输出 BRAINSTORM.md │
131
+ └──────────────────────────────────────┘
132
+
133
+ ┌──────────────────────────────────────┐
134
+ │ Brainstorm Alignment Check │
135
+ │ ↓ 在每个 flow-* Entry Gate │
136
+ │ ↓ 读取 BRAINSTORM.md 验证对齐 │
137
+ │ ↓ = Protocol 1 │
138
+ └──────────────────────────────────────┘
139
+
140
+ 新增机制:
141
+ ┌──────────────────────────────────────┐
142
+ │ flow-attention-refresh skill (本文件) │
143
+ │ ↓ 被 flow-dev, flow-ralph 引用 │
144
+ │ ↓ 在更细粒度的时刻刷新注意力 │
145
+ │ ↓ Protocol 2, 3, 4 │
146
+ └──────────────────────────────────────┘
147
+ ```
148
+
149
+ ## Rationalization Prevention
150
+
151
+ | Excuse | Reality |
152
+ |--------|---------|
153
+ | "我记得目标是什么" | 上下文 50+ 工具调用后,你真的不记得了 |
154
+ | "读文件浪费时间" | 读文件 < 1秒,返工 > 10分钟 |
155
+ | "这个任务很简单" | 简单任务也会偏离目标 |
156
+ | "刚刚读过了" | 每次迭代都要读,这是协议 |
157
+
158
+ ## Red Flags - STOP
159
+
160
+ 如果你发现自己:
161
+ - 开始任务前没有读取 TASKS.md
162
+ - 遇到错误后没有先记录 ERROR_LOG.md
163
+ - Ralph 循环中忘记读取上次错误
164
+ - 做决策时没有参考 BRAINSTORM.md
165
+
166
+ **STOP。执行对应的 Protocol。**
167
+
168
+ ---
169
+
170
+ **[PROTOCOL]**: 变更时更新此头部,然后检查 CLAUDE.md