본문으로 건너뛰기
cccskills
무료GitHub에 공개한국어 소개

cleanup-git-worktrees

Git worktree와 로컬 브랜치를 점검해 병합되었거나 오래된 항목 등 정리 후보를 분류합니다. 수정 내용이나 푸시되지 않은 커밋은 검토 대상으로 표시하고, 승인된 정리와 사후 점검을 안내합니다.

원문원문 설명 보기

Use for stale-worktree, Git registration and branch audits. Managed removal uses the repo lifecycle.

lobehub/lobehub스타 83,502(GitHub 83,502 + cccskills 0)

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • 오래된 worktree 정리
  • 병합된 브랜치 확인
  • 푸시하지 않은 작업 보호
  • 정리 후 상태 확인

한국어 소개

할 수 있는 일

이 스킬은 Git worktree와 로컬 브랜치를 점검하고, 삭제 후보와 수동 확인이 필요한 항목, 보호할 항목으로 나눕니다. 병합 여부, PR 상태, 마지막 업데이트 이후 경과 일수, 푸시되지 않은 커밋, 작업 트리의 변경 사항을 확인하고 각 항목이 삭제 후보인 이유를 설명합니다. 후보를 검토한 뒤 지정한 대상만 정리하고, 다시 점검해 삭제 결과와 남은 작업을 보고하는 흐름을 안내합니다.

이럴 때 유용합니다

오랫동안 사용하지 않은 worktree를 정리하거나 PR 병합 후 로컬 브랜치를 정돈할 때 사용할 수 있습니다. 수정된 파일이나 푸시되지 않은 커밋을 검토할 수 있도록 보존할 작업과 삭제 후보를 구분합니다. 저장소에서 worktree와 함께 서비스나 다른 자원도 관리한다면 별도의 수명 주기 절차가 필요할 수 있다는 점도 확인할 수 있습니다.

사용 예시

  • “이 저장소의 worktree를 점검하고 삭제 후보와 보호 대상을 이유와 함께 정리해 주세요.”
  • “병합된 PR 브랜치를 확인하고, 푸시되지 않은 작업이 남은 항목은 따로 분류해 주세요.”
  • “승인한 브랜치를 정리한 뒤 결과 상태를 보고해 주세요.”

주의 사항

점검에는 포함된 scripts/cleanup.sh를 사용합니다. 인증된 gh CLI로 PR 상태를 조회할 수 있습니다. 삭제는 되돌리기 어려운 작업으로 다루며, 대상이 명시되지 않으면 먼저 후보를 제시하고 승인을 받습니다. 등록된 worktree에는 재귀 삭제를 사용하지 않습니다. 잘못된 등록으로 남은 디렉터리를 삭제하려면 경로를 지정하고 확인해야 합니다.

이 소개문은 공개된 SKILL.md를 바탕으로 AI(OpenAI Codex)가 작성했습니다. 정확한 사양은 아래 원문을 확인하세요.

문서 점검

AI가 SKILL.md의 내용에서 주의가 필요한 작업과 도입 전제를 확인했습니다. 점수는 실제로 실행한 결과(실행 검증)만으로 매깁니다.

안전성전송·삭제·명령 실행 등을 명시하고 있는가
B일부 부족삭제 전 승인을 요구하지만, 저장소 정책은 수정된 병합 또는 종료 PR 브랜치도 삭제하도록 허용합니다.
도입의 용이성필요한 도구나 API 키가 적고 적혀 있는가
B일부 부족포함된 스크립트가 필요하며 PR 조회에는 인증된 `gh` CLI를 사용합니다.

점수에는 넣지 않았습니다. 2026년 10월 26일 기준으로 AI(OpenAI Codex)가 판정했습니다. 참고용이므로 설치 전에 원문도 확인해 주세요.

평가가 다르다고 생각되면 재검토를 요청하기

어느 항목이 왜 다르다고 생각하는지 적어 주세요. 로그인은 필요 없습니다. SKILL.md와 대조해 평가를 다시 만들고 이곳에 반영합니다.

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

포함된 파일(3)

  • SKILL.md10.9 KB
  • agents/openai.yaml241 B
  • scripts/cleanup.sh11.4 KB

SKILL.md(원문)

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

Cleanup Git Worktrees

Use the bundled script to make classification deterministic. Treat cleanup as a destructive action: audit first, show the exact candidates grouped by why they are deletable, and obtain one explicit approval before applying deletion unless the user's current request already names the exact targets. Aim for a single approval round-trip, not a per-item Q&A.

Workflow

  1. Run the audit from any worktree in the repository:

    bash .agents/skills/cleanup-git-worktrees/scripts/cleanup.sh audit --fetch --gh --stale-days 15 --base origin/canary
    
    • --fetch: prune the remote first. Omit only when offline and say so.
    • --gh: look up each branch's PR (number, state, head SHA) with the gh CLI. This is what turns [gone] into a verified merge; use it whenever gh is authenticated. It costs roughly one second per branch, so run it in the background on large repos.
    • --stale-days N: mark clean branches idle longer than N days with nothing unpushed as candidate-stale. The repository default the user has approved is 15 days.
    • --noise REGEX: untracked paths that never count as dirt (default node_modules|\.goal-tracing/).
  2. Interpret classifications:

    ClassificationMeaningAction
    protected-branchmain, canary, or the base refnever
    protect-currentthe worktree running the commandnever
    protect-dirtytracked modifications, or untracked files outside the noise regexkeep; list the files
    candidate-mergedtip is an ancestor of the basedelete
    candidate-pr-mergedPR state MERGED and local tip == PR head SHAdelete
    candidate-pr-closedPR CLOSED and tip == PR head or nothing unpusheddelete
    candidate-goneupstream pruned and nothing unpusheddelete after confirming PR state
    candidate-staleolder than --stale-days, clean, nothing unpusheddelete
    review-pr-merged-aheadPR merged but local tip has extra commitscheck the extra commits by subject (below)
    review-gone-unpushedupstream pruned but local-only commits existkeep; deleting loses work
    review-no-upstreamno upstream, not mergedkeep unless the user names it
    review-detacheddetached HEAD worktreekeep; show its dirty files
    broken-registration(...)registration whose gitdir is gonesee below
    activeeverything elsekeep

    Columns worth reading: dirty (real dirt), noise (ignorable untracked), age_days, unpushed (commits no remote ref reaches), pr / pr_state / tip_eq_pr.

  3. Present one compact table split into three groups: deletable now (all candidate-*), needs a manual check (review-*), and protected. Keep candidate-merged separate from candidate-gone, and never describe [gone] alone as proof of merge.

  4. After approval, use the repository's worktree lifecycle workflow when it manages services or other resources alongside a checkout; the Git-only script does not tear those down. For plain Git worktrees, pass exact branch names and the same classification flags used for the audit:

    bash .agents/skills/cleanup-git-worktrees/scripts/cleanup.sh clean \
      --gh --stale-days 15 --base origin/canary \
      --branch feat/example \
      --branch fix/example \
      --apply
    

    Without --apply, cleanup is a dry run. The script re-classifies every target immediately before deletion and refuses anything that is not candidate-*. Worktrees whose only dirt is noise are removed with git worktree remove --force; everything else uses the plain, refusing form.

    Removing a worktree that still holds node_modules can take several minutes each. Run large batches in the background and report progress rather than waiting on a single foreground call.

  5. Run the audit again and report:

    • removed worktrees and branches, with the SHA each branch pointed at (the script prints it; reflog keeps it for 90 days);
    • retained dirty / unpushed / detached targets and why;
    • remaining worktree and local-branch counts;
    • any partial deletion or Git error.

Proving a merge

Squash and rebase merges leave no ancestry, so git merge-base --is-ancestor and git cherry say "not merged" for branches whose PR landed. Use this ladder instead:

  1. --gh reports pr_state=MERGED and tip_eq_pr=eq: the local tip is exactly what GitHub merged. Done.
  2. review-pr-merged-ahead (tip moved past the PR head): list the extra commits with git log <pr-head>..<branch> and search the base for each subject: git log origin/canary --oneline -F --grep="<subject>". A hit on the PR's squash commit means the commit was part of the PR. A miss means the commit is unmerged; check which live branch still contains it with git branch --contains <sha> before deleting.
  3. Branches named after a PR (pr-18412, codex/pr-18497-fix) are local review copies; verify the PR by number with gh pr view N --json state,headRefOid and compare subjects as above.
  4. Do not judge by git diff origin/canary <branch> -- <files>: on an old branch the diff is dominated by later changes on the base.

Zero unpushed means every local commit is reachable from some remote ref, so deleting the local branch loses nothing even when the PR is still OPEN; the user has approved deleting such branches once they pass the stale threshold.

Repo-approved deletion policy

The repository owner has approved the following for this repo, so a cleanup run does not need to re-ask per item. It is the sanctioned exception to the safety rules below; state it in the report and say plainly whenever uncommitted work is being discarded.

  • Dirt equal to the base is not dirt. A tracked file listed as modified whose content is byte-identical to the base (git diff --quiet <base> -- <file>) is stale residue of a branch that is simply behind. When presenting, do not count it as a real change: list such files in their own group so the genuine modifications stay visible.
  • Merged / closed PR branches are disposable together with their local commits. When a branch's PR is MERGED or CLOSED, its worktree and local branch may be removed even when unpushed > 0 or the tree is dirty. Record every branch SHA before deleting (reflog keeps them ~90 days) and state in the report that uncommitted edits are not recoverable.
  • Local scratch does not block removal. Untracked *.probe.test.ts, spike scripts under scripts/, and untracked screenshots (*.png) are disposable; do not raise them as blockers.
  • Still never delete: main, canary, the base ref, and the worktree running the command. A branch whose PR is OPEN is kept while it still holds local-only work (dirty files or unpushed > 0); a clean, fully-pushed branch with an open PR is the redundant local copy the stale rule already covers.

Proving a merge when the repo squash-merges. This repo squash-merges, so a landed PR leaves the squash commit on the base but none of the branch's own commits. Searching the base for an individual commit subject therefore fails for every squashed branch — do not read that as "unmerged". Decide review-pr-merged-ahead by the PR's state plus commit dates instead: if the branch tip is not newer than mergedAt, the branch is pure pre-merge history whose content is already on the base (verify the PR's mergeCommit with git merge-base --is-ancestor <mergeCommit> origin/canary). Only commits dated after mergedAt are candidate unmerged work — keep the branch and list them.

The bundled script still refuses anything outside candidate-*, so these removals are done manually: wt_path=$(git worktree list --porcelain …) → record git rev-parse <branch> → git worktree remove --force → git branch -D. Keep the run in the background; removals that hold node_modules take minutes each.

Broken registrations

git worktree list --porcelain marks an entry prunable when its gitdir file points nowhere (typically after a partial removal). The audit reports these as broken-registration(directory-present|missing; reason) instead of crashing on them.

  • git worktree prune drops only the registration. It never touches the directory or the branch, so it is safe to run before re-auditing.
  • A leftover directory has no .git, so its dirty state cannot be checked. Show its size and file count and ask before deleting it with rm -rf; that is the one place recursive deletion is acceptable, and only on a path the user named.

Safety rules

  • Never discard dirty worktrees merely because their branch is merged, [gone], or old; noise-only dirt (the --noise regex) does not count. The one exception is a worktree whose branch's PR is MERGED or CLOSED, per the repo-approved deletion policy above.
  • Never delete a branch with unpushed > 0 through this script; list it and let the user decide. Same exception: a MERGED/CLOSED PR branch may be removed under the owner's standing approval, with its SHA recorded first.
  • Never use recursive deletion on a registered worktree. If Git partially removes a directory, stop and inspect the exact path before deciding how to recover.
  • Never delete main, canary, or the base branch.
  • Preserve unrelated user changes and concurrent worktrees. The user's other sessions may be working in them.
  • When writing ad-hoc verification loops, run them under bash, not the interactive zsh: zsh does not word-split $var in for/argument positions, so file lists collapse into one argument and checks silently pass.

Script

Use scripts/cleanup.sh; do not recreate its parsing and guard logic ad hoc unless the repository layout makes it unusable. It is set -euo pipefail; helper functions that pipe through grep wrap it in || true so an empty match is "clean", not an abort.

리뷰

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

댓글

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

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

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

0 / 1,000자

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

같은 저장소의 스킬

acceptance

무료요약 있음

실제 제품을 적절한 조작 환경에서 실행해 변경 사항을 검증하고, 사용자가 확인할 수 있는 증거를 모아 인수 보고서로 게시합니다. 기존 검증 계획을 확인하거나 점검 항목을 만들고, `lh` CLI로 결과를 게시할 수 있습니다.

  • 변경된 제품 동작을 실제로 확인하기
  • 스크린샷 등 검증 증거 수집하기
  • 검증 계획과 보고서 작성하기
lobehub/lobehub8.4만2026년 10월 26일 업데이트

add-model-provider

무료요약 있음

LobeHub에 AI 모델 제공자를 추가하는 과정을 안내합니다. 런타임 연동, 모델 정보와 설정, 브랜드 표시, 문서화 및 인수 확인을 다루며, 기존 제공자에 모델만 추가하는 경우와 새 연동이 필요한 경우를 구분합니다.

  • LobeHub에 새 AI 모델 제공자 추가하기
  • 제공자의 설정 안내나 설명 갱신하기
  • 모델 추가에 새 제공자 연동이 필요한지 판단하기
lobehub/lobehub8.4만2026년 10월 26일 업데이트

add-setting-env

무료요약 있음

서버 환경 변수로 사용자 설정의 기본값을 지정하도록 구현하는 절차를 안내합니다. 변수 검증, 서버 설정 구성, 사용자 저장소 반영부터 예시 환경 파일과 셀프 호스팅 문서 갱신까지 다룹니다.

  • 환경 변수로 사용자 설정 기본값 지정
  • 설정을 서버 구성과 사용자 저장소에 연결
  • 환경 변수 예시와 문서 갱신
lobehub/lobehub8.4만2026년 10월 26일 업데이트

agent-runtime-hooks

무료요약 있음

에이전트 실행 단계, 도구 호출, 사람의 승인, 컨텍스트 압축, 하위 에이전트 호출에 훅을 등록하는 방법을 안내합니다. 이벤트를 관찰하고 로컬 도구 결과를 모의하거나 설정에 따라 웹훅으로 도구 호출을 허용 또는 거부할 수 있습니다.

  • 에이전트 단계와 오류 기록
  • 테스트 중 도구 결과 모의
  • 웹훅으로 도구 호출 허용 또는 거부
lobehub/lobehub8.4만2026년 10월 26일 업데이트

agent-signal

무료요약 있음

에이전트의 이벤트 기반 백그라운드 작업을 설계하고 구현하도록 돕습니다. 소스, 시그널, 액션, 정책의 역할을 나누고 비동기 처리, 중복 실행 방지, 완료 기록과 관측 기능을 다룹니다.

  • 이벤트로 시작되는 백그라운드 작업 추가
  • 대화 요청과 작업을 분리
  • 액션의 중복 실행 방지
lobehub/lobehub8.4만2026년 10월 26일 업데이트

agent-testing-bot

무료요약 있음

실제 데스크톱 채팅 앱에서 봇 채널의 인수 테스트를 진행합니다. Discord, Slack, Telegram, WeChat, Lark, QQ에서 메시지를 보내고 응답을 기다린 뒤 결과 화면을 캡처합니다. iMessage는 BlueBubbles 브리지를 사용합니다.

  • 실제 Discord 채널에서 봇 응답 확인하기
  • Slack이나 Telegram 대화 경로 테스트하기
  • macOS 앱의 작업 결과 화면으로 기록하기
lobehub/lobehub8.4만2026년 10월 26일 업데이트

lobehub의 스킬 모두 보기

이 스킬의 문제 신고