gather-plan-apply
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResources
资源
scripts/
validate-gpa-compliance.sh
references/
examples-and-checklists.mdscripts/
validate-gpa-compliance.sh
references/
examples-and-checklists.mdGather-Plan-Apply Protocol (GPA Workflow)
收集-规划-应用协议(GPA工作流)
The GPA loop enforces a one-call-per-tool-type-per-phase workflow that eliminates token waste from excessive tool calls. This is NOT a suggestion — it is a MANDATORY execution pattern for all GoodVibes agents.
GPA循环强制实施每个阶段每种工具仅调用一次的工作流,以消除因过多工具调用导致的Token浪费。这并非建议——而是所有GoodVibes Agent必须遵循的执行模式。
THE EXACT WORKFLOW
详细工作流
0. LOAD SKILLS (once, before any GPA cycle)
- Call get_skill_content for role-relevant skills
- This is NOT part of the GPA cycle itself
1. G — GATHER (1-2 tool calls)
- Check .goodvibes/memory/ files FIRST (failures, patterns, decisions)
- Single `discover` call with ALL queries batched inside
- Multiple query types (glob, grep, symbols, structural) in one call
- Can search file content via grep/symbols queries
- Batch any file reads that need full content alongside discover
- Output: files_only or locations (minimal verbosity)
2. P — PLAN (0 tool calls, cognitive only)
- Agent thinks about what it learned from GATHER
- Plans which files to create/write/edit
- Plans which commands to run for validation
- Identifies ALL batch opportunities — same-type ops go in one call
- Plans the EXACT apply call structure
3. A — APPLY (1-2 tool calls)
- Writes and edits batched into one precision_write or precision_edit call
- Validation commands batched into one precision_exec call
- Key: one call per tool type, everything batched inside it
4. LOOP — Back to G if:
- Results didn't match expectations
- Scope changed
- Validation failed0. 加载技能(仅在GPA循环开始前执行一次)
- 调用get_skill_content获取与角色相关的技能
- 此步骤不属于GPA循环本身
1. G — 收集(1-2次工具调用)
- 优先检查.goodvibes/memory/文件(包含失败记录、模式、决策)
- 单次`discover`调用,将所有查询批量处理
- 支持在一个调用中包含多种查询类型(glob、grep、symbols、structural)
- 可通过grep/symbols查询搜索文件内容
- 将所有需要读取完整内容的文件读取操作与discover批量处理
- 输出:仅文件路径或位置信息(最小化冗余)
2. P — 规划(0次工具调用,仅需思考)
- Agent梳理收集阶段获取的信息
- 规划需要创建/写入/编辑的文件
- 规划用于验证的命令
- 识别所有可批量处理的操作——同类型操作需合并为一次调用
- 规划应用阶段的具体调用结构
3. A — 应用(1-2次工具调用)
- 将所有写入和编辑操作批量处理为一次precision_write或precision_edit调用
- 将所有验证命令批量处理为一次precision_exec调用
- 核心:每种工具仅调用一次,所有操作都在该调用内批量处理
4. 循环 — 出现以下情况时返回收集阶段:
- 结果不符合预期
- 范围发生变化
- 验证失败CALL BUDGET PER CYCLE
每个循环的调用预算
| Phase | Tool Calls | Type | Purpose |
|---|---|---|---|
| G (Gather) | 1-2 | | All discovery + memory reads |
| P (Plan) | 0 | Cognitive | Plan apply operations |
| A (Apply) | 1-2 | | All writes/edits + validation |
| TOTAL | 2-4 |
Core rule: One call per tool type per phase. Never make two calls in the same phase — batch both files into the one call.
precision_readNote on sequential calls: Sequential calls are acceptable when operations depend on each other (e.g., write then verify). Always prefer true batching via internal precision tool arrays (files array, edits array, commands array).
| 阶段 | 工具调用次数 | 类型 | 用途 |
|---|---|---|---|
| G(收集) | 1-2 | | 所有发现操作 + 内存读取 |
| P(规划) | 0 | 仅思考 | 规划应用阶段的操作 |
| A(应用) | 1-2 | | 所有写入/编辑操作 + 验证 |
| 总计 | 2-4 |
核心规则:每个阶段每种工具仅调用一次。绝不能在同一阶段进行两次调用——需将多个文件合并为一次调用。
precision_read关于顺序调用的说明:当操作存在依赖关系时(例如先写入再验证),顺序调用是允许的。但始终优先通过内部精准工具的数组参数实现真正的批量处理(如files数组、edits数组、commands数组)。
KEY RULES (NON-NEGOTIABLE)
关键规则(不可违反)
- batches ALL discovery queries into 1 call — NEVER use separate
discover,precision_globfor discoveryprecision_grep - Plan steps produce ZERO tool calls — they are cognitive (agent thinks in text)
- One call per tool type per phase — if you need 3 files read, batch them in 1 call
precision_read - APPLY output = 1-2 calls — precision_write/edit for files, precision_exec for commands
- ToolSearch is NOT part of GPA — load tools once at start, don't search mid-cycle
- Check memory FIRST — always read .goodvibes/memory/ before implementing
- 所有发现查询必须批量处理为一次调用——绝不能单独使用
discover和precision_glob进行发现操作precision_grep - 规划阶段不产生任何工具调用——仅需通过文本完成思考
- 每个阶段每种工具仅调用一次——若需要读取3个文件,需合并为一次调用
precision_read - 应用阶段仅需1-2次调用——使用precision_write/edit处理文件,使用precision_exec处理命令
- ToolSearch不属于GPA循环——仅在开始时加载工具,循环过程中不进行搜索
- 必须优先检查内存——在执行操作前务必读取.goodvibes/memory/目录
Phase 1: GATHER (1-2 calls)
阶段1:收集(1-2次调用)
Initial Setup: Check Memory
初始设置:检查内存
Before discovering files, check what's already known. Batch memory reads with your discover call or as a separate read:
yaml
undefined在发现文件前,先查看已有的信息。可将内存读取操作与discover调用批量处理,或作为单独的读取调用:
yaml
undefinedGOOD: Memory reads batched with file content reads
正确示例:内存读取与文件内容读取批量处理
precision_read:
files:
- path: ".goodvibes/memory/failures.json"
- path: ".goodvibes/memory/patterns.json"
- path: ".goodvibes/memory/decisions.json"
verbosity: minimal
undefinedprecision_read:
files:
- path: ".goodvibes/memory/failures.json"
- path: ".goodvibes/memory/patterns.json"
- path: ".goodvibes/memory/decisions.json"
verbosity: minimal
undefinedThe discover
Tool
discoverdiscover
工具
discoverThe tool runs multiple grep/glob/symbols/structural queries in parallel, returning results keyed by query ID. This is your primary discovery mechanism.
discoverPattern: Batch ALL discovery queries
yaml
undefineddiscover模式:所有发现查询批量处理
yaml
undefinedGOOD: 1 discover call with everything
正确示例:一次discover调用包含所有查询
discover:
queries:
- id: existing_files
type: glob
patterns: ["src/features/auth//*.ts"]
- id: existing_patterns
type: grep
pattern: "export (function|const|class)"
glob: "src/features//*.ts"
- id: exported_hooks
type: symbols
query: "use"
kinds: ["function"]
- id: console_logs
type: structural
structural_pattern: "console.log($$$ARGS)"
verbosity: files_only
**Query types:**
- **glob** - Find files by path patterns
- **grep** - Find files containing patterns
- **symbols** - Find exported functions/types/classes
- **structural** - Find AST patterns (e.g., function calls)
**Output modes:**
- `count_only` - Just counts (scope estimation)
- `files_only` - File paths only (building target lists) ← **USE THIS**
- `locations` - File paths + line numbers (when you need exact locations)discover:
queries:
- id: existing_files
type: glob
patterns: ["src/features/auth//*.ts"]
- id: existing_patterns
type: grep
pattern: "export (function|const|class)"
glob: "src/features//*.ts"
- id: exported_hooks
type: symbols
query: "use"
kinds: ["function"]
- id: console_logs
type: structural
structural_pattern: "console.log($$$ARGS)"
verbosity: files_only
**查询类型**:
- **glob** - 通过路径模式查找文件
- **grep** - 查找包含指定模式的文件
- **symbols** - 查找导出的函数/类型/类
- **structural** - 查找AST模式(例如函数调用)
**输出模式**:
- `count_only` - 仅返回数量(范围评估)
- `files_only` - 仅返回文件路径(构建目标列表)← **推荐使用**
- `locations` - 返回文件路径+行号(需要精确位置时使用)Reading Full File Contents
读取完整文件内容
For reading full file contents, use in the GATHER phase, batched with memory reads or as a second call if discover results are needed first.
precision_read若需读取完整文件内容,在收集阶段使用,可与内存读取批量处理,或在获取discover结果后作为第二次调用。
precision_read[BAD] vs [GOOD] Gather Patterns
错误示例 vs 正确示例:收集阶段模式
[BAD] — Sequential discovery queries (multiple tool calls)
yaml
undefined错误示例——顺序执行发现查询(多次工具调用)
yaml
undefinedBAD: 4 separate tool calls for discovery
错误:4次独立的工具调用用于发现
precision_glob:
patterns: ["src/**/*.ts"]
precision_grep:
queries:
- id: exports
pattern: "export function"
precision_read:
files:
- path: ".goodvibes/memory/failures.json"
precision_grep:
queries:
- id: imports
pattern: "import.*from"
**[GOOD] — Single discover call + batched memory reads (2 tool calls)**
```yamlprecision_glob:
patterns: ["src/**/*.ts"]
precision_grep:
queries:
- id: exports
pattern: "export function"
precision_read:
files:
- path: ".goodvibes/memory/failures.json"
precision_grep:
queries:
- id: imports
pattern: "import.*from"
**正确示例——单次discover调用 + 批量内存读取(2次工具调用)**
```yamlGOOD: 1 discover call with all queries
正确:一次discover调用包含所有查询
discover:
queries:
- id: files
type: glob
patterns: ["src//*.ts"]
- id: exports
type: grep
pattern: "export function"
glob: "src//*.ts"
- id: imports
type: grep
pattern: "import.from"
glob: "src/**/.ts"
verbosity: files_only
discover:
queries:
- id: files
type: glob
patterns: ["src//*.ts"]
- id: exports
type: grep
pattern: "export function"
glob: "src//*.ts"
- id: imports
type: grep
pattern: "import.from"
glob: "src/**/.ts"
verbosity: files_only
GOOD: Memory reads in one batched call
正确:一次批量调用读取所有内存文件
precision_read:
files:
- path: ".goodvibes/memory/failures.json"
- path: ".goodvibes/memory/patterns.json"
- path: ".goodvibes/memory/decisions.json"
verbosity: minimal
undefinedprecision_read:
files:
- path: ".goodvibes/memory/failures.json"
- path: ".goodvibes/memory/patterns.json"
- path: ".goodvibes/memory/decisions.json"
verbosity: minimal
undefinedPhase 2: PLAN (0 calls, cognitive only)
阶段2:规划(0次调用,仅需思考)
Purpose
目的
Planning is cognitive work, not tool calls. You think in text about:
- Which files to create/write
- Which files to edit (with exact find/replace)
- Which commands to run for validation
- ALL batch opportunities — same-type ops must be batched
Output: A written plan with NO tool calls
规划是思考工作,而非工具调用。你需要通过文本思考以下内容:
- 需要创建/写入哪些文件
- 需要编辑哪些文件(包含精确的查找/替换内容)
- 需要运行哪些命令进行验证
- 所有可批量处理的机会——同类型操作必须批量处理
输出:一份不包含工具调用的书面规划
Plan Structure
规划结构
Plan:
1. Create the following files:
- src/features/auth/types.ts — User interface
- src/features/auth/hooks.ts — useAuth hook
- src/features/auth/index.ts — barrel export
2. Edit the following files:
- src/app/layout.tsx — wrap App with AuthProvider
3. Validate:
- npm run typecheck (expect exit 0)
- npm run lint (expect exit 0)
4. Batch plan:
- Call 1 (Apply): precision_write with 3 files + precision_edit with 1 edit
- Call 2 (Apply): precision_exec with 2 commands规划:
1. 创建以下文件:
- src/features/auth/types.ts — 用户接口
- src/features/auth/hooks.ts — useAuth钩子
- src/features/auth/index.ts — 桶导出文件
2. 编辑以下文件:
- src/app/layout.tsx — 用AuthProvider包裹App
3. 验证:
- npm run typecheck(期望退出码0)
- npm run lint(期望退出码0)
4. 批量处理规划:
- 应用调用1:precision_write创建3个文件 + precision_edit执行1次编辑
- 应用调用2:precision_exec执行2条命令[BAD] vs [GOOD] Planning
错误示例 vs 正确示例:规划阶段
[BAD] — Vague plan that leads to sequential calls
Plan:
- Create some files
- Maybe edit layout
- Run typecheckThis leads to:
yaml
precision_write: ... # 1st call
precision_write: ... # 2nd call! (should be batched)
precision_edit: ... # 3rd call! (could combine with above pattern)[GOOD] — Specific plan with exact batch structure
Plan:
1. Write 3 files in 1 precision_write call:
- src/features/auth/types.ts (symbols)
- src/features/auth/hooks.ts (content)
- src/features/auth/index.ts (content)
2. Edit 1 file in 1 precision_edit call:
- src/app/layout.tsx — wrap with AuthProvider
3. Validate in 1 precision_exec call:
- npm run typecheck
- npm run lint错误示例——模糊规划导致顺序调用
规划:
- 创建一些文件
- 可能编辑布局文件
- 运行类型检查这会导致:
yaml
precision_write: ... # 第1次调用
precision_write: ... # 第2次调用!(本应批量处理)
precision_edit: ... # 第3次调用!(可与上述操作合并)正确示例——包含精确批量结构的具体规划
规划:
1. 一次precision_write调用创建3个文件:
- src/features/auth/types.ts(符号定义)
- src/features/auth/hooks.ts(内容)
- src/features/auth/index.ts(内容)
2. 一次precision_edit调用编辑1个文件:
- src/app/layout.tsx — 用AuthProvider包裹
3. 一次precision_exec调用执行验证:
- npm run typecheck
- npm run lintPhase 3: APPLY (1-2 calls)
阶段3:应用(1-2次调用)
Pattern: Batch All Writes/Edits
模式:批量处理所有写入/编辑操作
Single precision_write with multiple files:
yaml
precision_write:
files:
- path: "src/features/auth/types.ts"
content: |
export interface User {
id: string;
email: string;
}
- path: "src/features/auth/hooks.ts"
content: |
import type { User } from './types';
export function useAuth(): User | null { /*...*/ }
- path: "src/features/auth/index.ts"
content: |
export * from './types';
export * from './hooks';
verbosity: count_onlyOR single precision_edit with multiple edits:
yaml
precision_edit:
edits:
- path: "src/app/layout.tsx"
find: "<App />"
replace: "<AuthProvider><App /></AuthProvider>"
- path: "src/middleware.ts"
find: "export const config = {}"
replace: "export const config = { matcher: ['/dashboard/:path*'] }"
- path: "src/lib/api.ts"
find: "headers: {}"
replace: "headers: { Authorization: `Bearer ${token}` }"
verbosity: minimalValidation via precision_exec (second Apply call):
yaml
precision_exec:
commands:
- cmd: "npm run typecheck"
expect:
exit_code: 0
- cmd: "npm run lint"
expect:
exit_code: 0
verbosity: minimal单次precision_write调用创建多个文件:
yaml
precision_write:
files:
- path: "src/features/auth/types.ts"
content: |
export interface User {
id: string;
email: string;
}
- path: "src/features/auth/hooks.ts"
content: |
import type { User } from './types';
export function useAuth(): User | null { /*...*/ }
- path: "src/features/auth/index.ts"
content: |
export * from './types';
export * from './hooks';
verbosity: count_only或单次precision_edit调用执行多个编辑:
yaml
precision_edit:
edits:
- path: "src/app/layout.tsx"
find: "<App />"
replace: "<AuthProvider><App /></AuthProvider>"
- path: "src/middleware.ts"
find: "export const config = {}"
replace: "export const config = { matcher: ['/dashboard/:path*'] }"
- path: "src/lib/api.ts"
find: "headers: {}"
replace: "headers: { Authorization: `Bearer ${token}` }"
verbosity: minimal通过precision_exec进行验证(应用阶段第二次调用):
yaml
precision_exec:
commands:
- cmd: "npm run typecheck"
expect:
exit_code: 0
- cmd: "npm run lint"
expect:
exit_code: 0
verbosity: minimal[BAD] vs [GOOD] Apply Batching
错误示例 vs 正确示例:应用阶段批量处理
[BAD] — 3 separate precision_write calls
yaml
precision_write:
files:
- path: "file1.ts"
content: "..."
precision_write: # Second call!
files:
- path: "file2.ts"
content: "..."
precision_write: # Third call!
files:
- path: "file3.ts"
content: "..."[GOOD] — 1 precision_write call with 3 files
yaml
precision_write:
files:
- path: "file1.ts"
content: "..."
- path: "file2.ts"
content: "..."
- path: "file3.ts"
content: "..."
verbosity: count_only错误示例——3次独立的precision_write调用
yaml
precision_write:
files:
- path: "file1.ts"
content: "..."
precision_write: # 第2次调用!
files:
- path: "file2.ts"
content: "..."
precision_write: # 第3次调用!
files:
- path: "file3.ts"
content: "..."正确示例——1次precision_write调用创建3个文件
yaml
precision_write:
files:
- path: "file1.ts"
content: "..."
- path: "file2.ts"
content: "..."
- path: "file3.ts"
content: "..."
verbosity: count_onlyPhase 4: LOOP (When to Return to Gather)
阶段4:循环(何时返回收集阶段)
Loop Triggers
循环触发条件
- Results don't match expectations — Typecheck fails, tests fail, unexpected behavior
- Scope changed — Discovery revealed different situation than expected
- New information — Task requirements clarified during execution
- 结果不符合预期——类型检查失败、测试失败、出现意外行为
- 范围发生变化——发现阶段揭示的情况与预期不同
- 获取新信息——执行过程中任务需求得到明确
Loop Pattern
循环模式
yaml
undefinedyaml
undefinedInitial GPA cycle
初始GPA循环
discover: ... # Gather call 1
precision_read: ... # Gather call 2 (memory + key files)
precision_write: ... # Apply call 1
precision_exec: ... # Apply call 2 — FAILS typecheck
discover: ... # 收集阶段第1次调用
precision_read: ... # 收集阶段第2次调用(内存+关键文件)
precision_write: ... # 应用阶段第1次调用
precision_exec: ... # 应用阶段第2次调用——类型检查失败
LOOP: Start new GPA cycle with refined discovery
循环:启动新的GPA循环并优化发现查询
discover: # Gather call 1 (new cycle)
queries:
- id: find_missing_import
type: grep
pattern: "export.User"
glob: "src/**/.ts"
verbosity: locations # Need exact location
precision_edit: ... # Apply call 1 (new cycle) - fix the issue
precision_exec: ... # Apply call 2 (new cycle) - re-validate
undefineddiscover: # 新循环收集阶段第1次调用
queries:
- id: find_missing_import
type: grep
pattern: "export.User"
glob: "src/**/.ts"
verbosity: locations # 需要精确位置
precision_edit: ... # 新循环应用阶段第1次调用 - 修复问题
precision_exec: ... # 新循环应用阶段第2次调用 - 重新验证
undefinedComplete Example: Implementing Auth Feature
完整示例:实现认证功能
Cycle 1: Initial Implementation
循环1:初始实现
Step 1 — GATHER (2 calls)
yaml
undefined步骤1 — 收集(2次调用)
yaml
undefinedCall 1: Check memory
调用1:检查内存
precision_read:
files:
- path: ".goodvibes/memory/failures.json"
- path: ".goodvibes/memory/decisions.json"
verbosity: minimal
precision_read:
files:
- path: ".goodvibes/memory/failures.json"
- path: ".goodvibes/memory/decisions.json"
verbosity: minimal
Call 2: Discover landscape
调用2:发现现有情况
discover:
queries:
- id: existing_auth
type: glob
patterns: ["src/features/auth//*.ts", "src//auth*.ts"]
- id: auth_patterns
type: grep
pattern: "(useAuth|getSession|AuthProvider)"
glob: "src/**/*.{ts,tsx}"
- id: user_types
type: symbols
query: "User"
kinds: ["interface", "type"]
verbosity: files_only
**Step 2 — PLAN (0 calls, cognitive)**
Gather results:
- No memory failures for auth
- No existing auth files
- No auth patterns in use
- User type exists in src/types/user.ts
Plan:
Apply Call 1 (precision_write): Create 3 auth files
Apply Call 2 (precision_exec): typecheck + lint
**Step 3 — APPLY (2 calls)**
```yamldiscover:
queries:
- id: existing_auth
type: glob
patterns: ["src/features/auth//*.ts", "src//auth*.ts"]
- id: auth_patterns
type: grep
pattern: "(useAuth|getSession|AuthProvider)"
glob: "src/**/*.{ts,tsx}"
- id: user_types
type: symbols
query: "User"
kinds: ["interface", "type"]
verbosity: files_only
**步骤2 — 规划(0次调用,仅思考)**
收集结果:
- 内存中无认证相关失败记录
- 无现有认证文件
- 未使用任何认证模式
- User类型已存在于src/types/user.ts
规划:
应用调用1(precision_write):创建3个认证文件
应用调用2(precision_exec):执行类型检查+代码检查
**步骤3 — 应用(2次调用)**
```yamlCall 1: Create files
调用1:创建文件
precision_write:
files:
- path: "src/features/auth/provider.tsx"
content: |
import { ClerkProvider } from '@clerk/nextjs';
export function AuthProvider({ children }: { children: React.ReactNode }) {
return <ClerkProvider>{children}</ClerkProvider>;
}
- path: "src/features/auth/hooks.ts"
content: |
import { useUser } from '@clerk/nextjs';
import type { User } from '@/types/user';
export function useAuth(): User | null {
const { user } = useUser();
if (!user) return null;
return { id: user.id, email: user.emailAddresses[0].emailAddress, name: user.fullName };
}
- path: "src/features/auth/index.ts"
content: |
export { AuthProvider } from './provider';
export { useAuth } from './hooks';
verbosity: count_only
precision_write:
files:
- path: "src/features/auth/provider.tsx"
content: |
import { ClerkProvider } from '@clerk/nextjs';
export function AuthProvider({ children }: { children: React.ReactNode }) {
return <ClerkProvider>{children}</ClerkProvider>;
}
- path: "src/features/auth/hooks.ts"
content: |
import { useUser } from '@clerk/nextjs';
import type { User } from '@/types/user';
export function useAuth(): User | null {
const { user } = useUser();
if (!user) return null;
return { id: user.id, email: user.emailAddresses[0].emailAddress, name: user.fullName };
}
- path: "src/features/auth/index.ts"
content: |
export { AuthProvider } from './provider';
export { useAuth } from './hooks';
verbosity: count_only
Call 2: Validate
调用2:验证
precision_exec:
commands:
- cmd: "npm run typecheck"
expect:
exit_code: 0
- cmd: "npm run lint"
expect:
exit_code: 0
verbosity: minimal
precision_exec:
commands:
- cmd: "npm run typecheck"
expect:
exit_code: 0
- cmd: "npm run lint"
expect:
exit_code: 0
verbosity: minimal
Result: typecheck FAILS — missing @clerk/nextjs
结果:类型检查失败——缺少@clerk/nextjs依赖
**Total calls in Cycle 1: 4** (precision_read + discover + precision_write + precision_exec)
**循环1总调用次数:4次**(precision_read + discover + precision_write + precision_exec)Cycle 2: Fix Missing Dependency
循环2:修复缺失依赖
Step 1 — GATHER (1 call)
yaml
discover:
queries:
- id: package_json
type: glob
patterns: ["package.json"]
- id: clerk_usage
type: grep
pattern: "@clerk/nextjs"
glob: "src/**/*.{ts,tsx}"
verbosity: files_onlyStep 2 — PLAN (0 calls, cognitive)
Discovery: @clerk/nextjs not in package.json
Plan:
Apply Call 1 (precision_exec): npm install @clerk/nextjs, then typecheckStep 3 — APPLY (1 call)
yaml
precision_exec:
commands:
- cmd: "npm install @clerk/nextjs"
- cmd: "npm run typecheck"
expect:
exit_code: 0
verbosity: minimal步骤1 — 收集(1次调用)
yaml
discover:
queries:
- id: package_json
type: glob
patterns: ["package.json"]
- id: clerk_usage
type: grep
pattern: "@clerk/nextjs"
glob: "src/**/*.{ts,tsx}"
verbosity: files_only步骤2 — 规划(0次调用,仅思考)
发现结果:@clerk/nextjs不在package.json中
规划:
应用调用1(precision_exec):安装@clerk/nextjs,然后执行类型检查步骤3 — 应用(1次调用)
yaml
precision_exec:
commands:
- cmd: "npm install @clerk/nextjs"
- cmd: "npm run typecheck"
expect:
exit_code: 0
verbosity: minimalResult: PASSES
结果:验证通过
**Total calls in Cycle 2: 2** (discover + precision_exec)
**循环2总调用次数:2次**(discover + precision_exec)Common Violations and Fixes
常见违规及修复方案
| Violation | Tool Calls | Fix |
|---|---|---|
| Sequential precision_read calls | 5+ | Batch all files into 1 precision_read call |
| Sequential precision_write calls | 5+ | Batch all files into 1 precision_write call |
| Using precision_glob + precision_grep separately | 2+ | Use 1 discover call with both query types |
| Reading outline, then content | 2 | Read content once if you'll need it |
| Planning via tool calls | 1+ | Plan in text (cognitive work = 0 calls) |
| Memory reads skipped | - | Always check .goodvibes/memory/ in Gather phase |
| 违规行为 | 工具调用次数 | 修复方案 |
|---|---|---|
| 顺序执行precision_read调用 | 5+ | 将所有文件合并为1次precision_read调用 |
| 顺序执行precision_write调用 | 5+ | 将所有文件合并为1次precision_write调用 |
| 分别使用precision_glob + precision_grep | 2+ | 使用1次discover调用包含两种查询类型 |
| 先读取大纲再读取内容 | 2 | 若需要内容则直接读取完整内容 |
| 通过工具调用进行规划 | 1+ | 用文本进行规划(思考工作=0次调用) |
| 跳过内存读取 | - | 收集阶段必须检查.goodvibes/memory/目录 |
Enforcement
执行规范
If you find yourself making the same tool type twice in a phase, you are violating the protocol. Stop and restructure:
- Identify which calls are discovery → batch into 1 call
discover - Identify which calls are memory/file reads → batch into 1 call
precision_read - Identify which calls are writes/edits → batch into same-type calls (writes together, edits together)
- Ensure planning happens in text, not via tools
Target: one call per tool type per phase.
若你在同一阶段对同类型工具进行多次调用,即违反了本协议。请立即停止并调整:
- 识别所有发现类调用→合并为1次调用
discover - 识别所有内存/文件读取调用→合并为1次调用
precision_read - 识别所有写入/编辑调用→合并为同类型的单次调用(写入操作合并,编辑操作合并)
- 确保规划通过文本完成,而非工具调用
目标:每个阶段每种工具仅调用一次。最大化单次调用内的批量处理。
Summary
总结
- G (Gather): check memory + + optional
discoverfor key filesprecision_read - P (Plan): 0 calls (cognitive)
- A (Apply): /
precision_write+precision_editfor validationprecision_exec - LOOP: Start new cycle if needed
Rule: One call per tool type per phase. Maximize batching within each call.
Make this your default mode of operation.
- G(收集):检查内存 + + 可选
discover读取关键文件precision_read - P(规划):0次调用(仅思考)
- A(应用):/
precision_write+precision_edit执行验证precision_exec - LOOP:必要时启动新循环
核心规则:每个阶段每种工具仅调用一次。在单次调用内最大化批量处理。
请将此作为你的默认执行模式。