safe-editing
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSafe Editing
安全编辑
Use Git worktree to isolate AI-driven changes from the main working directory.
使用Git worktree将AI生成的修改与主工作目录隔离开来。
Trigger Conditions
触发条件
Activate this skill when:
- AI is about to make its first code modification in the current session
- User explicitly requests safe/isolated editing
- Starting a new feature implementation or bug fix
在以下场景中启用此技能:
- AI即将在当前会话中首次修改代码
- 用户明确要求进行安全/隔离编辑
- 开始新功能实现或Bug修复
Workflow
工作流程
1. Check Current State
1. 检查当前状态
bash
git rev-parse --show-toplevel
git worktree list
git status --porcelainVerify:
- In a Git repository
- No uncommitted changes in main directory
- Not already in a worktree
If uncommitted changes exist, ask user how to proceed (stash, commit, or abort).
bash
git rev-parse --show-toplevel
git worktree list
git status --porcelain验证以下内容:
- 当前处于Git仓库中
- 主目录中没有未提交的修改
- 未处于已有的worktree中
如果存在未提交的修改,请询问用户如何处理(暂存、提交或终止操作)。
2. Determine Branch Name
2. 确定分支名称
Analyze the task and generate a branch name:
| Task Type | Branch Format | Example |
|---|---|---|
| New feature | | |
| Bug fix | | |
| Refactor | | |
| Docs | | |
- Use lowercase kebab-case
- Translate Japanese to English
- Keep concise but descriptive
分析任务并生成分支名称:
| 任务类型 | 分支格式 | 示例 |
|---|---|---|
| 新功能 | | |
| Bug修复 | | |
| 重构 | | |
| 文档 | | |
- 使用小写短横线分隔格式(kebab-case)
- 日语内容需转换为英文
- 保持简洁且具有描述性
3. Create Worktree
3. 创建Worktree
Use the alias (defined in ):
gwt.zshrcbash
gwt <branch-name>This creates:
- New branch:
<branch-name> - Worktree at:
../git-worktrees/<repo-name>-<branch-name>
使用中定义的别名:
.zshrcgwtbash
gwt <branch-name>此命令会创建:
- 新分支:
<branch-name> - Worktree目录:
../git-worktrees/<repo-name>-<branch-name>
4. Navigate to Worktree
4. 切换到Worktree
bash
cd ../git-worktrees/<repo-name>-<branch-name>Confirm the switch:
bash
pwd
git branch --show-currentbash
cd ../git-worktrees/<repo-name>-<branch-name>确认已切换:
bash
pwd
git branch --show-current5. Perform Changes
5. 执行修改
Execute the requested modifications in the worktree directory. All file edits, creations, and deletions happen here.
在Worktree目录中执行请求的修改操作。所有文件编辑、创建和删除都在此处进行。
6. Commit, Push, and Create PR
6. 提交、推送并创建PR
Use the skill to:
commit-push-pr- Stage and commit changes
- Push to remote
- Create pull request
使用技能完成以下操作:
commit-push-pr- 暂存并提交修改
- 推送到远程仓库
- 创建Pull Request(PR)
7. Cleanup (After PR Merge)
7. 清理(PR合并后)
Once the PR is merged, clean up the worktree:
bash
cd <original-repo-path>
gwtr ../git-worktrees/<repo-name>-<branch-name>当PR合并完成后,清理Worktree:
bash
cd <original-repo-path>
gwtr ../git-worktrees/<repo-name>-<branch-name>Quick Reference
快速参考
| Alias | Command | Purpose |
|---|---|---|
| | Create worktree |
| | List worktrees |
| | Remove worktree |
| 别名 | 命令 | 用途 |
|---|---|---|
| | 创建Worktree |
| | 列出所有Worktree |
| | 删除Worktree |
Notes
注意事项
- Always confirm with user before creating worktree
- If worktree already exists for the task, reuse it
- Keep main directory clean for other work
- 创建Worktree前务必与用户确认
- 如果针对当前任务的Worktree已存在,请复用它
- 保持主目录整洁,以便进行其他工作