arh-pr-workflow Skill
Expert guidance for arh CLI — Uber's PR and feature branch management tool.
Create Claude task list using TaskCreate for all items below. Mark tasks complete via TaskUpdate as you go.
- - [ ] Parse user request (which arh operation?)
- [ ] Detect environment (Uber production repo?)
- [ ] Execute requested operation
- [ ] Verify result
- [ ] Report outcome
Branch Naming & Commit Templates
See references/uber-commit-template.md for branch naming convention, commit template format, and PR metadata gathering.
Initial Setup
CODEBLOCK0
Opens browser for GitHub authorization. Select all needed orgs (e.g., uber-code, uber-objectconfig). GitHub username must end with _UBER suffix.
Core Capabilities
1. Creating Feature Branches
Create a new feature branch from main:
CODEBLOCK1
Create a stacked feature (branch off current feature):
CODEBLOCK2
Create feature with specific parent:
CODEBLOCK3
2. Publishing Pull Requests
Publish PR for current feature:
CODEBLOCK4
Publish entire feature stack (root to leaf):
CODEBLOCK5
Publish without interactive prompts (auto-apply lint fixes):
CODEBLOCK6
Publish as draft PR:
CODEBLOCK7
Publish with auto-merge enabled:
CODEBLOCK8
Publish with combined flags:
CODEBLOCK9
3. Viewing PR Status
View feature tree:
CODEBLOCK10
View feature tree with PR status:
CODEBLOCK11
View with commit history (ahead/behind status):
CODEBLOCK12
4. Merging Pull Requests
Merge current feature and all ancestors:
CODEBLOCK13
How it works:
- - If on branch A (main -> C -> B -> A), merges A, B, and C
- If on branch B, merges B and C
- Requires all checks to pass (Builds, Required Approvers)
- Merges ancestors first, then current branch
5. Navigating Features
Checkout existing feature:
CODEBLOCK14
Checkout PR from URL (v0.0.38+):
CODEBLOCK15
This fetches the PR branch from remote and sets up upstream tracking.
Navigate feature stack:
CODEBLOCK16
6. Rebasing Features
Rebase current feature tree to latest parent:
CODEBLOCK17
Pull and rebase from default branch:
arh pull -r
This pulls latest changes from origin main and rebases the entire feature stack.
Important for go-code monorepo: After any git pull or arh pull, always run:
CODEBLOCK19
Rebase to new parent:
CODEBLOCK20
Rebase specific feature:
CODEBLOCK21
Rebase entire stack:
CODEBLOCK22
Rebase subtree:
CODEBLOCK23
Rebase all features:
CODEBLOCK24
7. Discarding Features
Discard a feature branch:
CODEBLOCK25
Important: This deletes both local and remote branches. Any PRs open from this branch will be closed.
Discard local only (keep remote):
CODEBLOCK26
Use --skip-remote when checking out someone else's PR branch that you want to discard locally.
8. Cleaning Up Merged Features
Clean up merged/closed feature branches:
CODEBLOCK27
Clean up without prompts:
CODEBLOCK28
How it works:
- - Lists all closed/merged features
- Asks for confirmation to discard
- Updates upstream tracking for dependent branches
- Example: main -> A -> B -> C, if B is closed, tidy discards B and updates C's parent to A
9. Running Quality Checks
Run linters on changed files:
CODEBLOCK29
Run tests on changed files:
CODEBLOCK30
10. Version Management
Check arh version:
CODEBLOCK31
Common Workflows
- - New feature:
arh feature NAME -> commit -> INLINECODE5 - Stacked PRs:
arh feature NAME -> commit -> arh feature next NAME2 -> commit -> INLINECODE8 - Update after review: commit fixes -> INLINECODE9
- Merge stack:
arh checkout last -> arh merge -> INLINECODE12 - Rebase on main:
arh rebase or arh rebase --all, then INLINECODE15
Troubleshooting
PR publish fails due to lint errors:
CODEBLOCK32
Skip pre-push coverage check (/opt/uber/etc/custom-hooks/coverage-check.sh):
arh publish --no-coverage # Skip coverage via wrapper (preferred)
SKIP_COVERAGE=1 arh publish # Skip coverage via env var
COVERAGE_THRESHOLD=70 arh publish # Lower threshold (default: 80%)
The
--no-coverage flag is handled by an
arh() shell wrapper in
~/.aliases that creates a marker file (
/tmp/.skip-coverage-$(id -u)) consumed by the pre-push hook.
Aliases:
arh-nc (no coverage),
arh-lc (lower threshold) — also in
~/.aliases.
Feature tree is messy:
CODEBLOCK34
Cannot merge due to failing checks:
- - Check build status: INLINECODE24
- Ensure all required approvals are received
- Verify all builds are passing
- Fix issues and update PR: INLINECODE25
Tips
- - Always create features with
arh feature for proper parent tracking - Use
arh -s frequently to monitor PR status - Use
--no-interactive in automated/CI contexts - Use
--changes-planned for WIP/draft PRs - Run
arh tidy regularly to keep feature tree clean - Use
--full-stack for dependent changes - go-code monorepo: After
git pull or arh pull, MUST run INLINECODE34
arh-pr-workflow 技能
arh CLI(Uber 的 PR 和功能分支管理工具)的专家指南。
使用 TaskCreate 为以下所有项目创建 Claude 任务列表。在操作过程中通过 TaskUpdate 标记任务完成。
- - [ ] 解析用户请求(哪个 arh 操作?)
- [ ] 检测环境(Uber 生产仓库?)
- [ ] 执行请求的操作
- [ ] 验证结果
- [ ] 报告结果
分支命名与提交模板
有关分支命名约定、提交模板格式和 PR 元数据收集,请参阅 references/uber-commit-template.md。
初始设置
bash
arh auth
打开浏览器进行 GitHub 授权。选择所有需要的组织(例如 uber-code、uber-objectconfig)。GitHub 用户名必须以 _UBER 后缀结尾。
核心功能
1. 创建功能分支
从主分支创建新功能分支:
bash
arh feature
创建堆叠功能(从当前功能分支创建子分支):
bash
arh feature next
使用特定父分支创建功能:
bash
arh feature --parent
2. 发布拉取请求
为当前功能发布 PR:
bash
arh publish
发布整个功能堆栈(从根到叶):
bash
arh publish --full-stack
无交互提示发布(自动应用 lint 修复):
bash
arh publish --no-interactive
发布为草稿 PR:
bash
arh publish --changes-planned
启用自动合并发布:
bash
arh publish --auto-merge
使用组合标志发布:
bash
arh publish --no-interactive --apply-fixes
arh publish --full-stack --changes-planned
3. 查看 PR 状态
查看功能树:
bash
arh log -p
查看带有 PR 状态的功能树:
bash
arh log -s
或
arh -s
查看提交历史(领先/落后状态):
bash
arh log -c
或
arh -c
4. 合并拉取请求
合并当前功能及其所有祖先:
bash
arh merge
工作原理:
- - 如果在分支 A 上(main -> C -> B -> A),则合并 A、B 和 C
- 如果在分支 B 上,则合并 B 和 C
- 要求所有检查通过(构建、必需审批人)
- 先合并祖先,再合并当前分支
5. 导航功能
检出已有功能:
bash
arh checkout
或
arh co
从 URL 检出 PR(v0.0.38+):
bash
arh checkout https://github.com/uber-code/go-code/pull/11960
或
arh checkout uber-code/go-code/pull/11960
或
arh checkout 11960
或
arh checkout username/feature-name
这将从远程获取 PR 分支并设置上游跟踪。
导航功能堆栈:
bash
arh checkout next # 树中的下一个功能
arh checkout prev # 树中的上一个功能
arh checkout first # 树中的第一个功能
arh checkout last # 树中的最后一个功能
6. 变基功能
将当前功能树变基到最新父分支:
bash
arh rebase
从默认分支拉取并变基:
bash
arh pull -r
这将从 origin main 拉取最新更改并变基整个功能堆栈。
go-code 单仓库重要提示: 在任何 git pull 或 arh pull 之后,始终运行:
bash
git-bzl refresh
变基到新父分支:
bash
arh rebase --parent
变基特定功能:
bash
arh rebase --feature
变基整个堆栈:
bash
arh rebase --base
变基子树:
bash
arh rebase --subtree
变基所有功能:
bash
arh rebase --all
7. 丢弃功能
丢弃功能分支:
bash
arh discard -f
重要提示: 这将删除本地和远程分支。从此分支打开的任何 PR 都将被关闭。
仅丢弃本地(保留远程):
bash
arh discard --skip-remote -f
在检出他人想要在本地丢弃的 PR 分支时使用 --skip-remote。
8. 清理已合并功能
清理已合并/关闭的功能分支:
bash
arh tidy
无提示清理:
bash
arh tidy --no-interactive
工作原理:
- - 列出所有已关闭/已合并的功能
- 请求确认是否丢弃
- 更新依赖分支的上游跟踪
- 示例:main -> A -> B -> C,如果 B 已关闭,tidy 会丢弃 B 并将 C 的父分支更新为 A
9. 运行质量检查
对更改的文件运行 linter:
bash
arh lint
对更改的文件运行测试:
bash
arh test
10. 版本管理
检查 arh 版本:
bash
arh version
或
arh -v
常见工作流程
- - 新功能:arh feature NAME -> 提交 -> arh publish
- 堆叠 PR:arh feature NAME -> 提交 -> arh feature next NAME2 -> 提交 -> arh publish --full-stack
- 审查后更新:提交修复 -> arh publish --no-interactive
- 合并堆栈:arh checkout last -> arh merge -> arh tidy
- 在主分支上变基:arh rebase 或 arh rebase --all,然后 arh publish --no-interactive
故障排除
PR 发布因 lint 错误失败:
bash
arh publish --apply-fixes # 自动应用 lint 修复
跳过推送前覆盖率检查(/opt/uber/etc/custom-hooks/coverage-check.sh):
bash
arh publish --no-coverage # 通过包装器跳过覆盖率(推荐)
SKIP_COVERAGE=1 arh publish # 通过环境变量跳过覆盖率
COVERAGE_THRESHOLD=70 arh publish # 降低阈值(默认:80%)
--no-coverage 标志由 ~/.aliases 中的 arh() shell 包装器处理,该包装器创建一个由推送前钩子使用的标记文件(/tmp/.skip-coverage-$(id -u))。
别名:arh-nc(无覆盖率)、arh-lc(降低阈值)——也在 ~/.aliases 中。
功能树混乱:
bash
arh -s # 检查状态
arh tidy # 清理已合并功能
arh rebase --all # 变基所有内容
由于检查失败无法合并:
- - 检查构建状态:arh -s
- 确保已收到所有必需的审批
- 验证所有构建是否通过
- 修复问题并更新 PR:arh publish
提示
- - 始终使用 arh feature 创建功能以进行正确的父分支跟踪
- 经常使用 arh -s 监控 PR 状态
- 在自动化/CI 环境中使用 --no-interactive
- 对 WIP/草稿 PR 使用 --changes-planned
- 定期运行 arh tidy 以保持功能树整洁
- 对依赖更改使用 --full-stack
- go-code 单仓库: 在 git pull 或 arh pull 之后,必须运行 git-bzl refresh