Git & Ship — Quản lý code và deploy

Quản lý git workflow, tạo worktree cho parallel development, và ship code lên production.

Cú pháp

/git                    # Git operations với conventional commits
/worktree               # Tạo isolated git worktree cho parallel dev
/ship                   # Ship pipeline: merge → test → review → push → PR

Bảng tham chiếu nhanh

LệnhMô tảUse case
/gitStaging, committing, pushing, PRs, mergesDaily git operations
/worktreeTạo git worktree riêng biệtParallel development trong monorepo
/shipFull ship pipeline (merge, test, review, push, PR)Ship feature lên production

/git — Git operations

Hỗ trợ conventional commits tự động:
/git                    # Auto-detect changes, suggest commit message
/git commit             # Stage + commit với conventional format
/git push               # Push + tạo PR nếu cần
Commit format tự động:
feat(auth): add Google OAuth login
fix(api): handle null response from payment gateway
chore(deps): upgrade Next.js to 14.2

/worktree — Parallel development

Cho phép chạy nhiều session Claude Code song song trên các bản sao riêng biệt của repo. Mỗi worktree có folder + branch riêng, không đụng nhau.

Cách dùng

# Tạo worktree với tên cụ thể
claude --worktree feat-F01-generate-site

# Tạo worktree tự động (random name)
claude --worktree

Lifecycle

  • Không có thay đổi → worktree + branch tự xóa khi thoát
  • Có thay đổi → Claude hỏi giữ lại hay xóa

File .worktreeinclude

Tạo ở root project, liệt kê file gitignored muốn copy vào worktree:
.env
.env.local

Use case cho project

# Terminal 1: làm feature
claude --worktree feat-F31-template-blueprints

# Terminal 2 (song song): fix bug
claude --worktree fix-builder-crash

# Terminal 3 (song song): audit
claude --worktree template-audit
Mỗi session làm việc độc lập, không sợ conflict. Rất hữu ích khi cần chạy nhiều task song song trên cùng repo!
Best practices:
  • Đặt tên worktree theo branch convention: feat-*, fix-*, hotfix-*
  • Tạo .worktreeinclude nếu project dùng .env
  • Dùng worktree khi cần chạy 2+ tasks song song trên cùng repo
  • Không dùng worktree cho task nhỏ chỉ cần 1 session

/ship — Ship pipeline

Full pipeline từ feature branch đến production:
1

Bước 1: Merge main

Pull latest từ main/staging, resolve conflicts nếu có.
2

Bước 2: Test

Chạy full test suite — phải PASS 100%.
3

Bước 3: Review diff

Review toàn bộ changes so với base branch.
4

Bước 4: Commit + Push

Commit final, push lên remote.
5

Bước 5: Create PR

Tạo PR với conventional title, description template.

Branch naming convention

feat/F01-01-generate-site          # Feature
fix/F01-builder-crash              # Bug fix
hotfix/F13-payment-timeout         # Urgent production fix
chore/deps-upgrade-nextjs          # Dependencies, config

Khi nào dùng / không dùng

DùngKhông dùng
Ship feature hoàn chỉnh (/ship)Chỉ commit nhỏ (dùng git CLI trực tiếp)
Parallel dev trên nhiều features (--worktree)Single branch workflow, task nhỏ 1 session
Cần conventional commits tự động (/git)Khi muốn manual git control