research-compound
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResearch Compound
研究成果整合
Compound learnings into folder-specific AGENTS.md files during research work.
将研究过程中的学习成果整合到特定文件夹的AGENTS.md文件中。
Trigger Conditions
触发条件
Activate this behavior when:
- Investigating a specific domain (jobs, models, services, controllers, etc.)
- Using research agents (repo-analyst, docs-researcher, etc.)
- Reading multiple files in the same folder hierarchy
- User asks to "understand", "investigate", or "research" a subsystem
在以下情况触发该行为:
- 研究特定领域(如任务、模型、服务、控制器等)
- 使用研究Agent(如repo-analyst、docs-researcher等)
- 读取同一文件夹层级中的多个文件
- 用户要求“理解”“调研”或“研究”某个子系统
Pre-Research: Check Existing Context
研究前:检查现有上下文
Before diving into code, find and read the nearest AGENTS.md:
bash
undefined在深入研究代码之前,找到并读取最近的AGENTS.md:
bash
undefinedFrom target folder, traverse up to find nearest AGENTS.md
从目标文件夹开始,向上遍历查找最近的AGENTS.md
Example: researching app/jobs/cash_app/
示例:研究app/jobs/cash_app/
Check: app/jobs/cash_app/AGENTS.md
检查:app/jobs/cash_app/AGENTS.md
app/jobs/AGENTS.md
app/jobs/AGENTS.md
app/AGENTS.md
app/AGENTS.md
AGENTS.md (root)
AGENTS.md (根目录)
undefinedundefinedWhat to Extract
需要提取的内容
From existing AGENTS.md, note:
- Known patterns and conventions
- Documented gotchas
- File organization rules
- Testing approaches
- Previous learnings (avoid re-discovering)
从现有AGENTS.md中记录:
- 已知的模式和约定
- 已记录的注意事项
- 文件组织规则
- 测试方法
- 之前的研究成果(避免重复发现)
Pre-Research Output
研究前输出
Briefly acknowledge:
Found existing context in app/jobs/AGENTS.md:
- Jobs use Sidekiq with retry configuration
- Naming: *Job suffix required
- Testing: Use perform_inline in specs简要确认:
在app/jobs/AGENTS.md中找到现有上下文:
- 任务使用Sidekiq并配置重试机制
- 命名规则:必须以*Job为后缀
- 测试:在测试用例中使用perform_inlinePost-Research: Evaluate Learnings
研究后:评估研究成果
After research, evaluate each discovery:
研究完成后,评估每个发现:
Worth Recording (YES)
值得记录(是)
| Criteria | Example |
|---|---|
| Applies to multiple files in domain | "All jobs inherit from ApplicationJob" |
| Non-obvious convention | "Jobs must call |
| Gotcha that caused confusion | "CashApp jobs require merchant_id, not user_id" |
| Integration pattern | "Jobs trigger webhooks via WebhookService" |
| Testing insight | "Use |
| 判定标准 | 示例 |
|---|---|
| 适用于该领域的多个文件 | "所有任务都继承自ApplicationJob" |
| 非显而易见的约定 | "任务必须在自定义逻辑前调用 |
| 易造成混淆的注意事项 | "CashApp任务需要merchant_id,而非user_id" |
| 集成模式 | "任务通过WebhookService触发Webhook" |
| 测试见解 | "在定时任务测试用例中使用 |
Skip Recording (NO)
无需记录(否)
| Criteria | Example |
|---|---|
| One-off implementation detail | "ProcessPaymentJob has 3 retries" |
| Already documented | Pattern exists in AGENTS.md |
| Too specific to single file | "Line 42 has a TODO" |
| Obvious from code | "Job processes payments" |
| 判定标准 | 示例 |
|---|---|
| 一次性实现细节 | "ProcessPaymentJob有3次重试机会" |
| 已在文档中记录 | 模式已存在于AGENTS.md中 |
| 仅针对单个文件的细节 | "第42行有一个TODO注释" |
| 从代码中可直接看出 | "任务处理支付" |
Update Protocol
更新流程
Step 1: Locate Target AGENTS.md
步骤1:定位目标AGENTS.md
Use nearest-wins hierarchy:
- If exists → update it
{domain}/AGENTS.md - If not, check parent folder
- If no AGENTS.md in hierarchy → create at domain level
bash
undefined采用“最近优先”层级规则:
- 若已存在 → 更新该文件
{domain}/AGENTS.md - 若不存在,检查父文件夹
- 若层级中无AGENTS.md → 在领域层级创建
bash
undefinedFind existing AGENTS.md files
查找现有AGENTS.md文件
find . -name "AGENTS.md" -type f | head -20
undefinedfind . -name "AGENTS.md" -type f | head -20
undefinedStep 2: Determine Section
步骤2:确定章节
Map learning type to section:
| Learning Type | Target Section |
|---|---|
| Pattern/Convention | |
| Gotcha/Warning | |
| File organization | |
| Testing approach | |
| Integration point | |
If section doesn't exist, create it.
将研究成果类型映射到对应章节:
| 研究成果类型 | 目标章节 |
|---|---|
| 模式/约定 | |
| 注意事项/警告 | |
| 文件组织 | |
| 测试方法 | |
| 集成点 | |
若对应章节不存在,则创建该章节。
Step 3: Format the Learning
步骤3:格式化研究成果
markdown
- **[Short title]**: [Concrete description]
- Example: `path/to/example.rb:42`Keep entries:
- Single bullet point (1-2 lines)
- Concrete, not vague
- With file reference when applicable
markdown
- **[简短标题]**: [具体描述]
- 示例:`path/to/example.rb:42`保持条目:
- 单个项目符号(1-2行)
- 具体明确,而非模糊描述
- 如有适用,附带文件引用
Step 4: Append (Don't Replace)
步骤4:追加(而非替换)
Use Edit tool to append to appropriate section:
markdown
undefined使用编辑工具将内容追加到对应章节:
markdown
undefinedGotchas
Gotchas
- Existing gotcha: Description
- NEW: Merchant ID required: CashApp jobs use , not
merchant_iduser_id- Example:
app/jobs/cash_app/process_payment_job.rb:15
- Example:
undefined- 已有的注意事项: 描述
- 新增:需要商家ID: CashApp任务使用,而非
merchant_iduser_id- 示例:
app/jobs/cash_app/process_payment_job.rb:15
- 示例:
undefinedCreating New AGENTS.md
创建新的AGENTS.md
If no AGENTS.md exists in the domain hierarchy, create one:
markdown
undefined若领域层级中无AGENTS.md,则创建新文件:
markdown
undefined{Domain Name}
{领域名称}
Purpose
用途
{One-line description of this domain}
{该领域的一行描述}
Patterns
Patterns
- Pattern name: Description
- Example:
path/to/file.rb
- Example:
- 模式名称: 描述
- 示例:
path/to/file.rb
- 示例:
Gotchas
Gotchas
- Gotcha name: Description
- 注意事项名称: 描述
Testing
Testing
- Testing approach: Description
undefined- 测试方法: 描述
undefinedPlacement Rules
放置规则
| Domain Depth | Create At |
|---|---|
| |
| |
| |
Only create subfolder AGENTS.md if:
- 3+ files in that specific folder
- Distinct patterns from parent domain
- Significant complexity warranting isolation
| 领域深度 | 创建位置 |
|---|---|
| |
| |
| |
仅在以下情况创建子文件夹AGENTS.md:
- 该特定文件夹中有3个以上文件
- 存在与父领域不同的独特模式
- 复杂度较高,需要独立文档
Examples
示例
Example 1: Pre-Research Check
示例1:研究前检查
User: "Investigate how background jobs work in this app"
Claude:
1. Target domain: app/jobs/
2. Check for AGENTS.md...
- Found: app/jobs/AGENTS.md
3. Read existing context:
"Jobs use Sidekiq, ApplicationJob base class, *Job suffix"
4. Proceed with research, avoiding re-discovery of known patterns用户:“调研这个应用中后台任务的工作方式”
Claude:
1. 目标领域:app/jobs/
2. 检查AGENTS.md...
- 找到:app/jobs/AGENTS.md
3. 读取现有上下文:
“任务使用Sidekiq、ApplicationJob基类,必须以*Job为后缀”
4. 开始研究,避免重复发现已知模式Example 2: Post-Research Update
示例2:研究后更新
After researching app/jobs/cash_app/:
Discovered:
- CashApp jobs require merchant_id (not user_id) ← WORTH RECORDING
- ProcessPaymentJob has 3 retries ← SKIP (too specific)
- All CashApp jobs log to separate channel ← WORTH RECORDING
Update app/jobs/cash_app/AGENTS.md:在研究app/jobs/cash_app/后:
发现:
- CashApp任务需要merchant_id(而非user_id) ← 值得记录
- ProcessPaymentJob有3次重试机会 ← 无需记录(过于具体)
- 所有CashApp任务记录到独立日志通道 ← 值得记录
更新app/jobs/cash_app/AGENTS.md:Gotchas
Gotchas
-
- Merchant ID required: Use , not
merchant_idfor CashApp jobsuser_id
- Merchant ID required: Use
-
- Example:
app/jobs/cash_app/process_payment_job.rb:15
- Example:
-
- 需要商家ID: CashApp任务使用而非
merchant_iduser_id
- 需要商家ID: CashApp任务使用
-
- 示例:
app/jobs/cash_app/process_payment_job.rb:15
- 示例:
Patterns
Patterns
-
- Separate logging: CashApp jobs use channel
CashAppLogger
- Separate logging: CashApp jobs use
-
- Example:
app/jobs/cash_app/base_job.rb:8
- Example:
undefined-
- 独立日志: CashApp任务使用通道
CashAppLogger
- 独立日志: CashApp任务使用
-
- 示例:
app/jobs/cash_app/base_job.rb:8
- 示例:
undefinedExample 3: Creating New AGENTS.md
示例3:创建新的AGENTS.md
Researching app/services/webhooks/ (no existing AGENTS.md)
After research, create app/services/webhooks/AGENTS.md:研究app/services/webhooks/(无现有AGENTS.md)
研究完成后,创建app/services/webhooks/AGENTS.md:Webhooks
Webhooks
Purpose
用途
Outbound webhook delivery and retry management.
出站Webhook的交付与重试管理。
Patterns
Patterns
- Delivery service: All webhooks go through
WebhookDeliveryService- Example:
app/services/webhooks/delivery_service.rb
- Example:
- Payload builders: Each event type has a
*PayloadBuilder- Example:
app/services/webhooks/payment_payload_builder.rb
- Example:
- 交付服务: 所有Webhook都通过处理
WebhookDeliveryService- 示例:
app/services/webhooks/delivery_service.rb
- 示例:
- 负载构建器: 每种事件类型都有对应的
*PayloadBuilder- 示例:
app/services/webhooks/payment_payload_builder.rb
- 示例:
Gotchas
Gotchas
- Idempotency required: Webhooks may retry; receivers must handle duplicates
- Timeout: 30-second timeout on delivery attempts
undefined- 需要幂等性: Webhook可能重试,接收方必须处理重复请求
- 超时设置: 交付尝试的超时时间为30秒
undefinedQuality Checks
质量检查
Before updating AGENTS.md, verify:
- Learning is generalizable (applies beyond single file)
- Not already documented
- Concrete enough to act on
- Has file reference for examples
- Matches existing AGENTS.md style/structure
在更新AGENTS.md之前,验证:
- 研究成果具有通用性(适用于多个文件)
- 未在现有文档中记录
- 具体到可执行
- 附带示例文件引用
- 符合现有AGENTS.md的风格/结构
Anti-Patterns
反模式
| Don't | Do Instead |
|---|---|
| Dump all findings into AGENTS.md | Filter for generalizable patterns only |
| Create AGENTS.md for every folder | Only domains with distinct patterns |
| Write paragraphs | Single bullet points with examples |
| Duplicate root-level guidance | Only domain-specific additions |
| Update on every file read | Batch updates at research completion |
| 不要做 | 正确做法 |
|---|---|
| 将所有发现都写入AGENTS.md | 仅筛选具有通用性的模式 |
| 为每个文件夹都创建AGENTS.md | 仅为有独特模式的领域创建 |
| 编写大段文字 | 使用带示例的单个项目符号 |
| 重复根层级的指导内容 | 仅添加领域特定的补充内容 |
| 每次读取文件都更新 | 在研究完成后批量更新 |