From bb-spec-workflow
Use when the user wants to push local code to a remote via the PR flow. Auto-detects single / multiple repos; supports batch or selective handling; a repo dir can be passed as an argument. Before pushing, if .bb-spec/docs/spec/INDEX.md exists at the repo or project root, runs a branch-spec self-check (pre-review) — a subagent diffs the current branch vs main against the spec, violations are fixed via /revise and re-reviewed in a loop, then drafts a concise 6-section PR description (background / requirement / approach / result / tests / spec, under 50 lines) used directly as the PR body. TRIGGER — push it / open a PR / ship the code / self-check before a PR / review this branch against the spec. | 用户想把本地代码通过 PR 流程推送到远程仓库。自动检测单 / 多仓库,支持批量或选择性处理;用户也可通过参数指定单个仓库目录。推送前若仓库根或项目根(CWD)存在 `.bb-spec/docs/spec/INDEX.md`,会自动跑一次**分支规范自查(pre-review)**——派 subagent 拿 spec 比对当前分支 vs main 的 diff,违规经 /revise 修复并循环复审,通过后生成一份**简洁的 6 段 PR 描述草稿**(背景 / 需求 / 方案 / 结果 / 测试 / 规范,整体不超过 50 行),直接用作创建 PR 的 body。常见触发:"push 一下"、"提个 PR"、"代码推上去"、"准备发 PR"、"开 PR 之前帮我自查一下"、"对照规范看下这个分支"。
How this skill is triggered — by the user, by Claude, or both
Slash command
/bb-spec-workflow:git-push-prThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
创建分支 → 跑测试 → 提交 → **分支规范自查 + PR 草稿**(仅当仓库或项目根存在 `.bb-spec/docs/spec/INDEX.md`)→ 推送 → 创建 PR → 处理 PR → 清理分支。
创建分支 → 跑测试 → 提交 → 分支规范自查 + PR 草稿(仅当仓库或项目根存在 .bb-spec/docs/spec/INDEX.md)→ 推送 → 创建 PR → 处理 PR → 清理分支。
可附带目录路径指定仓库:/git-push-pr ./my-project。未指定则自动检测当前目录。
Shell 变量名禁区:禁止用 status、path、PATH、SECONDS 等保留名。
git branch --show-current。在 main/master 上 → 必须先创建新分支。已在功能分支 → 继续。
优先级:Makefile test/tests/check/ci/test-all → 项目类型推断(go test ./... / bun test / cargo test / pytest)→ 问用户。
失败:立即停止,报告给用户。用户明确"跳过测试"时才可略过。
git status --short。有改动 → 明确暂存相关文件(禁止 git add .)+ commit。不确定的文件(.env、凭据)必须先问。工作区干净 → 跳过。
两级查找 spec:
.bb-spec.yaml 的 base_dir(默认 .bb-spec),检查 {base_dir}/docs/spec/INDEX.md.bb-spec/docs/spec/INDEX.md任一位置命中 → 以该路径作为 spec 来源进入自查;两处都不存在 → 跳过整个 4.5。
Agent(subagent_type: bb-spec-workflow:pre-reviewer,模型由 agent 定义指定),prompt 传入:
repo_path:仓库绝对路径base_branch:比对基线分支spec_dir:前置探测命中的 spec 目录diff_summary:diff 概况(commit 数、规模、审查重点)审查指令、输出格式(## 结论 PASS|FAIL → ## 违规项 → ## 备注)、只读约束均由 agent 定义自包含。
revise,把本轮全部违规项(file:line + 违反哪条 + 建议修法)作为参数传入;归因诊断、修复、全量测试、本地 commit 由 revise 闭环,禁止绕过 revise 直接改代码 → revise 完成后重新派 subagent 复审 → ≥ 3 轮仍 FAIL → 停下报告分歧## 背景
## 需求
## 方案
## 结果
## 测试
## 规范
直接作为步骤 6 的 --body。
git push -u origin <branch>。失败 → 停止报告。
根据 git remote get-url origin 判断平台(github → gh,gitlab → glab)。
创建后用 AskUserQuestion 让用户选(除非已显式声明):
gh pr merge --squash --auto --delete-branch(GitLab 用 --auto-merge --remove-source-branch)gh pr close --delete-branch → 清理git rebase origin/main:机械性冲突自行解决 + --force-with-lease 重推;业务性冲突停下报告查 PR 状态:MERGED → 清理;OPEN → 提醒用户确认;CLOSED → 提醒用户选择。
git checkout main && git pull origin main
git rev-parse --abbrev-ref HEAD # 9.1 确认在 main
git branch -D <branch> # 9.2 删本地(用 -D,squash 后 -d 会拒绝)
# 9.3 探测远程分支是否存在再删
git ls-remote --exit-code --heads origin <branch> && git push origin --delete <branch>
git fetch -p # 9.4 裁剪远程引用
每个仓库独立执行 2-9(含各自测试和 4.5 自查)。一个失败不影响其他。步骤 7 逐仓库分别询问。
git push --force / git reset --hard / git checkout -- . / 未授权合并 PR / 非 squash 策略 / 提交敏感文件
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub 0xbb2b/bb-spec --plugin bb-spec-workflow