stack-summary
Use when you need to audit, analyze, or review stack quality before restructuring. Produces a structured summary with per-commit classification, philosophy audit, and violation flags. Output feeds directly into /stack-plan restructure mode. Use INSTEAD of manual git log inspection.
- License 许可
- Unlicense
- 最近更新
- 2026-11-15
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- stack-summary
- description
- Use when you need to audit, analyze, or review stack quality before restructuring. Produces a structured summary with per-commit classification, philosophy audit, and violation flags. Output feeds directly into /stack-plan restructure mode. Use INSTEAD of manual git log inspection.
- argument-hint
- <range | --root | (none for this worktree's stack)>
- compatibility
- Requires git-branchless
- disable-model-invocation
- false
02 资源文件 2
- 参考文档references/git-branchless.md37 B
- 参考文档references/philosophy.md33 B
03 SKILL.md 正文
Analyze a commit stack and produce a structured report. The output serves two purposes:
- Human review — understand what each commit does at a glance
- Planner input — feed violations directly into
/stack-planrestructure
Pre-flight
-
Load references — read
references/philosophy.md(relative to this skill's directory). -
Confirm repository initialization. A devenv project with
git.branchless.enablerunsgit branchless initon every shell entry. Anywhere else, check and stop if it is missing:git config --get branchless.core.mainBranch >/dev/null || echo "not initialized: ask the user to run git branchless init"Do not run
git branchless inityourself: it rewrites the repository's shared configuration and hooks for every worktree. -
Check for stale rebase state:
ls -d "$(git rev-parse --git-path rebase-merge)" \ "$(git rev-parse --git-path rebase-apply)" 2>/dev/nullIf either exists, run
git rebase --abortbefore proceeding. In a linked worktree.gitis a file, so ask Git for the paths.
Determine Range
Examine $ARGUMENTS to select the commit range:
- If
$ARGUMENTSis a range (main..HEAD,hash..hash) → use it - If
$ARGUMENTSis--root→ use the full history from root to HEAD - If
$ARGUMENTSis empty → use this worktree's own stack ($STACK, below) - If
$STACKis empty (on main, or a fresh worktree) → use full history (--root)
Plain stack() is not the current stack while local main is behind its
upstream, the normal state when worktrees branch from origin/main: it also
holds the upstream commits and every stack another worktree branched from them.
For the same reason, a main..HEAD range holds upstream commits then; use the
fork-point range $(git merge-base "$base" HEAD)..HEAD. See Selecting your
own stack in references/git-branchless.md.
Resolve to BASE and TIP:
# Range:
BASE=<resolved>; TIP=<resolved>
# --root:
BASE=$(git hash-object -t tree /dev/null) # empty tree
TIP=HEAD
# Default, this worktree's stack:
main_branch="$(git config branchless.core.mainBranch || echo main)"
remote="$(git config "branch.${main_branch}.remote" || echo origin)"
base="$(git rev-parse --abbrev-ref "${main_branch}@{upstream}" 2>/dev/null \
|| echo "${remote}/${main_branch}")"
git rev-parse --verify -q "${base}^{commit}" >/dev/null || base="$main_branch"
STACK="descendants(roots((stack() & ::HEAD) - ::$base)) - ::$base"
stack_commits="$(git query -r "$STACK")" || exit 1
test -n "$stack_commits" || { echo "empty stack selection" >&2; exit 1; }
git sl "$STACK" || exit 1
BASE="$(git merge-base "$base" HEAD)" || exit 1
TIP="$(git query -r "heads($STACK)")" || exit 1
test -n "$TIP" || { echo "empty stack heads" >&2; exit 1; }
If TIP has several lines, the stack forks; summarize each head separately.
Every selection and guard must exit 0 and produce the required non-empty value.
Gather Data
For each commit in the range, collect:
# 1. Commit list with messages
git log --oneline --reverse $BASE..$TIP
# 2. Per-commit file stats
git log --reverse --stat --format="=== %h %s ===" $BASE..$TIP
# 3. Total diff stats for verification
git diff --stat $BASE..$TIP
# For --root, use these instead (git log supports --root but git diff doesn't,
# so we diff against the empty-tree hash):
git log --oneline --reverse --root
git log --reverse --stat --format="=== %h %s ===" --root
git diff --stat $(git hash-object -t tree /dev/null) HEAD
For commits flagged during audit (oversized, potentially bundled), read the full diff to understand the content:
git show <hash> --stat
git show <hash> # full diff when needed
Classify Each Commit
For every commit, determine:
-
Type: which concern does it address?
identity— LICENSE, README intro, project setupinstructions— CLAUDE.md, coding standards, conventionsbuild— flake, dependencies, devShell, overlays, lock filesformat— formatters, linters, treefmt, alejandraci— GitHub Actions, CI workflowstooling— editor config, Claude Code settings, steering filesreference— reference docs (philosophy, tool docs)skill— SKILL.md filesintegration— symlinks, routing tables, skill wiringdocs— README sections, installation guides, user-facing docstest— tests, test infrastructurechore— TODO, changelog, metadata
-
Files: list of files created or modified
-
Lines: insertions + deletions (from
--stat) -
Scope: the most specific component name
Audit Against Philosophy
Check each commit against references/philosophy.md rules:
Sizing (§ Sizing Heuristic)
- Flag commits exceeding 200 lines changed
- Flag commits under 50 lines that could merge with adjacent same-concern
Atomic (§ Atomic Commits)
- Flag commits with "and" in the description (may need splitting)
- Flag commits touching unrelated concerns (e.g. build + docs + skill)
- Flag commits that bundle multiple features (e.g. 3 skills in one commit)
Incremental Content (§ Incremental Content)
- Flag README/CLAUDE.md content that appears in a late batch commit instead of with the feature it documents
- Flag doc-only commits whose content belongs with earlier feature commits
- Flag monolithic doc commits (>100 lines of docs added at once)
Dependency Timing (§ Dependency Timing)
- Flag dependencies/config added before they're used
- Flag forward references (commit references something from a later commit)
Ordering (§ Commit Ordering)
- Flag refactoring mixed with feature work
- Flag features before their dependencies
Grouping Opportunities
- Identify adjacent commits with the same type AND scope that could merge
without exceeding 200 lines (e.g., two 30-line
docscommits touching the same file) - Identify commits that are logical continuations (commit N adds a feature, commit N+1 adds docs for that same feature — they belong together)
- Check for "thin wrapper" commits that just wire up something from the previous commit (e.g., a commit that only adds a flake output for a module introduced in the prior commit)
- Don't suggest merging commits that serve different review purposes even if they're small (e.g., a 20-line refactor and a 20-line feature should stay separate for revertibility)
Single-Topic Validation
- For each commit, read the full diff (not just the stat) and verify that every changed line serves the commit message's stated purpose
- Flag commits where the diff contains unrelated changes: a "fix typo" commit that also reformats imports, an "add feature" commit that also cleans up whitespace in unrelated files
- Flag commits where the message says one thing but the diff does another (e.g., message says "refactor" but the diff adds new functionality)
- Use the test: "If I reverted this commit, would only one concern be affected?" If reverting would undo two unrelated things, the commit should be split
History Hygiene (§ History Hygiene)
- Flag "fix", "WIP", "tweaks", "addresses feedback" commits
Produce Output
Format the summary in two sections:
Stack Summary
Stack: <range> (<N> commits, <total lines> lines)
| # | Hash | Message | Type | Files | Lines | Flags |
|---|------|---------|------|-------|-------|-------|
| 1 | abc1234 | chore: initial commit | identity | LICENSE, README.md | 29 | |
| 2 | def5678 | feat(flake): add skeleton | build | flake.nix, ... | 81 | |
| 3 | ghi9012 | feat(skills): add fix, split, test | skill | 3 SKILL.md | 388 | OVERSIZED, BUNDLED |
...
Use these flag labels:
OVERSIZED— exceeds 200 linesUNDERSIZED— single commit under 50 lines that is too small to stand on its ownBUNDLED— multiple features in one commitBATCHED-DOCS— docs that should be distributed to feature commitsFORWARD-REF— references something from a later commitMIXED-CONCERNS— touches unrelated concernsEARLY-DEP— dependency added before first useHYGIENE— fix/WIP/tweaks commit messageMERGEABLE— adjacent commits that are individually reasonable but serve the same concern and could combineOFF-TOPIC— diff contains changes unrelated to the commit message
Violations
For each flagged commit, explain:
### [OVERSIZED] abc1234 feat(skills): add fix, split, test (388 lines)
Three distinct skills bundled into one commit. Each skill is an independent
feature with its own SKILL.md. Should be split into 3 commits (~130 lines
each).
Suggested split:
1. feat(stack-fix): add stack-fix skill — skills/stack-fix/SKILL.md (~182 lines)
2. feat(stack-split): add stack-split skill — skills/stack-split/SKILL.md (~113 lines)
3. feat(stack-test): add stack-test skill — skills/stack-test/SKILL.md (~93 lines)
Grouping Opportunities
If mergeable commits are found, list them:
### Grouping Opportunities
1. Commits 4-5 (docs/install-rewrite + docs/readme-ecosystem-neutral):
both update user-facing docs for the same restructure, combined ~90 lines.
Could merge into one docs commit.
2. Commit 8 (chore: update TODO.md) is 15 lines and only adds checklist
items — could merge with an adjacent metadata commit if one exists.
Only suggest groupings where the merged result would still be a single coherent concern under 200 lines. Don't suggest merging across concern boundaries just because commits are small.
Planner Handoff
If violations are found, end with:
To restructure this stack, run:
/stack-plan restructure <range>
Key changes needed:
- Split commit abc1234 into 3 skill commits
- Distribute README content from xyz7890 to feature commits
- Move CLAUDE.md routing table from ... to skill commits
If no violations are found:
Stack is clean. No restructuring needed.
Tips
- Don't over-flag. A 210-line commit for a single large reference doc is fine — it's one coherent document. Flag the pattern, not the number.
- Bundled commits are the most impactful violation to catch — they affect revertibility and review quality.
- The summary table should be copy-pasteable into a conversation with
/stack-planfor restructuring. - When unsure if content is "batched docs" vs. legitimate cross-cutting packaging docs, note the ambiguity rather than hard-flagging.
--rootmode for tip-only redistribution: when a branch has accumulated experimental commits, pivots, and failed approaches,--rootmode produces the total diff against the empty tree (or use a range likemain..HEADfor the total diff against a base). This output shows the FINAL file state, which is the input for/stack-plan --tip-onlyredistribution. When the majority of commits are flagged withHYGIENE,MIXED-CONCERNS, orOFF-TOPIC, suggest tip-only redistribution in the planner handoff instead of standard restructure.
04 同仓库更多 Skills
stack-test
Use when you need to run tests or formatters across commits in a stack. Use INSTEAD of manual git test run or looping git checkout + test. Prevents: testing every commit when only the tip has to pass, unbounded parallel jobs exhausting memory, cache misunderstandings.
stack-submit
Use when you need to push, submit, or create pull requests for a commit stack. Rebases only the current stack onto upstream main, validates, and pushes INSTEAD of manual git sync + git submit + PR/MR creation. Handles branch creation, stacked PR/MR creation with correct base branches.
stack-split
Use when you need to break up, split, or decompose a large commit into smaller atomic commits. Use INSTEAD of manual git rebase -i + edit or git reset HEAD^. Prevents: non-working intermediate commits, wrong split ordering, missed downstream restack.
stack-plan
Use when you need to plan commits, restructure a stack, or commit uncommitted work as organized atomic commits. Builds a stack from a description, uncommitted work, or existing commits INSTEAD of dumping everything into one monolithic commit with git add -A && git commit, or manual git rebase -i, git reset --soft, or ad-hoc git move sequences. Prevents: wrong commit ordering, forward references, git move -F panics, untested intermediates.
stack-fix
Use when you need to fix, correct, or update content in an earlier commit — line-level edits, content moves, or structural changes. Absorbs staged changes into correct stack commits INSTEAD of running git absorb or git commit --fixup via Bash, or hand-running git prev + edit + git amend + git restack --merge. Prevents: missed dry-run preview, leftover staged changes going unnoticed, forgetting to restack. Falls back to guided manual amend when absorb cannot route hunks.
peer-communication
How to write replies a person reads: answer first, plain words, easy to scan. Load before your first reply in an interactive session.