본문으로 건너뛰기
cccskills
무료GitHub에 공개

squash

Review a branch's commits, combine adjacent changes that belong together, and improve commit messages. A rebuilt history is prepared separately and replaces the original branch only after the user reviews and confirms the proposed changes.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Analyze branch commits and consolidate iterative modifications.

설치 방법 보기

이럴 때 유용합니다

  • Combining unpushed commits on the current branch
  • Cleaning up a named branch without checking it out
  • Improving unclear commit messages
  • Reviewing proposed history changes before applying them

포함된 파일(6)

  • SKILL.md6.3 KB
  • scripts/build_history.py16.1 KB
  • scripts/collect_commits.py9.8 KB
  • scripts/format_report.py3.0 KB
  • scripts/replace_branch.py14.2 KB
  • scripts/resolve_scope.py3.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Squash — Consolidate Branch History

Analyzes commits on the current branch and consolidates them into clean, logical units. The original branch is untouched until the user explicitly confirms the result. Heavy git operations are delegated to Python scripts (scripts/ directory) that enforce safety checks.

Instructions

  • NEVER operate on the default branch (main/master).
  • All user-facing text must match the language the user has been using.
  • When presenting choices, use interactive dialogs with selectable options rather than plain text.
  • Scripts are at .codebuddy/skills/squash/scripts/ relative to repo root. Use python3 to run them. NEVER read or modify the script contents.

Cleanup procedure

Whenever stopping due to failure or user discard, extract these values from the latest successful step output (if available), then run:

git worktree remove --force {worktree_path}
git branch -D {tmp_branch}
rm -rf {session_dir}
FieldSource
worktree_pathStep 4 output (on Step 4 failure or Step 5 discard)
tmp_branchStep 4 output (on Step 4 failure or Step 5 discard)
session_dirStep 2 output (on Step 2/3 failure)

If these values cannot be determined (e.g., Step 2 failed before creating session_dir), skip the cleanup that depends on them. Errors during cleanup can be safely ignored—resources will eventually be removed by resolve_scope.py on the next run.


Step 1: Cleanup

If $ARGUMENTS is empty, run:

python3 scripts/resolve_scope.py {repo_dir}

The script validates that the current branch is not the default branch, and cleans up stale sessions from previous runs. If it fails, inform the user and stop.

If $ARGUMENTS is non-empty (a branch name), skip this step — validation is handled by the collect script in Step 2.


Step 2: Collect Commits

Two modes depending on $ARGUMENTS:

  • No argument — squash unpushed commits on the current branch:
    python3 scripts/collect_commits.py {repo_dir}
    
  • Branch name (e.g. /squash feature/foo) — squash the entire named branch (does not require checking it out):
    python3 scripts/collect_commits.py {repo_dir} $ARGUMENTS
    

If the script fails, inform the user and stop.

Record {session_dir} from the output — all temporary files and the worktree will live inside this directory throughout the session.

If commits is empty, inform the user and stop. Present the commit_table field to the user.


Step 3: Analyze & Decide

Use commits (with subject, files, is_merge, quality_flag) and overlaps (adjacent pair file overlap ratios) from Step 2.

Grouping

Group adjacent commits belonging to the same logical change when either:

  1. File overlap ≥ 30 % (from overlaps).
  2. Message similarity — same module/feature keyword, or follow-up pattern.

A "revert" commit should be grouped with the commit it reverts. If both are adjacent, squashing them cancels them out.

Never group across a merge commit. Never include a merge commit in a squash group. Never reorder commits.

Messages

Synthesize a new commit message for each squash group. Rewrite any commit with a non-null quality_flag.

If nothing to merge or rewrite, inform the user the history is clean and stop.

Output — Decision Table

Write to {session_dir}/decision.json:

{
  "session_dir": "...",
  "repo_dir": "...",
  "branch": "...",
  "squash_base": "<full_hash>",
  "squash_end": "<full_hash>",
  "upstream_remote": null,
  "upstream_merge": null,
  "actions": [
    {"type": "keep",   "commits": ["<hash>"]},
    {"type": "squash", "commits": ["<hash1>", "<hash2>"], "message": "..."},
    {"type": "reword", "commits": ["<hash>"], "message": "..."},
    {"type": "merge",  "commits": ["<hash>"]}
  ]
}

Copy session_dir, repo_dir, branch, squash_base, squash_end, upstream_remote, upstream_merge directly from Step 2 output.

Rules: chronological order (oldest first), every commit in exactly one action, full 40-char hashes, squash/reword require message, merge must have exactly one commit, squash must never contain a merge.


Step 4: Build New History

python3 scripts/build_history.py {session_dir}/decision.json

On failure → run cleanup procedure and stop (error output includes worktree_path and tmp_branch).

On success, parse the JSON output and record {worktree_path}, {tmp_branch}, and {current_head} from it. The script automatically handles any commits added after squash_end — no manual git operations needed.


Step 5: User Confirmation

Mandatory interaction point. Do NOT skip.

python3 scripts/format_report.py {session_dir}/decision.json

Present the report (showing planned changes), then ask: Confirm / Discard. Wait for response.

Note: The reported "new commit count" in the format report is an estimate based on the decision table. The actual count after execution (which accounts for zero-diff groups being skipped) will be shown in Step 6 results.

Discard → run cleanup procedure and stop.


Step 6: Replace Branch

Write {session_dir}/replace.json using values from prior steps, then run:

python3 scripts/replace_branch.py {session_dir}/replace.json
FieldSource
repo_dirStep 2 output
branchStep 2 output (branch field — may be a non-current branch)
tmp_branchStep 4 output
worktree_pathStep 4 output
current_headStep 4 output
upstream_remoteStep 2 output
upstream_mergeStep 2 output

The script automatically appends any new commits added since {current_head}, verifies tree equality, and atomically updates the branch ref. On success it removes the worktree and tmp branch.

On failure → run cleanup procedure and stop.

On success:

rm -rf {session_dir}

Report using new_commit_count from Step 4 output (which accounts for commits skipped due to zero-diff groups):

Squash complete: {original_commit_count} commits → {new_commit_count} commits


Step 7: Offer to Push

If the branch has upstream tracking and the remote tracking point is an ancestor of the new HEAD, ask: Push / Skip.

Otherwise, end silently.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Accept screenshot baseline changes by running the project's dedicated script, then commit the updated version.json using the project's commit conventions. This provides an explicit command for recording changes to the screenshot comparison baseline.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Accepting changes to a screenshot comparison baseline
  • Committing the updated baseline version.json
  • Running the baseline acceptance procedure with an explicit command
Tencent/libpag5.8천2026년 10월 19일 업데이트

commit

무료

Commit local changes to the current Git branch with a message based on the project's conventions. When staged and unstaged changes coexist, choose which to include. The skill does not push changes or create pull requests.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Saving local work as a commit
  • Committing only changes already staged
  • Staging and committing all local changes
Tencent/libpag5.8천2026년 10월 19일 업데이트

cr

무료

Review local branches, pull requests, commits, or files and address issues. The skill selects a single-agent or multi-agent workflow based on the environment, with automatic fixes for lower-risk issues and confirmation for high-risk changes.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Reviewing changes on a local branch
  • Starting a pull request review from its number or URL
  • Checking a specific commit or file
Tencent/libpag5.8천2026년 10월 19일 업데이트

pagx

무료

Create PAGX vector graphics files from a visual description, HTML file, or public URL, including supported animations. Edit existing designs, check their appearance, and export them to SVG, HTML, or PPTX.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating a poster or product card from a written description
  • Converting an HTML file or public URL to PAGX
  • Making an animated banner or loading animation
Tencent/libpag5.8천2026년 10월 19일 업데이트

pr

무료

Commit and push local changes, then create a pull request or update an existing one based on the branch state. The skill prepares commit messages and new pull request details from the changes being submitted.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Creating a pull request from local changes
  • Adding changes to an existing pull request
  • Choosing staged changes or all changes for a commit
Tencent/libpag5.8천2026년 10월 19일 업데이트

Tencent의 스킬 모두 보기

이 스킬의 문제 신고