ClaudeMods
☰
KO
● 0 명 접속 중 · 조회 0 회
후원프로젝트 제출
GitHub 저장소 · 작성자 ccdwyer

stack-traffic-control

gh stack용 출발 안내판처럼 동작하는 Claude Code mod입니다. `/stack` 창, 프롬프트 위 한 줄 상태 표시, raw force-push·rebase·PR base 편집을 gh stack으로 돌려보내는 Bash 가드를 제공합니다.

번역 완료

이 mod 소개

Stack Traffic Control은 GitHub 공식 stacked-PR 확장 기능인 gh stack을 사용하는 저장소를 위한 Claude Code mod입니다. /stack 명령은 스택을 위에서 아래로 나열하는 창을 엽니다. 각 브랜치의 PR 번호, CI 검사 상태, 준비 완료인지, rebase가 필요한지, 대기 중인지 또는 반영되었는지와 함께 push하지 않은 커밋과 커밋하지 않은 변경을 보여 주고 새로 고침 버튼도 제공합니다. 프롬프트 위의 한 줄 표시기는 스택에서 현재 위치를 보여 주며, stacked branch에 있을 때는 rebase 경고도 표시합니다. 가드 훅은 셸이 해석하는 방식으로 Bash 명령을 검사합니다(인용, 이스케이프, 리디렉션, heredoc, ; && || |, 서브셸, 치환, bash -c와 eval, env/sudo/xargs 같은 래퍼, cd/pushd/git -C 디렉터리 추적). 스택 작업 흐름과 충돌하는 raw 명령은 거부하고 정확한 gh stack 대응 명령을 모델에 보여 줍니다. 보호되는 작업에는 스택 브랜치와 trunk의 force-push 및 삭제, trunk 또는 layer로의 rebase, rebase 또는 merge 방식의 pull, 스택 PR에 대한 gh pr edit --base, 스택 브랜치에 대한 gh pr create가 포함됩니다. 스택 파일을 읽을 수 없거나, 디렉터리 상태를 알 수 없거나, 명령줄을 파싱할 수 없거나, 한 줄에서 브랜치를 전환한 뒤 push하는 경우에는 안전하게 거부합니다. push refspec, push.default, branch.*.rebase, pull.rebase, pull.ff 및 git -c 재정의를 따릅니다. 알려진 제한은 문서화되어 있으며, 샌드박스가 아니라 안전망입니다. GitHub CLI와 gh extension install github/gh-stack가 필요하고, ccdwyer-mods 플러그인 마켓플레이스를 통해 설치합니다.

설치

먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.

claude plugin marketplace add ccdwyer/stack-traffic-control
claude plugin install stack-traffic-control
원문 / README

Stack Traffic Control

Stack Traffic Control demo

The band above the prompt, the /stack departure board, and a raw force-push refused with the gh stack alternative. MP4

A Claude Code mod that acts as a departure board for gh stack, GitHub's official stacked-PR extension.

  • /stack opens a pane listing the stack top to bottom. For each branch it shows the PR number, CI checks (✓ ✗ …), and whether the branch is ready, needs a rebase, is queued or has landed. It also shows unpushed commits (↑, or unpublished for a branch that has never been pushed) and uncommitted changes (✎). A refresh button updates it.

  • Above the prompt, when you're on a stacked branch: 🛫 stack 2/4 · feature-b · 1 needs rebase.

  • Guard. In a repo that uses gh stack, some raw commands are refused, and the model is shown the exact gh stack command to use instead and why. The repo's stack file (<git-common-dir>/gh-stack) decides what is protected: every branch of every stack, and their trunks, are protected from force-pushes and deletes, whichever branch you're on. Rebase, pull and PR rules apply when you're on a stacked branch.

    | Raw command | Use instead | |---|---| | git push --force / -f / --force-with-lease / +refspec / --mirror / glob refspecs / --delete hitting a stack branch | gh stack push, gh stack submit --auto, gh stack sync --prune | | git rebase onto the trunk, a layer or @{u} (also --onto=, or a bare git rebase) | gh stack rebase (--downstack, --upstack, --no-trunk) | | git pull that would rebase or merge (flags and pull.rebase / pull.ff config; fast-forward-only pulls pass) | gh stack sync | | gh pr edit --base on a stack PR | gh stack submit --auto / gh stack modify | | gh pr create for a stack branch | gh stack submit --auto |

    These commands still run, with a note attached for the model:

    • A rebase that stays inside the branch (git rebase -i HEAD~3) runs, with a reminder to follow up with gh stack rebase --upstack.
    • git rebase --continue, --abort and --skip run, with a reminder about the gh stack rebase equivalents.

    These pass untouched:

    • force-pushing tags or unrelated branches
    • PRs whose head isn't a stack branch
    • PRs in another repo (--repo)
    • anything run off a stack

    The guard reads the Bash line the way a shell would. It looks inside:

    • quoting, escapes, line continuations and redirections. Quoted heredoc bodies are data. In unquoted heredocs and redirect targets, $( … ) is checked.
    • ;, &&, || and |
    • subshells ( … ), groups { … }, if/while bodies, and $( … ) / backtick substitutions
    • bash -c '…' and eval
    • wrappers: env, sudo, nohup, time, nice, command, exec, xargs, timeout
    • cd / pushd (including ~ and options), env -C, sudo -D, git -C, --git-dir and --work-tree. A cd inside a pipeline, a background job or an if body is handled the way the shell handles it. It also remembers where the Bash tool's persistent shell is across calls.

    It fails closed in four cases, but only in repos that use gh stack:

    • The stack file can't be checked or read. The command is refused with the reason rather than allowed.
    • A cd leaves the directory unknowable (cd -, cd $X, a cd that may not have run). Git steps are refused until a literal cd settles it.
    • The line can't be read (a substitution as the program, an unbalanced quote) and could push, rebase, pull or edit a PR. It is refused, and the model is asked to run that step as a plain command.
    • A line switches branch and then pushes. It is refused, and the model is asked to split it, because the push can't be checked against a branch it isn't on yet.

    The guard also follows:

    • configured push refspecs (remote.<name>.push, remote.<name>.mirror) and push.default, including upstream
    • branch.<name>.rebase, pull.rebase and pull.ff, plus git -c overrides
    • GIT_DIR / GIT_WORK_TREE prefixes
    • git rebase <upstream> <branch>, which rewrites <branch> whatever HEAD is

    Known limits, as a safety net and not a sandbox:

    • a program name hidden in a variable ($GIT push -f)
    • a script run as bash script.sh / source with no git text on the line
    • git aliases
    • git reset --hard and git merge on a stacked branch, which aren't checked

"Needs rebase" combines gh stack's own flag with a check that each layer contains its parent layer's tip. Repos that have never used gh stack (no stack file) are never looked into further, so the guard costs nothing there.

Requirements

  • GitHub CLI with the stack extension: gh extension install github/gh-stack

Install

/plugin marketplace add ccdwyer/claude-mods
/plugin install stack-traffic-control@ccdwyer-mods
/reload-plugins

Develop

claude plugin validate .
claude plugin test .

What it hooks

Events this mod hooks, as claude plugin validate reads the module:

  • session.start
  • command.run{command=stack}
  • turn.complete
  • tool.call{tool=Bash}
  • ui.render{component=AbovePrompt}
  • ui.render{component=Pane
  • requestId=stack-board}

Engine calls it makes: $.clock.now (via lookAt, stackAt), $.command.register, $.env.get (via shellContext), $.process.run (via run), $.state.get, $.state.set, $.ui.open, $.ui.resolve.

A tool.call hook sits in the middle of every tool call: it can see the call, refuse it, or add context to its result. This mod uses that only for the behaviour described above.

Privacy

It uses your existing GitHub CLI (gh, with the gh stack extension) to read your stack and pull request status from GitHub, under your own account. Nothing is sent anywhere else.

The mod collects no analytics or telemetry, and its author receives no data from it.

Full policy: PRIVACY.md.

License

MIT

비슷한 프로젝트