pre-work-research

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pre-Work Research

前置研究

Overview

概述

Research before coding. Understand the landscape before changing it.
Core principle: Measure twice, cut once.
Announce at start: "I'm researching the codebase and documentation before implementing."
编码前先做研究。在修改现有系统前先了解其全貌。
核心原则:三思而后行。
开始时告知:“我正在研究代码库和文档,之后再进行实现。”

When to Research

何时需要研究

Research is appropriate when:
SituationResearch Needed
Unfamiliar area of codebaseYes
New library or APIYes
Complex integrationYes
Performance-sensitive codeYes
Security-sensitive codeYes
Simple, isolated changeMinimal
以下场景需要进行研究:
场景是否需要研究
不熟悉的代码区域
新的库或API
复杂集成
性能敏感型代码
安全敏感型代码
简单、独立的修改少量即可

The Research Protocol

研究流程

Step 1: Understand Requirements

步骤1:理解需求

Before researching implementation:
  • Read the full issue description
  • Review all acceptance criteria
  • Note any constraints mentioned
  • Identify unknowns
在研究实现方案前:
  • 完整阅读问题描述
  • 查看所有验收标准
  • 记录提到的约束条件
  • 识别未知点

Step 2: Research Repository Documentation

步骤2:研究仓库文档

bash
undefined
bash
undefined

Project overview

项目概述

cat README.md
cat README.md

Architecture/design docs

架构/设计文档

ls -la docs/ find . -name ".md" -path "./docs/"
ls -la docs/ find . -name ".md" -path "./docs/"

Contributing guidelines

贡献指南

cat CONTRIBUTING.md
cat CONTRIBUTING.md

API documentation

API文档

cat docs/api*.md cat docs/architecture*.md

**Look for:**
- Architecture decisions
- Design patterns used
- Coding conventions
- Testing requirements
- Deployment considerations
cat docs/api*.md cat docs/architecture*.md

**重点关注:**
- 架构决策
- 使用的设计模式
- 编码规范
- 测试要求
- 部署注意事项

Step 3: Research Existing Codebase

步骤3:研究现有代码库

Find Similar Implementations

查找类似实现

bash
undefined
bash
undefined

Find similar features

查找类似功能

grep -r "similar keyword" src/
grep -r "similar keyword" src/

Find related tests

查找相关测试

grep -r "similar keyword" **/.test.
grep -r "similar keyword" **/.test.

Find imports of relevant modules

查找相关模块的导入

grep -r "import.*ModuleName" src/
undefined
grep -r "import.*ModuleName" src/
undefined

Understand Patterns

理解现有模式

bash
undefined
bash
undefined

How are similar things done?

类似功能是如何实现的?

Look at 2-3 examples of similar functionality

查看2-3个类似功能的示例

Example: If adding an API endpoint

示例:如果添加API端点

grep -r "router." src/routes/ cat src/routes/[existing-endpoint].ts
grep -r "router." src/routes/ cat src/routes/[existing-endpoint].ts

Example: If adding a service

示例:如果添加服务

ls -la src/services/ cat src/services/[existing-service].ts
undefined
ls -la src/services/ cat src/services/[existing-service].ts
undefined

Check for Utilities

检查可用工具类

bash
undefined
bash
undefined

What utilities exist?

有哪些工具类可用?

ls -la src/utils/ cat src/utils/[relevant-util].ts
ls -la src/utils/ cat src/utils/[relevant-util].ts

Are there shared helpers?

是否有共享的辅助函数?

grep -r "export function" src/utils/
undefined
grep -r "export function" src/utils/
undefined

Step 4: Research External Resources

步骤4:研究外部资源

When using external APIs or libraries:
当使用外部API或库时:

Official Documentation

官方文档

bash
undefined
bash
undefined

Read the docs for dependencies

查看依赖包的信息

pnpm info [package-name]
pnpm info [package-name]

Then visit documentation URL

然后访问文档URL

undefined
Search: "[library-name] documentation" Search: "[library-name] getting started" Search: "[library-name] [specific feature]"
undefined
undefined
搜索:"[library-name] documentation" 搜索:"[library-name] getting started" 搜索:"[library-name] [specific feature]"
undefined

API References

API参考

For external APIs:
  • Authentication requirements
  • Rate limits
  • Error handling
  • Response formats
  • Versioning
对于外部API:
  • 认证要求
  • 请求限制
  • 错误处理
  • 响应格式
  • 版本控制

Community Resources

社区资源

  • GitHub issues for common problems
  • Stack Overflow for patterns
  • Blog posts for best practices
  • GitHub上的常见问题
  • Stack Overflow上的实现模式
  • 关于最佳实践的博客文章

Step 5: Document Findings

步骤5:记录研究结果

Create a research summary:
markdown
undefined
创建研究总结:
markdown
undefined

Pre-Work Research: Issue #[NUMBER]

前置研究:问题 #[NUMBER]

Requirements Understanding

需求理解

  • [Key requirement 1]
  • [Key requirement 2]
  • [关键需求1]
  • [关键需求2]

Codebase Patterns

代码库模式

  • Pattern for [X]: See
    src/example/pattern.ts
  • Utilities available:
    src/utils/helper.ts
  • Test pattern: See
    src/example/example.test.ts
  • [X]的实现模式:参考
    src/example/pattern.ts
  • 可用工具类:
    src/utils/helper.ts
  • 测试模式:参考
    src/example/example.test.ts

External Dependencies

外部依赖

  • [Library]: [Key findings]
  • [API]: [Authentication method, rate limits]
  • [库名称]:[关键发现]
  • [API名称]:[认证方式、请求限制]

Approach

实现方案

Based on research, the approach is:
  1. [Step 1]
  2. [Step 2]
  3. [Step 3]
基于研究结果,方案如下:
  1. [步骤1]
  2. [步骤2]
  3. [步骤3]

Risks/Considerations

风险/注意事项

  • [Risk 1]
  • [Consideration 1]
undefined
  • [风险1]
  • [注意事项1]
undefined

Step 6: Update Issue (If Significant)

步骤6:更新问题(如有重要发现)

If research reveals important context:
bash
gh issue comment [ISSUE_NUMBER] --body "## Pre-Implementation Research
如果研究发现了重要信息:
bash
gh issue comment [ISSUE_NUMBER] --body "## 实现前置研究

Approach

实现方案

[Summary of planned approach]
[计划方案概述]

Considerations

注意事项

  • [Important finding 1]
  • [Important finding 2]
  • [重要发现1]
  • [重要发现2]

Questions (if any)

疑问(如有)

  • [Question needing clarification] "
undefined
  • [需要澄清的问题] "
undefined

Research Depth by Task Size

按任务规模确定研究深度

Task SizeResearch Depth
Trivial (typo, config)None needed
Small (single file)Quick pattern check
Medium (feature)Full protocol
Large (system)Extended research
任务规模研究深度
微小(拼写错误、配置修改)无需研究
小型(单文件修改)快速检查现有模式
中型(功能开发)完整执行研究流程
大型(系统级修改)深度研究

Quick Pattern Check (5 min)

快速模式检查(5分钟)

bash
undefined
bash
undefined

Just verify pattern

仅验证现有模式

grep -r "pattern" src/ | head -5 cat src/similar/example.ts | head -50
undefined
grep -r "pattern" src/ | head -5 cat src/similar/example.ts | head -50
undefined

Full Protocol (15-30 min)

完整研究流程(15-30分钟)

Complete Steps 1-6 above.
完成上述步骤1-6。

Extended Research (1+ hour)

深度研究(1小时以上)

  • Read all relevant documentation
  • Trace through existing implementations
  • Create proof-of-concept if needed
  • Document architectural considerations
  • 阅读所有相关文档
  • 追踪现有实现的执行流程
  • 如有需要,创建概念验证原型
  • 记录架构层面的注意事项

What to Look For

研究重点

In Documentation

文档中需关注

Look ForWhy
Architecture diagramsUnderstand system structure
Coding standardsMatch existing style
Decision recordsUnderstand why things are done a way
API contractsMaintain compatibility
关注内容原因
架构图理解系统结构
编码标准匹配现有代码风格
决策记录了解现有实现的设计初衷
API契约保持兼容性

In Codebase

代码库中需关注

Look ForWhy
Similar featuresFollow established patterns
Test patternsWrite consistent tests
Error handlingHandle errors consistently
Logging patternsLog appropriately
关注内容原因
类似功能遵循已确立的实现模式
测试模式编写风格一致的测试
错误处理保持错误处理逻辑一致
日志模式规范日志记录

In External Resources

外部资源中需关注

Look ForWhy
Official examplesUse recommended patterns
Common pitfallsAvoid known issues
Performance tipsOptimize appropriately
Security guidanceImplement securely
关注内容原因
官方示例使用推荐的实现模式
常见陷阱避免已知问题
性能优化建议合理进行优化
安全指导安全地实现功能

Research Outputs

研究成果

After research, you should know:
  • How similar features are implemented
  • What patterns to follow
  • What utilities are available
  • What the testing approach should be
  • Any risks or special considerations
完成研究后,你应该明确:
  • 类似功能的实现方式
  • 需要遵循的模式
  • 可用的工具类
  • 应采用的测试方案
  • 任何风险或特殊注意事项

Checklist

检查清单

Before starting implementation:
  • Issue requirements understood
  • Repository docs checked
  • Similar code patterns found
  • Relevant utilities identified
  • External resources researched (if applicable)
  • Approach documented
  • Issue updated (if significant findings)
开始实现前需确认:
  • 已理解问题需求
  • 已查看仓库文档
  • 已找到类似代码的实现模式
  • 已识别相关可用工具类
  • 已研究相关外部资源(如适用)
  • 已记录实现方案
  • 已更新问题(如有重要发现)

Integration

集成关系

This skill is called by:
  • issue-driven-development
    - Step 5
This skill informs:
  • tdd-full-coverage
    - How to write tests
  • strict-typing
    - Type patterns to use
  • inline-documentation
    - Documentation patterns
本技能被以下技能调用:
  • issue-driven-development
    - 步骤5
本技能为以下技能提供支持:
  • tdd-full-coverage
    - 指导如何编写测试
  • strict-typing
    - 指导应使用的类型模式
  • inline-documentation
    - 指导文档编写模式