Loading...
Loading...
Compare original and translation side by side
mainmain ──●──●──●──●──●──●──●──●──●── (always deployable)
╲ ╱ ╲ ╱
●──●─╱ ●──╱ ← short-lived feature branches (1-3 days)mainmain ──●──●──●──●──●──●──●──●──●── (always deployable)
╲ ╱ ╲ ╱
●──●─╱ ●──╱ ← short-lived feature branches (1-3 days)Work pattern:
Implement slice → Test → Verify → Commit → Next slice
Not this:
Implement everything → Hope it works → Giant commit推荐工作模式:
实现小模块 → 测试 → 验证 → 提交 → 下一个模块
错误模式:
实现所有功能 → 祈祷能跑通 → 巨型提交undefinedundefinedundefinedundefinedundefinedundefined
**Format:**
**Types:**
- `feat` — New feature
- `fix` — Bug fix
- `refactor` — Code change that neither fixes a bug nor adds a feature
- `test` — Adding or updating tests
- `docs` — Documentation only
- `chore` — Tooling, dependencies, config
**格式要求:**
**类型说明:**
- `feat` — 新功能
- `fix` — 修复bug
- `refactor` — 既不修复bug也不新增功能的代码变更
- `test` — 新增或更新测试
- `docs` — 仅文档变更
- `chore` — 工具、依赖、配置相关变更undefinedundefined
**Separate refactoring from feature work.** A refactoring change and a feature change are two different changes — submit them separately. This makes each change easier to review, revert, and understand in history. Small cleanups (renaming a variable) can be included in a feature commit at reviewer discretion.
**将重构和功能开发分开**,重构变更和功能变更是两种不同的变更,请分开提交。这样每一次变更都更容易评审、回滚,也更容易在历史记录中理解。小型清理(比如重命名变量)可以在评审人同意的情况下包含在功能提交中。code-review-and-quality~100 lines → Easy to review, easy to revert
~300 lines → Acceptable for a single logical change
~1000 lines → Split into smaller changescode-review-and-quality~100 lines → 易评审,易回滚
~300 lines → 单个逻辑变更可接受的大小
~1000 lines → 需要拆分为更小的变更main (always deployable)
│
├── feature/task-creation ← One feature per branch
├── feature/user-settings ← Parallel work
└── fix/duplicate-tasks ← Bug fixesmainmain (always deployable)
│
├── feature/task-creation ← 一个分支对应一个功能
├── feature/user-settings ← 并行开发
└── fix/duplicate-tasks ← Bug修复mainfeature/<short-description> → feature/task-creation
fix/<short-description> → fix/duplicate-tasks
chore/<short-description> → chore/update-deps
refactor/<short-description> → refactor/auth-modulefeature/<short-description> → feature/task-creation
fix/<short-description> → fix/duplicate-tasks
chore/<short-description> → chore/update-deps
refactor/<short-description> → refactor/auth-moduleundefinedundefined
Benefits:
- Multiple agents can work on different features simultaneously
- No branch switching needed (each directory has its own branch)
- If one experiment fails, delete the worktree — nothing is lost
- Changes are isolated until explicitly merged
优势:
- 多个Agent可以同时在不同功能上工作
- 不需要切换分支(每个目录对应自己的分支)
- 如果某个实验失败,直接删除worktree即可,不会丢失任何内容
- 变更在显式合并前都是隔离的Agent starts work
│
├── Makes a change
│ ├── Test passes? → Commit → Continue
│ └── Test fails? → Revert to last commit → Investigate
│
├── Makes another change
│ ├── Test passes? → Commit → Continue
│ └── Test fails? → Revert to last commit → Investigate
│
└── Feature complete → All commits form a clean historygit reset --hard HEADAgent开始工作
│
├── 完成一次变更
│ ├── 测试通过? → 提交 → 继续
│ └── 测试失败? → 回滚到上一次提交 → 排查问题
│
├── 完成下一次变更
│ ├── 测试通过? → 提交 → 继续
│ └── 测试失败? → 回滚到上一次提交 → 排查问题
│
└── 功能开发完成 → 所有提交构成清晰的历史记录git reset --hard HEADCHANGES MADE:
- src/routes/tasks.ts: Added validation middleware to POST endpoint
- src/lib/validation.ts: Added TaskCreateSchema using Zod
THINGS I DIDN'T TOUCH (intentionally):
- src/routes/auth.ts: Has similar validation gap but out of scope
- src/middleware/error.ts: Error format could be improved (separate task)
POTENTIAL CONCERNS:
- The Zod schema is strict — rejects extra fields. Confirm this is desired.
- Added zod as a dependency (72KB gzipped) — already in package.jsonCHANGES MADE:
- src/routes/tasks.ts: Added validation middleware to POST endpoint
- src/lib/validation.ts: Added TaskCreateSchema using Zod
THINGS I DIDN'T TOUCH (intentionally):
- src/routes/auth.ts: Has similar validation gap but out of scope
- src/middleware/error.ts: Error format could be improved (separate task)
POTENTIAL CONCERNS:
- The Zod schema is strict — rejects extra fields. Confirm this is desired.
- Added zod as a dependency (72KB gzipped) — already in package.jsonundefinedundefined
Automate this with git hooks:
```json
// package.json (using lint-staged + husky)
{
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{json,md}": ["prettier --write"]
}
}
使用git hooks实现自动化:
```json
// package.json (使用lint-staged + husky)
{
"lint-staged": {
"*.{ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{json,md}": ["prettier --write"]
}
}package-lock.jsondist/.next/.env.vscode/settings.json.gitignorenode_modules/dist/.env.env.local*.pempackage-lock.jsondist/.next/.env.vscode/settings.json.gitignorenode_modules/dist/.env.env.local*.pemundefinedundefinedundefinedundefined| Rationalization | Reality |
|---|---|
| "I'll commit when the feature is done" | One giant commit is impossible to review, debug, or revert. Commit each slice. |
| "The message doesn't matter" | Messages are documentation. Future you (and future agents) will need to understand what changed and why. |
| "I'll squash it all later" | Squashing destroys the development narrative. Prefer clean incremental commits from the start. |
| "Branches add overhead" | Short-lived branches are free and prevent conflicting work from colliding. Long-lived branches are the problem — merge within 1-3 days. |
| "I'll split this change later" | Large changes are harder to review, riskier to deploy, and harder to revert. Split before submitting, not after. |
| "I don't need a .gitignore" | Until |
| 常见借口 | 实际情况 |
|---|---|
| "等功能开发完我再提交" | 一个巨型提交根本无法评审、调试或回滚,每完成一个小模块就提交。 |
| "提交信息不重要" | 提交信息就是文档,未来的你(以及未来的Agent)需要知道做了什么变更、为什么要变更。 |
| "我之后会把所有提交压扁" | 压扁提交会销毁整个开发过程记录,最好从一开始就提交清晰的增量变更。 |
| "分支会增加 overhead" | 短生命周期分支毫无成本,还能避免冲突工作互相影响,长生命周期分支才是问题所在,请在1-3天内完成合并。 |
| "我之后再拆分这个变更" | 大型变更更难评审,部署风险更高,也更难回滚,请在提交前拆分,而不是之后。 |
| "我不需要.gitignore文件" | 等你不小心提交了带生产环境密钥的.env文件就知道需要了,立刻配置好。 |
.gitignorenode_modules/.env.gitignorenode_modules/.env.gitignore.gitignore