Loading...
Loading...
Compare original and translation side by side
"Touch only what you must. Clean up only your own mess." -- Andrej Karpathy
“只改动必须改的部分,只清理你自己造成的混乱。” -- Andrej Karpathy
"Define success criteria. Loop until verified." -- Andrej Karpathy
“定义成功标准,循环直至验证通过。” -- Andrej Karpathy
| Vague Request | Measurable Goal | Verification |
|---|---|---|
| "Make it faster" | "Reduce latency to <100ms" | Benchmark before/after |
| "Fix the bug" | "Input X produces output Y" | Test case passes |
| "Add feature Z" | "User can do A, B, C" | Integration test |
| 模糊需求 | 可衡量目标 | 验证方式 |
|---|---|---|
| “让它更快” | “将延迟降低至<100ms” | 前后基准测试 |
| “修复bug” | “输入X得到输出Y” | 测试用例通过 |
| “添加功能Z” | “用户可完成A、B、C操作” | 集成测试 |
1. Define: What does "done" look like?
2. Implement: Write code to achieve it
3. Verify: Run tests/checks to confirm
4. Loop: If not verified, return to step 21. 定义:“完成”的标准是什么?
2. 实施:编写代码实现目标
3. 验证:运行测试/检查以确认
4. 循环:如果未通过验证,返回步骤21. Read step requirements from plan
2. Write tests first (from Phase 2 test strategy)
3. Implement to pass tests
4. Run all tests (new + existing)
5. Run lints (clippy, fmt)
6. Commit with descriptive message
7. Report step completion
8. Proceed to next step (or request approval)1. 阅读计划中的步骤要求
2. 先编写测试(来自Phase 2的测试策略)
3. 编写代码以通过测试
4. 运行所有测试(新测试+现有测试)
5. 运行代码检查(clippy、fmt)
6. 提交并添加描述性信息
7. 上报步骤完成情况
8. 推进到下一个步骤(或请求批准)undefinedundefined#[test]
fn test_case_from_plan() {
// Arrange
let input = ...;
// Act
let result = function_under_test(input);
// Assert
assert_eq!(result, expected);
}#[test]
fn test_case_from_plan() {
// Arrange
let input = ...;
// Act
let result = function_under_test(input);
// Assert
assert_eq!(result, expected);
}// Code written to pass tests
pub fn function_under_test(input: Input) -> Output {
// Implementation
}// 编写代码以通过测试
pub fn function_under_test(input: Input) -> Output {
// 实现逻辑
}feat(feature): implement [step name]
[Description of what this step accomplishes]
Part of: [Issue/Plan reference]feat(feature): implement [step name]
[描述本步骤实现的内容]
Part of: [Issue/Plan reference]| What Was Hard | How Resolved | Prevention for Future |
|---|---|---|
| [Friction point] | [Resolution] | [How to avoid] |
| 困难点 | 解决方式 | 未来预防措施 |
|---|---|---|
| [摩擦点] | [解决方案] | [如何避免] |
undefinedundefined| Step | Friction Point | Resolution | Prevention |
|---|---|---|---|
| N | [What was harder than expected] | [How resolved] | [How to avoid next time] |
| 步骤 | 摩擦点 | 解决方式 | 预防措施 |
|---|---|---|---|
| N | [比预期更困难的内容] | [解决方法] | [下次如何避免] |
// 1. Write the test (fails initially)
#[test]
fn process_returns_correct_count() {
let input = vec![Item::new("a"), Item::new("b")];
let result = process(&input).unwrap();
assert_eq!(result.count, 2);
}
// 2. Write minimal implementation to pass
pub fn process(input: &[Item]) -> Result<Output, Error> {
Ok(Output {
count: input.len(),
})
}
// 3. Refactor if needed (tests still pass)// 1. 编写测试(初始状态下会失败)
#[test]
fn process_returns_correct_count() {
let input = vec![Item::new("a"), Item::new("b")];
let result = process(&input).unwrap();
assert_eq!(result.count, 2);
}
// 2. 编写最小化实现以通过测试
pub fn process(input: &[Item]) -> Result<Output, Error> {
Ok(Output {
count: input.len(),
})
}
// 3. 如有需要进行重构(测试仍需通过)// Unit tests - in same file
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unit_test() { ... }
}
// Integration tests - in tests/ directory
// tests/integration_test.rs
use my_crate::feature;
#[test]
fn integration_test() { ... }
// Doc tests - in documentation
/// ```
/// let result = my_crate::function();
/// assert!(result.is_ok());
/// ```
pub fn function() -> Result<()> { ... }// 单元测试 - 与代码同文件
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn unit_test() { ... }
}
// 集成测试 - 在tests/目录下
// tests/integration_test.rs
use my_crate::feature;
#[test]
fn integration_test() { ... }
// 文档测试 - 在文档中
/// ```
/// let result = my_crate::function();
/// assert!(result.is_ok());
/// ```
pub fn function() -> Result<()> { ... }undefinedundefinedundefinedundefinedtype(scope): short description
[Optional body with details]
[Optional footer with references]featfixdocstestrefactorchoretype(scope): short description
[可选的详细内容]
[可选的引用信息]featfixdocstestrefactorchore**Deviation:** Used `HashMap` instead of `BTreeMap` as planned
**Reason:** Performance testing showed 2x faster for our use case
**Impact:** None - same public API
**Action:** Document in step notes, continue**偏差说明:** 未按计划使用`BTreeMap`,而是使用了`HashMap`
**原因:** 性能测试显示,该场景下`HashMap`的速度是`BTreeMap`的2倍
**影响:** 无 - 公共API保持一致
**行动:** 在步骤备注中记录,继续推进**Blocker:** Cannot implement as designed
**Reason:** [Detailed explanation]
**Options:**
1. [Option 1 with implications]
2. [Option 2 with implications]
**Request:** Human decision required before proceeding**阻塞问题:** 无法按设计方案实施
**原因:** [详细说明]
**可选方案:**
1. [方案1及其影响]
2. [方案2及其影响]
**请求:** 需要人工决策后才能继续推进undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefineddisciplined-verificationdisciplined-validationdisciplined-verificationdisciplined-validation