Automatically handles Branch creation → Commit → Push → PR creation. The Branch concept is hidden from the user and explained as a "safe workspace".
Execution Order
Step 1: Collect State in Parallel
Run the following commands in parallel :
git rev-parse --is-inside-work-tree # .git 존재 확인
git symbolic-ref --short HEAD # 현재 branch (detached HEAD 감지)
git status --porcelain # 변경 파일 목록
git rev-list --count @{u}..HEAD 2>/dev/null || git rev-list --count HEAD 2>/dev/null # 올리지 않은 commit 수 (upstream 없으면 전체 commit 수로 대체)
git remote get-url origin 2>/dev/null # 원격 저장소 URL
gh auth status 2>&1 # GitHub CLI 로그인 상태
Step 2: Safety Check
.gitNone: "This isn't a Git project folder. Please set it up first with 'start Git'." → Abort- Detached HEAD: "You've moved away from a safe location. I'll return automatically." →
git checkout main(or master) and retry - No remote repository: "Not connected to GitHub. Please set it up first with 'start Git'." → Abort
- gh not logged in: "You're not logged in to GitHub CLI. Please set it up with 'start Git'." → Abort
- Merge Conflict (
UU,AA, etc. detected): Conflict resolution guidance (see the "Conflict Resolution" section below) → Abort - Determine changes: Check both of the following two conditions:
git status --porcelainresult (whether modified files exist)git rev-list --count @{u}..HEADresult (whether unpushed commits exist; if upstream is not set, substitute the total commit count)- If both are empty: "There are no changed files and no unsaved saves. Please modify a file and try again." → Abort
- If there are no modified files but there are unsent commits: proceed with the PR using the already saved content (skip commit in Step 5)
- Already on a branch other than main/master: Proceed as-is on the current branch (skip new branch creation)
Step 3: Request Work Description
Let's create a review request (PR). You know the "suggest edits" mode in Google Docs, right? It's like leaving the original as-is and sending it with "How about changing it like this?"
EXECUTE: Immediately call the AskUserQuestion tool with the JSON below:
{
"questions": [{
"question": "어떤 작업을 했는지 한 줄로 적어주세요.",
"header": "작업 설명",
"options": [
{"label": "직접 입력", "description": "Other에 작업 설명을 입력해주세요 (예: '메인 페이지 디자인 변경', '오타 수정')"},
{"label": "자동 생성", "description": "변경 내용을 분석해서 설명을 자동으로 만들어요"}
],
"multiSelect": false
}]
}
Step 4: Create Branch (Hidden from User)
Create a new branch only if the current branch is main or master:
git checkout -b {slug}/{date}
Branch naming rules:
- Slugify the user input: "Change main page design" →
main-page-design - Add date:
main-page-design/0222 - Briefly convert Korean to English or romanize it
To the user: "I've created a safe workspace. Here you can edit freely without affecting the original."
When moving already saved (committed) content to a new branch:
If it's already committed on main, after creating the branch you need to revert the commit on main.
For the number of unsent commits, use the git rev-list --count result collected in Step 1:
git checkout -b {slug}/{date} # 새 branch 생성 (commit 포함)
git checkout main # main으로 잠시 돌아감
git reset --soft HEAD~{미전송 commit 수} # main의 commit 되돌림 (staging area에 남음)
git checkout {slug}/{date} # 다시 작업 branch로
Note: During this process, the existing individual commit messages are combined into one (squash effect). For non-developers, this actually provides a cleaner result, so it is intended behavior.
Step 5: Commit + Push
Commit only if there are modified files (skip if already saved):
git add -A # 수정된 파일이 있을 때만
git commit -m "사용자가 입력한 작업 설명" # 수정된 파일이 있을 때만
git push origin HEAD
Step 6: Create PR
gh pr create --title "사용자가 입력한 작업 설명" --body "$(cat <<'EOF'
## 변경 내용
{사용자가 입력한 작업 설명}
---
Created by 바르다 깃선생
EOF
)"
Step 7: Return to main
After creating the PR, automatically return to the main branch:
git checkout main
Step 8: Print receipt
검토 요청 완료!
링크: https://github.com/username/my-project/pull/1
이 링크를 팀원에게 보내면, 변경 내용을 확인하고
"좋아요, 반영해주세요" 하고 승인할 수 있어요.
지금은 원래 위치(main)로 돌아온 상태예요.
새로운 작업을 시작하려면 파일을 수정한 뒤 "저장해줘"라고 하세요.
If already on a separate branch
If the current branch in Step 2 is not main/master:
- Skip Step 4 (branch creation)
- Proceed directly from the current branch to commit → push → PR creation
- "Since you're already in the workspace, I'll create the review request right away."
Resolve conflicts
When a Merge Conflict is detected, EXECUTE: immediately call the AskUserQuestion tool with the JSON below:
{
"questions": [{
"question": "두 사람이 같은 파일의 같은 부분을 동시에 고쳐서 충돌이 생겼어요. 어떻게 할까요?",
"header": "충돌 해결",
"options": [
{"label": "내가 수정한 걸로 유지", "description": "내 변경 내용을 사용해요"},
{"label": "상대방이 수정한 걸로 유지", "description": "상대방의 변경 내용을 사용해요"}
],
"multiSelect": false
}]
}
Depending on the choice:
- "Keep mine":
git checkout --ours {파일}→git add {파일} - "Keep theirs":
git checkout --theirs {파일}→git add {파일}
If there are multiple conflicted files, show the file list and process them in bulk.
Error handling
- PR already exists: "A review request for this workspace already exists." → Provide the existing PR URL
- push failed: Provide guidance the same as the upload skill's error handling
- gh pr create failed: "Failed to create the review request." →
gh auth statusguidance to recheck