Add Vietnamese (Tiếng Việt) Localization (#42)
* feat(i18n): add Vietnamese localization infrastructure Add comprehensive infrastructure for Vietnamese translation of the claude-howto documentation: Features: - Parallel vi/ directory structure for Vietnamese content - Modified build_epub.py with --lang flag for Vietnamese EPUB - Vietnamese-specific pre-commit hooks for quality checks - Translation support files (glossary, style guide, queue tracker) - sync_translations.py script to detect outdated translations Infrastructure: - vi/ directory with all 10 module subdirectories - TRANSLATION_NOTES.md: comprehensive glossary and style guide - TRANSLATION_QUEUE.md: progress tracking for 66+ files - vi/README.md: Vietnamese landing page EPUB Build: - Added --lang CLI flag (en/vi) to build_epub.py - Language-specific metadata (title, subtitle) - Automatic root path adjustment for vi/ directory - Dynamic output filename (claude-howto-guide-vi.epub) Quality Assurance: - Vietnamese markdown linting - Vietnamese cross-reference checking - Vietnamese Mermaid syntax validation - Vietnamese link checking - Vietnamese EPUB build validation Ready for translation work to begin. * feat(vi): translate INDEX.md to Vietnamese Complete Vietnamese translation of INDEX.md - the comprehensive index of all example files in the repository. Translation follows vi/TRANSLATION_NOTES.md guidelines: - Technical terms kept per glossary (slash command → "lệnh slash") - File paths and code blocks preserved in English - Table structure and formatting maintained - All 882 lines translated Content includes: - Complete file tree (10 modules, 100+ files) - Feature coverage matrix - Quick start guides by use case - Learning path progression - Search by keyword sections Progress: 1/5 core documents completed * feat(vi): translate CATALOG.md to Vietnamese Complete Vietnamese translation of CATALOG.md - the quick reference guide to all Claude Code features. Translation follows vi/TRANSLATION_NOTES.md guidelines: - Technical terms kept per glossary (slash command → "lệnh slash") - All command names preserved (/help, /optimize, etc.) - Code blocks, JSON examples, and bash commands unchanged - All tables and formatting maintained - 517 lines translated with complete feature coverage Content includes: - Summary statistics (99 built-in + 43 examples = 117 total) - Complete built-in commands reference (55+ commands) - Custom commands examples (8 commands) - Permission modes (6 modes) - Subagents (6 built-in + 10 custom) - Skills (5 bundled + 4 custom) - Plugins (3 complete plugins) - MCP servers (1 built-in + 8 common servers) - Hooks (25 events + 7 example hooks) - Memory files (7 types) - New features (March 2026) - 17 new features - Installation priority guide - Complete one-command installation Progress: 2/5 core documents completed * docs(vi): translate learning roadmap to Vietnamese - Add complete Vietnamese translation of LEARNING-ROADMAP.md (747 lines) - Include self-assessment quiz for level determination - Translate three learning levels: Beginner, Intermediate, Advanced - Translate all milestones (1A, 1B, 2A, 2B, 3A, 3B) with hands-on exercises - Preserve Mermaid diagram for learning path visualization - Maintain progress tracking checklists and learning tips * docs(vi): translate quick reference guide to Vietnamese - Add complete Vietnamese translation of QUICK_REFERENCE.md (507 lines) - Include installation quick commands for all features - Translate feature cheat sheet with usage examples - Translate common use cases (code review, documentation, DevOps, etc.) - Preserve all code snippets, commands, and file paths in English - Maintain file locations reference diagram - Include learning path and new features (March 2026) sections - Keep tips & tricks, feature matrix, and checklist intact * docs(vi): translate module 01 - slash commands to Vietnamese - Add complete Vietnamese translation of 01-slash-commands/README.md (553 lines) - Translate slash commands overview and architecture - Include 55+ built-in commands reference table with Vietnamese descriptions - Translate bundled skills section (5 skills) - Document custom commands (now skills) migration path - Include frontmatter reference, arguments, and dynamic context sections - Preserve all command names, code examples, and Mermaid diagrams - Translate 8 available commands in folder with usage examples - Include installation, troubleshooting, and best practices sections * docs(vi): update translation queue progress - Module 01 README done - Mark 01-slash-commands/README.md as completed (2026-04-02) - Update Module 01 progress: 1/9 files (11%) - Update overall progress: 6/66 files (9%) - Update Priority 2 progress: 1/31 files (3%) - Add recent completion note to queue header * docs(vi): translate slash command - commit to Vietnamese - Translate commit.md slash command to Vietnamese - Keep all git commands and technical syntax intact - Translate instructions and descriptions - Maintain conventional commits format documentation * docs(vi): translate slash command - doc-refactor to Vietnamese - Translate doc-refactor.md slash command to Vietnamese - Keep all technical terms and file paths intact - Translate documentation refactoring instructions - Maintain structure and numbering * docs(vi): translate slash command - generate-api-docs to Vietnamese - Translate generate-api-docs.md slash command to Vietnamese - Keep all technical terms and file paths intact - Translate API documentation generation instructions - Maintain output format specifications * docs(vi): translate slash command - optimize to Vietnamese - Translate optimize.md slash command to Vietnamese - Keep all technical terms and code concepts intact - Translate code optimization instructions - Maintain issue priority and response format * docs(vi): translate slash command - pr to Vietnamese - Translate pr.md slash command to Vietnamese - Keep all commands and technical syntax intact - Translate PR preparation checklist instructions - Maintain conventional commits format documentation * docs(vi): translate slash command - push-all to Vietnamese - Translate push-all.md slash command to Vietnamese (153 lines) - Keep all git commands and technical syntax intact - Translate comprehensive workflow with safety checks - Maintain API key validation patterns and error handling - Preserve when to use/avoid sections and alternatives * docs(vi): translate slash command - setup-ci-cd to Vietnamese - Translate setup-ci-cd.md slash command to Vietnamese - Keep all tool names and technical terms intact - Translate CI/CD pipeline implementation instructions - Maintain pre-commit hooks and GitHub Actions sections * docs(vi): translate slash command - unit-test-expand to Vietnamese - Translate unit-test-expand.md slash command to Vietnamese - Keep all framework names and technical terms intact - Translate test coverage expansion instructions - Maintain testing frameworks and scenario sections * docs(vi): update translation queue - Module 01 complete (100%) - Mark all 9 Module 01 files as completed (2026-04-02) - Update Module 01 progress: 9/9 files (100%) ✅ - Update overall progress: 14/66 files (21%) - Update Priority 2 progress: 9/31 files (29%) - Update header with Module 01 completion milestone Module 01: Slash Commands - All files translated: ✅ README.md (overview, built-in commands, skills) ✅ commit.md (git commit with context) ✅ doc-refactor.md (documentation restructuring) ✅ generate-api-docs.md (API documentation generator) ✅ optimize.md (code optimization analysis) ✅ pr.md (pull request preparation) ✅ push-all.md (stage, commit, push with safety) ✅ setup-ci-cd.md (CI/CD pipeline implementation) ✅ unit-test-expand.md (test coverage expansion) * docs(vi): translate module 02 - memory guide to Vietnamese - Add complete Vietnamese translation of 02-memory/README.md (1162 lines) - Translate memory system overview and architecture - Include quick reference for memory commands (/init, /memory, #) - Document complete memory hierarchy (8 levels with precedence) - Translate auto memory section with architecture diagrams - Include practical examples (project, directory-specific, personal memory) - Add best practices, installation instructions, and troubleshooting - Preserve all code examples, file paths, and technical terms - Maintain Mermaid diagrams and tables * docs(vi): translate example project CLAUDE.md to Vietnamese - Translate project-CLAUDE.md example memory file - Keep all technical terms, commands, and code style intact - Translate descriptions and explanations - Maintain project configuration structure * docs(vi): translate example personal CLAUDE.md to Vietnamese - Translate personal-CLAUDE.md example memory file - Keep all technical terms, tools, and preferences intact - Translate descriptions and explanations - Maintain personal preferences structure * docs(vi): translate example directory-specific CLAUDE.md to Vietnamese - Translate directory-api-CLAUDE.md example memory file - Keep all technical terms, API standards, and code examples intact - Translate descriptions and explanations - Maintain API module standards structure * docs(vi): update translation queue - Module 02 complete (100%) - Mark all 4 Module 02 files as completed (2026-04-02) - Update Module 02 progress: 4/4 files (100%) ✅ - Update overall progress: 18/66 files (27%) - Update Priority 2 progress: 13/31 files (42%) - Update header with Module 02 completion milestone Module 02: Memory - All files translated: ✅ README.md (1162 lines - comprehensive memory guide) ✅ project-CLAUDE.md (example project memory) ✅ personal-CLAUDE.md (example personal preferences) ✅ directory-api-CLAUDE.md (example directory-specific rules) * docs(vi): translate module 03 - skills guide to Vietnamese - Add complete Vietnamese translation of 03-skills/README.md (805 lines) - Translate Agent Skills overview and architecture - Include progressive disclosure loading mechanism (3 levels) - Document skill types, locations, and automatic discovery - Translate skill creation process and SKILL.md format - Include required and optional frontmatter fields - Document skill content types (reference vs task) - Translate controlling skill invocation and string substitutions - Include dynamic context injection with shell commands - Document running skills in subagents with context: fork - Translate 6 practical examples with directory structures - Add supporting files, management, and best practices sections - Preserve all code examples, YAML frontmatter, and Mermaid diagrams - Maintain tables, troubleshooting guides, and security considerations * docs(vi): translate skill - blog-draft to Vietnamese - Translate blog-draft/SKILL.md to Vietnamese (275 lines) - Keep all workflow steps and technical structure intact - Translate instructions and descriptions - Maintain version tracking and file structure - Preserve all markdown formatting and code examples * docs(vi): translate skill - brand-voice to Vietnamese - Translate brand-voice/SKILL.md to Vietnamese (73 lines) - Keep brand identity, tone, and vocabulary intact - Translate writing guidelines and examples - Maintain preferred/avoided terms sections - Preserve good/bad examples with explanations * docs(vi): translate skill - claude-md to Vietnamese - Translate claude-md/SKILL.md to Vietnamese (213 lines) - Keep all golden rules and core principles intact - Translate execution flow and content strategy - Maintain WHAT/WHY/HOW structure - Preserve quality constraints and validation checklist - Keep anti-patterns and output format sections * docs(vi): translate skill - code-review to Vietnamese - Translate code-review/SKILL.md to Vietnamese (71 lines) - Keep all review categories and template intact - Translate security, performance, quality, maintainability sections - Maintain review template structure - Preserve version history * docs(vi): translate skill - refactor to Vietnamese - Translate refactor/SKILL.md to Vietnamese (427 lines) - Keep all Martin Fowler refactoring methodology intact - Translate 6-phase workflow with detailed steps - Maintain core principles and safety rules - Preserve code smell catalog and refactoring techniques - Keep quick start example with before/after code - Maintain version history and references sections * docs(vi): update translation queue - Module 03 complete (100%) - Mark all 6 Module 03 files as completed (2026-04-02) - Update Module 03 progress: 6/6 files (100%) ✅ - Update overall progress: 24/66 files (36%) - Update Priority 2 progress: 19/31 files (61%) - Update header with Module 03 completion milestone Module 03: Skills - All files translated: ✅ README.md (805 lines - comprehensive skills guide) ✅ blog-draft/SKILL.md (275 lines - blog post creation workflow) ✅ brand-voice/SKILL.md (73 lines - brand voice consistency) ✅ claude-md/SKILL.md (213 lines - CLAUDE.md best practices) ✅ code-review/SKILL.md (71 lines - comprehensive code review) ✅ refactor/SKILL.md (427 lines - Fowler refactoring methodology) * docs(vi): translate Module 04 Subagents README Complete Vietnamese translation of subagents reference guide: - Configuration and built-in subagents (general-purpose, Plan, Explore, Bash, statusline-setup, Claude Code Guide) - Agent management with /agents command - Automatic delegation vs explicit invocation - Resumable agents and chaining - Persistent memory across agent sessions - Background subagents for parallel work - Worktree isolation for safe experimentation - Agent Teams (experimental feature) - Best practices and usage patterns * docs(vi): complete Module 04 Subagents translation Translate all 6 subagent example definitions: - code-reviewer.md: Expert code review specialist - debugger.md: Root cause analysis and debugging - documentation-writer.md: Technical documentation creation - implementation-agent.md: Full-stack feature implementation - secure-reviewer.md: Security-focused code review - test-engineer.md: Comprehensive test coverage Update translation queue progress: - Module 04: 7/7 files (100%) ✅ - Overall: 31/66 files (47%) - Next: Module 05 (MCP) * docs(vi): complete Module 05 MCP translation Translate comprehensive MCP (Model Context Protocol) guide: - Overview and architecture diagrams - Installation methods (HTTP, Stdio, SSE, WebSocket) - OAuth 2.0 authentication support - MCP tool search and dynamic updates - Elicitation and prompt slash commands - Configuration management (local, project, user scopes) - Practical examples (GitHub, Database, Filesystem, Slack MCPs) - MCP vs Memory decision matrix - Code execution approach for solving context bloat - MCPorter runtime reference - Security best practices and troubleshooting Translate 4 MCP configuration JSON examples: - filesystem-mcp.json: File operations - github-mcp.json: GitHub integration - database-mcp.json: SQL queries - multi-mcp.json: Multiple servers configuration Update translation queue progress: - Module 05: 5/5 files (100%) ✅ - Overall: 36/66 files (55%) - Next: Module 06 (Hooks) * docs(vi): complete Module 06 Hooks translation Translate comprehensive Hooks guide: - Overview and architecture - Configuration structure (user, project, local scopes) - Four hook types: command, HTTP, prompt, agent - 25 hook events with matcher patterns - Component-scoped hooks and subagent frontmatter - JSON input/output format and exit codes - Environment variables and best practices - Security considerations and debugging - Installation instructions Copy 9 hook example files (code, no translation needed): - format-code.sh: Auto-format code after write/edit - log-bash.sh: Bash command logging - notify-team.sh: Team notifications - pre-commit.sh: Pre-commit validation - security-scan.sh: Security scanning - validate-prompt.sh: Prompt validation - context-tracker.py: Token usage tracking - context-tracker-tiktoken.py: Accurate token counting Update translation queue progress: - Module 06: 9/9 files (100%) ✅ - Overall: 45/67 files (67%) - Next: Module 07 (Plugins) * docs(vi): complete Module 07 Plugins translation Translate comprehensive Plugins guide: - Overview and architecture diagrams - Plugin loading process and lifecycle - Plugin types (Official, Community, Organization, Personal) - Plugin definition structure and manifest - Plugin structure example with all directories - LSP server configuration and examples - Plugin options (v2.1.83+) with userConfig - Persistent plugin data via CLAUDE_PLUGIN_DATA - Inline plugins via settings (v2.1.80+) - Standalone vs Plugin approach comparison - Practical examples (PR Review, DevOps, Documentation plugins) - Plugin marketplace and distribution - Marketplace configuration and definition schema - Plugin source types and distribution methods - Plugin CLI commands and installation methods - Plugin features comparison table - Testing, hot-reload, and managed settings - Plugin security restrictions - Publishing workflow and best practices - Complete troubleshooting guide Copy all plugin subdirectories (code, no translation needed): - devops-automation/: Deployment workflows, incident management - documentation/: API docs, README generation, templates - pr-review/: Pull request review automation Update translation queue progress: - Module 07: 10+/10+ files (100%) ✅ - Overall: 55+/67 files (82%) - Next: Module 08-10 (Checkpoints, Advanced Features, CLI) * docs(vi): complete Modules 08-10 translation Module 08: Checkpoints and Rewind (2 files) - Overview and architecture - Access methods (keyboard shortcut, slash command) - Five rewind options (restore code+conversation, conversation, code, summarize, cancel) - Automatic checkpoints and retention policies - Use cases and practical examples - Integration with git and best practices Module 09: Advanced Features (3 files) - Planning Mode: Two-phase implementation approach - Extended Thinking: Deep reasoning for complex problems - Auto Mode: Background safety classifier - Background Tasks, Scheduled Tasks - Permission Modes (default, acceptEdits, plan, auto, dontAsk, bypassPermissions) - Print Mode, Session Management - Voice Dictation, Channels, Remote Control - Web Sessions, Desktop App, Task List - Git Worktrees, Sandboxing, Managed Settings Module 10: CLI Reference (1 file) - CLI commands reference - Core flags and options - Interactive vs Print Mode - Model selection and configuration - System prompt customization - Tool & permission management - Output formats and scripting Update translation queue progress: - Modules 08-10: 6/6 files (100%) ✅ - All Modules 01-10: 61+/61+ files (100%) ✅ - Overall: 61+/67 files (91%) - Remaining: Supporting docs (6 files) * docs(vi): complete supporting documentation translation Translate all 5 supporting documents: - CONTRIBUTING.md: Contribution guidelines - SECURITY.md: Security policy and vulnerability reporting - CODE_OF_CONDUCT.md: Community standards and harassment policy - STYLE_GUIDE.md: Documentation formatting conventions - CHANGELOG.md: Version history (v2.2.0, v2.1.1, v2.1.0, v2.0.0) Update translation queue to 100% completion: - All Modules 01-10: 61+ files (100%) ✅ - Supporting Docs: 5/5 files (100%) ✅ - Overall: 67+/67 files (100%) ✅ - Status: HOÀN THÀNH ✅ * fix(vi): fix mermaid syntax and broken cross-references in Vietnamese translation Fix invalid `#` comment in mermaid block (use `%%` instead) and update cross-reference script to support Unicode/Vietnamese diacritics in anchor generation. Fix broken anchor links across vi/ documentation files. * fix(vi): remove inline mermaid comment causing parse error Inline %% comments on node definition lines are not supported by the mermaid parser. The surrounding HTML comment already explains this is an incorrect example.
This commit is contained in:
299
vi/08-checkpoints/README.md
Normal file
299
vi/08-checkpoints/README.md
Normal file
@@ -0,0 +1,299 @@
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="../resources/logos/claude-howto-logo-dark.svg">
|
||||
<img alt="Claude How To" src="../resources/logos/claude-howto-logo.svg">
|
||||
</picture>
|
||||
|
||||
# Checkpoints và Rewind / Checkpoints and Rewind
|
||||
|
||||
Checkpoints cho phép bạn lưu trạng thái hội thoại và quay lại các điểm trước đó trong phiên Claude Code của bạn. Điều này vô giá khi khám phá các cách tiếp cận khác nhau, phục hồi từ sai lầm, hoặc so sánh các giải pháp thay thế.
|
||||
|
||||
## Tổng Quan / Overview
|
||||
|
||||
Checkpoints cho phép bạn lưu trạng thái hội thoại và quay lại các điểm trước đó, cho phép thử nghiệm an toàn và khám phá nhiều cách tiếp cận. Chúng là các snapshot của trạng thái hội thoại của bạn, bao gồm:
|
||||
- Tất cả các trao đổi tin nhắn
|
||||
- Các sửa đổi file được thực hiện
|
||||
- Lịch sử sử dụng công cụ
|
||||
- Ngữ cảnh phiên
|
||||
|
||||
Checkpoints vô giá khi khám phá các cách tiếp cận khác nhau, phục hồi từ sai lầm, hoặc so sánh các giải pháp thay thế.
|
||||
|
||||
## Các Khái Niệm Chính / Key Concepts
|
||||
|
||||
| Khái Niệm | Mô Tả |
|
||||
|---------|-------------|
|
||||
| **Checkpoint** | Snapshot của trạng thái hội thoại bao gồm tin nhắn, files, và ngữ cảnh |
|
||||
| **Rewind** | Quay lại checkpoint trước đó, loại bỏ các thay đổi tiếp theo |
|
||||
| **Điểm Nhánh** | Checkpoint từ đó nhiều cách tiếp cận được khám phá |
|
||||
|
||||
## Truy Cập Checkpoints / Accessing Checkpoints
|
||||
|
||||
Bạn có thể truy cập và quản lý checkpoints theo hai cách chính:
|
||||
|
||||
### Sử Dụng Phím Tắt / Using Keyboard Shortcut
|
||||
Nhấn `Esc` hai lần (`Esc` + `Esc`) để mở giao diện checkpoint và duyệt các checkpoints đã lưu.
|
||||
|
||||
### Sử Dụng Lệnh Slash / Using Slash Command
|
||||
Sử dụng lệnh `/rewind` (bí danh: `/checkpoint`) để truy cập nhanh:
|
||||
|
||||
```bash
|
||||
# Mở giao diện rewind
|
||||
/rewind
|
||||
|
||||
# Hoặc sử dụng bí danh
|
||||
/checkpoint
|
||||
```
|
||||
|
||||
## Các Tùy Chọn Rewind / Rewind Options
|
||||
|
||||
Khi bạn rewind, bạn được trình bày một menu năm tùy chọn:
|
||||
|
||||
1. **Khôi phục code và hội thoại** -- Hoàn nguyên cả files và tin nhắn đến checkpoint đó
|
||||
2. **Khôi phục hội thoại** -- Chỉ rewind tin nhắn, giữ code hiện tại của bạn như-is
|
||||
3. **Khôi phục code** -- Chỉ hoàn nguyên các thay đổi file, giữ toàn bộ lịch sử hội thoại
|
||||
4. **Tóm tắt từ đây** -- Nén hội thoại từ điểm này thành tóm tắt được tạo bởi AI thay vì loại bỏ nó. Các tin nhắn gốc được bảo toàn trong transcript. Bạn có thể tùy chọn cung cấp hướng dẫn để tập trung tóm tắt vào các chủ đề cụ thể.
|
||||
5. **Không sao cả** -- Hủy và quay lại trạng thái hiện tại
|
||||
|
||||
## Checkpoints Tự Động / Automatic Checkpoints
|
||||
|
||||
Claude Code tự động tạo checkpoints cho bạn:
|
||||
|
||||
- **Mọi prompt người dùng** - Một checkpoint mới được tạo với mỗi đầu vào người dùng
|
||||
- **Liên tục** - Checkpoints tồn tại qua các phiên
|
||||
- **Tự động dọn dẹp** - Checkpoints được tự động dọn dẹp sau 30 ngày
|
||||
|
||||
Điều này có nghĩa là bạn luôn có thể rewind đến bất kỳ điểm nào trước đó trong hội thoại của bạn, từ vài phút trước đến nhiều ngày trước.
|
||||
|
||||
## Các Trường Hợp Sử Dụng / Use Cases
|
||||
|
||||
| Kịch Bản | Workflow |
|
||||
|----------|----------|
|
||||
| **Khám Phá Cách Tiếp Cận** | Lưu → Thử A → Lưu → Rewind → Thử B → So Sánh |
|
||||
| **Refactoring An Toàn** | Lưu → Refactor → Test → Nếu fail: Rewind |
|
||||
| **A/B Testing** | Lưu → Thiết Kế A → Lưu → Rewind → Thiết Kế B → So Sánh |
|
||||
| **Phục Hồi Sai Lầm** | Nhận thấy vấn đề → Rewind đến trạng thái tốt cuối |
|
||||
|
||||
## Sử Dụng Checkpoints / Using Checkpoints
|
||||
|
||||
### Xem và Rewind / Viewing and Rewinding
|
||||
|
||||
Nhấn `Esc` hai lần hoặc sử dụng `/rewind` để mở trình duyệt checkpoint. Bạn sẽ thấy danh sách tất cả các checkpoints có sẵn với timestamps. Chọn bất kỳ checkpoint nào để rewind đến trạng thái đó.
|
||||
|
||||
### Chi Tiết Checkpoint / Checkpoint Details
|
||||
|
||||
Mỗi checkpoint hiển thị:
|
||||
- Timestamp khi nó được tạo
|
||||
- Các file đã được sửa đổi
|
||||
- Số lượng tin nhắn trong hội thoại
|
||||
- Các công cụ đã được sử dụng
|
||||
|
||||
## Ví Dụ Thực Tiễn / Practical Examples
|
||||
|
||||
### Ví Dụ 1: Khám Phá Các Cách Tiếp Cận Khác Nhau / Example 1: Exploring Different Approaches
|
||||
|
||||
```
|
||||
User: Hãy thêm một lớp caching vào API
|
||||
|
||||
Claude: Tôi sẽ thêm Redis caching vào các API endpoints của bạn...
|
||||
[Thực hiện thay đổi tại checkpoint A]
|
||||
|
||||
User: Thực ra, hãy thử in-memory caching thay thế
|
||||
|
||||
Claude: Tôi sẽ rewind để khám phá một cách tiếp cận khác...
|
||||
[User nhấn Esc+Esc và rewinds đến checkpoint A]
|
||||
[Triển khai in-memory caching tại checkpoint B]
|
||||
|
||||
User: Bây giờ tôi có thể so sánh cả hai cách tiếp cận
|
||||
```
|
||||
|
||||
### Ví Dụ 2: Phục Hồi Từ Sai Lầm / Example 2: Recovering from Mistakes
|
||||
|
||||
```
|
||||
User: Refactor module xác thực để sử dụng JWT
|
||||
|
||||
Claude: Tôi sẽ refactor module xác thực...
|
||||
[Thực hiện các thay đổi rộng rãi]
|
||||
|
||||
User: Đợi, điều đó làm hỏng tích hợp OAuth. Hãy quay lại.
|
||||
|
||||
Claude: Tôi sẽ giúp bạn rewind đến trước khi refactor...
|
||||
[User nhấn Esc+Esc và chọn checkpoint trước khi refactor]
|
||||
|
||||
User: Hãy thử một cách tiếp cận thận trọng hơn lần này
|
||||
```
|
||||
|
||||
### Ví Dụ 3: Thử Nghiệm An Toàn / Example 3: Safe Experimentation
|
||||
|
||||
```
|
||||
User: Hãy thử viết lại điều này theo phong cách functional
|
||||
[Tạo checkpoint trước khi thử nghiệm]
|
||||
|
||||
Claude: [Thực hiện các thay đổi thử nghiệm]
|
||||
|
||||
User: Các tests đang fail. Hãy rewind.
|
||||
[User nhấn Esc+Esc và rewinds đến checkpoint]
|
||||
|
||||
Claude: Tôi đã rewind các thay đổi. Hãy thử một cách tiếp cận khác.
|
||||
```
|
||||
|
||||
### Ví Dụ 4: Các Cách Tiếp Cận Nhánh / Example 4: Branching Approaches
|
||||
|
||||
```
|
||||
User: Tôi muốn so sánh hai thiết kế database
|
||||
[Lưu ý checkpoint - gọi là "Bắt Đầu"]
|
||||
|
||||
Claude: Tôi sẽ tạo thiết kế đầu tiên...
|
||||
[Triển khai Schema A]
|
||||
|
||||
User: Bây giờ để tôi quay lại và thử cách tiếp cận thứ hai
|
||||
[User nhấn Esc+Esc và rewinds đến "Bắt Đầu"]
|
||||
|
||||
Claude: Bây giờ tôi sẽ triển khai Schema B...
|
||||
[Triển khai Schema B]
|
||||
|
||||
User: Tuyệt! Bây giờ tôi có cả hai schemas để chọn
|
||||
```
|
||||
|
||||
## Giữ Lại Checkpoint / Checkpoint Retention
|
||||
|
||||
Claude Code tự động quản lý checkpoints của bạn:
|
||||
|
||||
- Checkpoints được tạo tự động với mọi prompt người dùng
|
||||
- Checkpoints cũ được giữ lên đến 30 ngày
|
||||
- Checkpoints được tự động dọn dẹp để ngăn chặn tăng trưởng lưu trữ không giới hạn
|
||||
|
||||
## Các Mẫu Workflow / Workflow Patterns
|
||||
|
||||
### Chiến Lược Nhánh Để Khám Phá / Branching Strategy for Exploration
|
||||
|
||||
Khi khám phá nhiều cách tiếp cận:
|
||||
|
||||
```
|
||||
1. Bắt đầu với triển khai ban đầu → Checkpoint A
|
||||
2. Thử Cách Tiếp Cận 1 → Checkpoint B
|
||||
3. Rewind đến Checkpoint A
|
||||
4. Thử Cách Tiếp Cận 2 → Checkpoint C
|
||||
5. So sánh kết quả từ B và C
|
||||
6. Chọn cách tiếp cận tốt nhất và tiếp tục
|
||||
```
|
||||
|
||||
### Mẫu Refactoring An Toàn / Safe Refactoring Pattern
|
||||
|
||||
Khi thực hiện các thay đổi đáng kể:
|
||||
|
||||
```
|
||||
1. Trạng thái hiện tại → Checkpoint (tự động)
|
||||
2. Bắt đầu refactoring
|
||||
3. Chạy tests
|
||||
4. Nếu tests pass → Tiếp tục làm việc
|
||||
5. Nếu tests fail → Rewind và thử cách tiếp cận khác
|
||||
```
|
||||
|
||||
## Thực Hành Tốt Nhất / Best Practices
|
||||
|
||||
Vì checkpoints được tạo tự động, bạn có thể tập trung vào công việc của mình mà không phải lo lắng về việc lưu trạng thái thủ công. Tuy nhiên, hãy ghi nhớ các thực hành sau:
|
||||
|
||||
### Sử Dụng Checkpoints Hiệu Quả / Using Checkpoints Effectively
|
||||
|
||||
✅ **Nên:**
|
||||
- Review các checkpoints có sẵn trước khi rewind
|
||||
- Sử dụng rewind khi bạn muốn khám phá các hướng khác nhau
|
||||
- Giữ checkpoints để so sánh các cách tiếp cận khác nhau
|
||||
- Hiểu những gì mỗi tùy chọn rewind làm (khôi phục code và hội thoại, khôi phục hội thoại, khôi phục code, hoặc tóm tắt)
|
||||
|
||||
❌ **Không Nên:**
|
||||
- Dựa vào checkpoints một mình để bảo toàn code
|
||||
- Mong đợi checkpoints theo dõi các thay đổi file hệ thống file bên ngoài
|
||||
- Sử dụng checkpoints như một thay thế cho git commits
|
||||
|
||||
## Cấu Hình / Configuration
|
||||
|
||||
Bạn có thể bật/tắt checkpoints tự động trong settings của bạn:
|
||||
|
||||
```json
|
||||
{
|
||||
"autoCheckpoint": true
|
||||
}
|
||||
```
|
||||
|
||||
- `autoCheckpoint`: Bật hoặc tắt tạo checkpoint tự động trên mọi prompt người dùng (mặc định: `true`)
|
||||
|
||||
## Hạn Chế / Limitations
|
||||
|
||||
Checkpoints có các hạn chế sau:
|
||||
|
||||
- **Các thay đổi lệnh Bash KHÔNG được theo dõi** - Các thao tác như `rm`, `mv`, `cp` trên hệ thống file không được ghi lại trong checkpoints
|
||||
- **Các thay đổi bên ngoài KHÔNG được theo dõi** - Các thay đổi được thực hiện bên ngoài Claude Code (trong editor của bạn, terminal, v.v.) không được ghi lại
|
||||
- **Không phải thay thế cho kiểm soát phiên bản** - Sử dụng git cho các thay đổi vĩnh viễn, có thể kiểm tra trong codebase của bạn
|
||||
|
||||
## Xử Lý Sự Cố / Troubleshooting
|
||||
|
||||
### Checkpoints Thiếu / Missing Checkpoints
|
||||
|
||||
**Vấn Đề**: Không tìm thấy checkpoint mong đợi
|
||||
|
||||
**Giải Pháp**:
|
||||
- Kiểm tra nếu checkpoints đã bị xóa
|
||||
- Xác minh rằng `autoCheckpoint` được bật trong settings của bạn
|
||||
- Kiểm tra dung lượng đĩa
|
||||
|
||||
### Rewind Thất Bại / Rewind Failed
|
||||
|
||||
**Vấn Đề**: Không thể rewind đến checkpoint
|
||||
|
||||
**Giải Pháp**:
|
||||
- Đảm bảo không có thay đổi chưa commit xung đột
|
||||
- Kiểm tra nếu checkpoint bị hỏng
|
||||
- Thử rewind đến một checkpoint khác
|
||||
|
||||
## Tích Hợp Với Git / Integration with Git
|
||||
|
||||
Checkpoints bổ sung (nhưng không thay thế) git:
|
||||
|
||||
| Tính Năng | Git | Checkpoints |
|
||||
|---------|-----|-------------|
|
||||
| Phạm Vi | Hệ thống file | Hội thoại + files |
|
||||
| Liên Tục | Vĩnh viễn | Dựa trên phiên |
|
||||
| Độ Chi Tiết | Commits | Bất kỳ điểm nào |
|
||||
| Tốc Độ | Chậm hơn | Tức thì |
|
||||
| Chia Sẻ | Có | Có hạn |
|
||||
|
||||
Sử dụng cả hai cùng nhau:
|
||||
1. Sử dụng checkpoints để thử nghiệm nhanh
|
||||
2. Sử dụng git commits cho các thay đổi đã hoàn thiện
|
||||
3. Tạo checkpoint trước các thao tác git
|
||||
4. Commit các trạng thái checkpoint thành công đến git
|
||||
|
||||
## Hướng Dẫn Bắt Đầu Nhanh / Quick Start Guide
|
||||
|
||||
### Workflow Cơ Bản / Basic Workflow
|
||||
|
||||
1. **Làm việc bình thường** - Claude Code tạo checkpoints tự động
|
||||
2. **Muốn quay lại?** - Nhấn `Esc` hai lần hoặc sử dụng `/rewind`
|
||||
3. **Chọn checkpoint** - Chọn từ danh sách để rewind
|
||||
4. **Chọn những gì để khôi phục** - Chọn từ khôi phục code và hội thoại, khôi phục hội thoại, khôi phục code, tóm tắt từ đây, hoặc hủy
|
||||
5. **Tiếp tục làm việc** - Bạn đã trở lại điểm đó
|
||||
|
||||
### Phím Tắt / Keyboard Shortcuts
|
||||
|
||||
- **`Esc` + `Esc`** - Mở trình duyệt checkpoint
|
||||
- **`/rewind`** - Cách thay thế để truy cập checkpoints
|
||||
- **`/checkpoint`** - Bí danh cho `/rewind`
|
||||
|
||||
## Biết Khi Nào Rewind: Giám Sát Ngữ Cảnh / Knowing When to Rewind: Context Monitoring
|
||||
|
||||
Checkpoints cho phép bạn quay lại — nhưng làm thế nào bạn biết *khi* bạn nên? Khi hội thoại của bạn tăng trưởng, cửa sổ ngữ cảnh của Claude được lấp đầy và chất lượng mô hình âm thầm giảm xuống. Bạn có thể đang shipping code từ một mô hình mù quáng một nửa mà không nhận ra.
|
||||
|
||||
**[cc-context-stats](https://github.com/luongnv89/cc-context-stats)** giải quyết điều này bằng cách thêm **vùng ngữ cảnh** thời gian thực vào thanh trạng thái Claude Code của bạn. Nó theo dõi nơi bạn đang ở trong cửa sổ ngữ cảnh — từ **Plan** (xanh lá, an toàn để lập kế hoạch và code) qua **Code** (vàng, tránh bắt đầu các kế hoạch mới) đến **Dump** (cam, hoàn thành và rewind). Khi bạn thấy vùng thay đổi, bạn biết đó là thời gian để checkpoint và bắt đầu tươi mới thay vì đẩy tiếp với đầu ra bị giảm sút.
|
||||
|
||||
## Các Khái Niệm Liên Quan / Related Concepts
|
||||
|
||||
- **[Tính Năng Nâng Cao](../09-advanced-features/)** - Chế độ lập kế hoạch và các khả năng nâng cao khác
|
||||
- **[Quản Lý Memory](../02-memory/)** - Quản lý lịch sử hội thoại và ngữ cảnh
|
||||
- **[Slash Commands](../01-slash-commands/)** - Các phím tắt do người dùng gọi
|
||||
- **[Hooks](../06-hooks/)** - Tự động hóa dựa trên sự kiện
|
||||
- **[Plugins](../07-plugins/)** - Các gói mở rộng được đóng gói
|
||||
|
||||
## Tài Nguyên Thêm / Additional Resources
|
||||
|
||||
- [Tài Liệu Checkpointing Chính Thức](https://code.claude.com/docs/en/checkpointing)
|
||||
- [Hướng Dẫn Tính Năng Nâng Cao](../09-advanced-features/) - Extended thinking và các khả năng khác
|
||||
339
vi/08-checkpoints/checkpoint-examples.md
Normal file
339
vi/08-checkpoints/checkpoint-examples.md
Normal file
@@ -0,0 +1,339 @@
|
||||
# Checkpoint Examples
|
||||
|
||||
Real-world examples of using checkpoints effectively in Claude Code.
|
||||
|
||||
Note: Checkpoints are created automatically with every user prompt. You do not need to manually save them. To rewind, press `Esc` twice (`Esc+Esc`) or use `/rewind` to open the checkpoint browser.
|
||||
|
||||
## Example 1: Database Migration
|
||||
|
||||
### Scenario
|
||||
You need to migrate from MySQL to PostgreSQL but want to explore both a direct migration and a gradual dual-write approach.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: Let's implement a direct migration from MySQL to PostgreSQL
|
||||
[Checkpoint A created automatically]
|
||||
|
||||
Claude: I'll implement the direct migration...
|
||||
[Changes database driver, updates queries, modifies schema]
|
||||
|
||||
User: Run the tests
|
||||
[Checkpoint B created automatically]
|
||||
|
||||
Claude: Running tests...
|
||||
❌ 15 tests failing - connection pool issues
|
||||
|
||||
User: This approach has issues. Let's try the dual-write pattern instead.
|
||||
[User presses Esc+Esc, selects Checkpoint A, chooses "Restore code and conversation"]
|
||||
|
||||
User: Now implement a dual-write pattern where we write to both databases
|
||||
|
||||
Claude: I'll implement dual-write migration...
|
||||
[Implements dual-write layer, gradual migration strategy]
|
||||
|
||||
User: Run the tests
|
||||
|
||||
Claude: Running tests...
|
||||
✅ All tests passing
|
||||
|
||||
User: The dual-write approach is clearly safer. Let's commit this.
|
||||
```
|
||||
|
||||
## Example 2: Performance Optimization
|
||||
|
||||
### Scenario
|
||||
Multiple performance optimization strategies to try.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: Let's optimize the API response time. Current: 450ms
|
||||
[Checkpoint "Baseline" created automatically]
|
||||
|
||||
Claude: I'll add database query caching...
|
||||
[Implements Redis caching]
|
||||
|
||||
User: Run performance tests
|
||||
|
||||
Claude: Results: 280ms average response time (38% improvement)
|
||||
|
||||
User: Let me try a different approach.
|
||||
[User presses Esc+Esc, selects "Baseline" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Try database query optimization instead
|
||||
|
||||
Claude: I'll optimize database queries...
|
||||
[Adds indexes, optimizes N+1 queries]
|
||||
|
||||
User: Run performance tests
|
||||
|
||||
Claude: Results: 180ms average response time (60% improvement)
|
||||
|
||||
User: Let me also try a third approach.
|
||||
[User presses Esc+Esc, selects "Baseline" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Try response compression and CDN
|
||||
|
||||
Claude: I'll add compression and CDN...
|
||||
[Implements gzip, sets up CDN]
|
||||
|
||||
User: Run performance tests
|
||||
|
||||
Claude: Results: 320ms average response time (29% improvement)
|
||||
|
||||
User: Query optimization was the best. Let me go back and combine it with caching.
|
||||
[User presses Esc+Esc, selects the checkpoint after query optimization, chooses "Restore code and conversation"]
|
||||
|
||||
User: Now add Redis caching on top of these optimized queries
|
||||
|
||||
Claude: [Adds Redis caching on top of optimized queries]
|
||||
|
||||
User: Run performance tests
|
||||
|
||||
Claude: Results: 95ms average response time (79% improvement) 🎉
|
||||
|
||||
User: Perfect! This is the winner. Let's commit this.
|
||||
```
|
||||
|
||||
## Example 3: UI/UX Iteration
|
||||
|
||||
### Scenario
|
||||
Trying different layouts for a dashboard.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: Let's redesign the dashboard with a sidebar layout
|
||||
[Checkpoint "Start" created automatically]
|
||||
|
||||
Claude: [Implements sidebar layout]
|
||||
|
||||
User: Show me a screenshot
|
||||
|
||||
Claude: [Shows screenshot]
|
||||
|
||||
User: The sidebar feels cramped. Let's try a top navigation instead.
|
||||
[User presses Esc+Esc, selects "Start" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Try a top navigation layout
|
||||
|
||||
Claude: [Implements top navigation]
|
||||
|
||||
User: Show me a screenshot
|
||||
|
||||
Claude: [Shows screenshot]
|
||||
|
||||
User: Better, but let's try a card-based grid layout
|
||||
[User presses Esc+Esc, selects "Start" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Try a card-based grid layout
|
||||
|
||||
Claude: [Implements card grid]
|
||||
|
||||
User: Show me a screenshot
|
||||
|
||||
Claude: [Shows screenshot]
|
||||
|
||||
User: This is great! But can we combine the top nav with the card grid?
|
||||
[User presses Esc+Esc, selects the checkpoint after the card grid, chooses "Restore code and conversation"]
|
||||
|
||||
User: Add top navigation to the card grid layout
|
||||
|
||||
Claude: [Adds top navigation to card grid]
|
||||
|
||||
User: Perfect! This is the final design.
|
||||
```
|
||||
|
||||
## Example 4: Debugging Session
|
||||
|
||||
### Scenario
|
||||
Hunting down a tricky bug with multiple hypotheses.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: There's a memory leak in the application
|
||||
[Checkpoint "Before debugging" created automatically]
|
||||
|
||||
Claude: Let me investigate...
|
||||
[Analyzes code]
|
||||
|
||||
User: I think it's in the event listeners. Let's fix those.
|
||||
|
||||
Claude: [Fixes event listener cleanup]
|
||||
|
||||
User: Run memory profiler
|
||||
|
||||
Claude: Still leaking memory - event listeners weren't the issue
|
||||
|
||||
User: Let me go back and try a different hypothesis.
|
||||
[User presses Esc+Esc, selects "Before debugging" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Maybe it's the database connections?
|
||||
|
||||
Claude: [Implements connection pooling fixes]
|
||||
|
||||
User: Run memory profiler
|
||||
|
||||
Claude: Still leaking - not the connections either
|
||||
|
||||
User: Let me go back and try another angle.
|
||||
[User presses Esc+Esc, selects "Before debugging" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Let's check for circular references
|
||||
|
||||
Claude: [Finds and fixes circular references in cache]
|
||||
|
||||
User: Run memory profiler
|
||||
|
||||
Claude: ✅ Memory leak fixed! The circular references in the caching layer were the culprit.
|
||||
|
||||
User: Excellent! Let's commit this fix.
|
||||
```
|
||||
|
||||
## Example 5: API Design Evolution
|
||||
|
||||
### Scenario
|
||||
Designing a REST API with multiple iterations.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: Create a REST API for our blog platform
|
||||
[Checkpoint "Before API design" created automatically]
|
||||
|
||||
Claude: [Creates basic CRUD API]
|
||||
|
||||
User: This is too simple. Let's add pagination and filtering
|
||||
|
||||
Claude: [Adds pagination and filtering]
|
||||
|
||||
User: We need better resource relationships
|
||||
|
||||
Claude: [Implements HATEOAS links]
|
||||
|
||||
User: Actually, let's try GraphQL instead of REST
|
||||
[User presses Esc+Esc, selects "Before API design" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Implement a GraphQL API for our blog platform instead
|
||||
|
||||
Claude: [Implements GraphQL API]
|
||||
|
||||
User: I think REST is better for our use case.
|
||||
[User presses Esc+Esc, selects the checkpoint after HATEOAS, chooses "Restore code and conversation"]
|
||||
|
||||
User: Let's finalize the REST approach.
|
||||
```
|
||||
|
||||
## Example 6: Configuration Management
|
||||
|
||||
### Scenario
|
||||
Testing different configuration approaches.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: Move configuration to environment variables
|
||||
[Checkpoint "Original config" created automatically]
|
||||
|
||||
Claude: [Implements env var configuration]
|
||||
|
||||
User: Test in development
|
||||
|
||||
Claude: Works locally but deployment issues in production
|
||||
|
||||
User: Let me try a different approach.
|
||||
[User presses Esc+Esc, selects "Original config" checkpoint, chooses "Restore code and conversation"]
|
||||
|
||||
User: Try a config file approach with validation
|
||||
|
||||
Claude: [Implements YAML config with JSON schema validation]
|
||||
|
||||
User: Test in development
|
||||
|
||||
Claude: ✅ Works well, good validation errors
|
||||
|
||||
User: Can we also support env vars for sensitive values?
|
||||
|
||||
Claude: [Adds env var override for secrets]
|
||||
|
||||
User: Test deployment
|
||||
|
||||
Claude: ✅ All environments working correctly
|
||||
|
||||
User: Perfect! This is production-ready.
|
||||
```
|
||||
|
||||
## Example 7: Test Strategy
|
||||
|
||||
### Scenario
|
||||
Implementing comprehensive testing.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: Add unit tests for the auth module
|
||||
[Checkpoint created automatically]
|
||||
|
||||
Claude: [Adds Jest unit tests]
|
||||
|
||||
User: Run tests
|
||||
|
||||
Claude: 45 tests passing, 78% coverage
|
||||
|
||||
User: Add integration tests too
|
||||
|
||||
Claude: [Adds integration tests]
|
||||
|
||||
User: Run tests
|
||||
|
||||
Claude: 89 tests passing, 92% coverage, but tests are slow (3 minutes)
|
||||
|
||||
User: The tests are too slow. Let's optimize.
|
||||
|
||||
Claude: [Optimizes test setup, adds parallel execution]
|
||||
|
||||
User: Run tests
|
||||
|
||||
Claude: 89 tests passing, 92% coverage, 35 seconds ✅
|
||||
|
||||
User: Great! Now add E2E tests for critical paths
|
||||
|
||||
Claude: [Adds Playwright E2E tests]
|
||||
|
||||
User: Run all tests
|
||||
|
||||
Claude: 112 tests passing, 94% coverage, 2 minutes
|
||||
|
||||
User: Perfect balance of coverage and speed!
|
||||
```
|
||||
|
||||
## Example 8: Using Summarize from Checkpoint
|
||||
|
||||
### Scenario
|
||||
After a long debugging session, you want to condense the conversation while preserving context.
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
User: [After 20+ messages of debugging and exploration]
|
||||
|
||||
[User presses Esc+Esc, selects an early checkpoint, chooses "Summarize from here"]
|
||||
[Optionally provides instructions: "Focus on what we tried and what worked"]
|
||||
|
||||
Claude: [Generates a summary of the conversation from that point forward]
|
||||
[Original messages are preserved in the transcript]
|
||||
[The summary replaces the visible conversation, reducing context window usage]
|
||||
|
||||
User: Now let's continue with the approach that worked.
|
||||
```
|
||||
|
||||
## Key Takeaways
|
||||
|
||||
1. **Checkpoints are automatic**: Every user prompt creates a checkpoint -- no manual saving needed
|
||||
2. **Use Esc+Esc or /rewind**: These are the two ways to access the checkpoint browser
|
||||
3. **Choose the right restore option**: Restore code, conversation, both, or summarize depending on your needs
|
||||
4. **Don't fear experimentation**: Checkpoints make it safe to try radical changes
|
||||
5. **Combine with git**: Use checkpoints for exploration, git for finalized work
|
||||
6. **Summarize long sessions**: Use "Summarize from here" to keep conversations manageable
|
||||
Reference in New Issue
Block a user