pre-work-research
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePre-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:
| Situation | Research Needed |
|---|---|
| Unfamiliar area of codebase | Yes |
| New library or API | Yes |
| Complex integration | Yes |
| Performance-sensitive code | Yes |
| Security-sensitive code | Yes |
| Simple, isolated change | Minimal |
以下场景需要进行研究:
| 场景 | 是否需要研究 |
|---|---|
| 不熟悉的代码区域 | 是 |
| 新的库或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
undefinedbash
undefinedProject 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 considerationscat docs/api*.md
cat docs/architecture*.md
**重点关注:**
- 架构决策
- 使用的设计模式
- 编码规范
- 测试要求
- 部署注意事项Step 3: Research Existing Codebase
步骤3:研究现有代码库
Find Similar Implementations
查找类似实现
bash
undefinedbash
undefinedFind 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/
undefinedgrep -r "import.*ModuleName" src/
undefinedUnderstand Patterns
理解现有模式
bash
undefinedbash
undefinedHow 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
undefinedls -la src/services/
cat src/services/[existing-service].ts
undefinedCheck for Utilities
检查可用工具类
bash
undefinedbash
undefinedWhat 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/
undefinedgrep -r "export function" src/utils/
undefinedStep 4: Research External Resources
步骤4:研究外部资源
When using external APIs or libraries:
当使用外部API或库时:
Official Documentation
官方文档
bash
undefinedbash
undefinedRead the docs for dependencies
查看依赖包的信息
pnpm info [package-name]
pnpm info [package-name]
Then visit documentation URL
然后访问文档URL
undefinedSearch: "[library-name] documentation"
Search: "[library-name] getting started"
Search: "[library-name] [specific feature]"
undefinedundefined搜索:"[library-name] documentation"
搜索:"[library-name] getting started"
搜索:"[library-name] [specific feature]"
undefinedAPI 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
undefinedPre-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:
- [Step 1]
- [Step 2]
- [Step 3]
基于研究结果,方案如下:
- [步骤1]
- [步骤2]
- [步骤3]
Risks/Considerations
风险/注意事项
- [Risk 1]
- [Consideration 1]
undefined- [风险1]
- [注意事项1]
undefinedStep 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- [需要澄清的问题] "
undefinedResearch Depth by Task Size
按任务规模确定研究深度
| Task Size | Research 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
undefinedbash
undefinedJust verify pattern
仅验证现有模式
grep -r "pattern" src/ | head -5
cat src/similar/example.ts | head -50
undefinedgrep -r "pattern" src/ | head -5
cat src/similar/example.ts | head -50
undefinedFull 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 For | Why |
|---|---|
| Architecture diagrams | Understand system structure |
| Coding standards | Match existing style |
| Decision records | Understand why things are done a way |
| API contracts | Maintain compatibility |
| 关注内容 | 原因 |
|---|---|
| 架构图 | 理解系统结构 |
| 编码标准 | 匹配现有代码风格 |
| 决策记录 | 了解现有实现的设计初衷 |
| API契约 | 保持兼容性 |
In Codebase
代码库中需关注
| Look For | Why |
|---|---|
| Similar features | Follow established patterns |
| Test patterns | Write consistent tests |
| Error handling | Handle errors consistently |
| Logging patterns | Log appropriately |
| 关注内容 | 原因 |
|---|---|
| 类似功能 | 遵循已确立的实现模式 |
| 测试模式 | 编写风格一致的测试 |
| 错误处理 | 保持错误处理逻辑一致 |
| 日志模式 | 规范日志记录 |
In External Resources
外部资源中需关注
| Look For | Why |
|---|---|
| Official examples | Use recommended patterns |
| Common pitfalls | Avoid known issues |
| Performance tips | Optimize appropriately |
| Security guidance | Implement 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:
- - Step 5
issue-driven-development
This skill informs:
- - How to write tests
tdd-full-coverage - - Type patterns to use
strict-typing - - Documentation patterns
inline-documentation
本技能被以下技能调用:
- - 步骤5
issue-driven-development
本技能为以下技能提供支持:
- - 指导如何编写测试
tdd-full-coverage - - 指导应使用的类型模式
strict-typing - - 指导文档编写模式
inline-documentation