Branch Doctor: Git, Test, CI & PR Health Check
Run a comprehensive diagnostic health check of the current branch before opening a PR, requesting review, or merging.
The 5-Point Health Check
When invoked, execute the diagnostic script or perform the 5 checks:
uv run {SKILLS_DIR}/branch-doctor/scripts/doctor.py
1. Working Tree Health
- Inspect
git status --porcelain and git diff --stat.
- Verify whether there are unstaged changes, untracked debris, or unresolved merge conflicts.
- Ensure only intentional files are modified.
2. Git History & Conventional Commits Sanity
3. Local Test Ladder Execution
- Detect the project's local test runner in this order of precedence:
justfile $\rightarrow$ just test (or just fast-fail)
Makefile $\rightarrow$ make test
pyproject.toml / uv.lock $\rightarrow$ uv run pytest
Cargo.toml $\rightarrow$ cargo test
package.json $\rightarrow$ npm test
go.mod $\rightarrow$ go test ./...
- Execute the test suite, confirm exit code is 0, and note the test count and duration.
4. GitHub Actions CI Status
- Check the status of remote GitHub Actions workflows for the current branch:
gh run list --branch "$(git rev-parse --abbrev-ref HEAD)" --limit 3 --json databaseId,name,status,conclusion,url
- Check for any
failure, startup_failure (permissions blocks), or ongoing runs.
5. Pull Request Well-Formedness
- Check whether an open PR exists for the branch:
gh pr view --json number,title,body,state,mergeable,reviewDecision,url
- If PR exists, audit against quality gates:
- Title: Must follow Conventional Commits (
feat(auth): add OAuth2 provider).
- Body Content: Must not be blank; must detail what, why, and verification proof.
- Issue References: Must link related tickets or issues (
Fixes #123, Resolves #456, or Jira ticket keys).
- Template Conformance: Check against
.github/PULL_REQUEST_TEMPLATE.md (or .github/pull_request_template.md). Verify sections are completed without unedited template placeholders.
- Mergeability: Confirm no merge conflicts (
mergeable: MERGEABLE).
- If PR does NOT exist:
- Provide a ready-to-use PR title and summary generated from the branch commits.
Output Format
# 🏥 Branch Doctor Report
- **Branch:** `feat/auth-token-validation` (base: `origin/main`)
- **Overall Status:** ✅ HEALTHY / ⚠️ WARNINGS / ❌ UNHEALTHY
## Diagnostic Checks
| Check | Status | Details |
|---|---|---|
| **Working Tree** | ✅ Clean | 0 unstaged, 0 untracked |
| **Commit History** | ✅ Sane | 3 commits, all valid Conventional Commits |
| **Local Tests** | ✅ Passing | 42 passed in 1.4s via `make test` |
| **GitHub CI** | ✅ Passing | All 3 workflow runs successful |
| **Pull Request** | ⚠️ Attention | PR #104 missing linked issue reference |
## Findings & Action Items
1. **Pull Request:** Add `Fixes #<issue>` to PR description before requesting review.
1---2name: branch-doctor3description: Comprehensive health check for the current git branch. Diagnoses working tree cleanliness, validates git history against Conventional Commits, executes local tests, checks GitHub Actions CI runs, and audits Pull Request well-formedness against PR templates and issue linking standards. Triggers on: 'doctor', 'branch health', 'check branch', 'pre-flight check', 'PR health check'.4---56# Branch Doctor: Git, Test, CI & PR Health Check78Run a comprehensive diagnostic health check of the current branch before opening a PR, requesting review, or merging.910---1112## The 5-Point Health Check1314When invoked, execute the diagnostic script or perform the 5 checks:1516```bash17uv run {SKILLS_DIR}/branch-doctor/scripts/doctor.py18```1920### 1. Working Tree Health21- Inspect `git status --porcelain` and `git diff --stat`.22- Verify whether there are unstaged changes, untracked debris, or unresolved merge conflicts.23- Ensure only intentional files are modified.2425### 2. Git History & Conventional Commits Sanity26- Check all commits on the branch since branching from base (`git log origin/main..HEAD --oneline`).27- Validate that every commit message strictly adheres to the Conventional Commits format:28 ```29 <type>(<optional scope>): <imperative subject>30 ```31- Reject WIP commits (`wip`, `temp`, `fixup!`, `squash!`, bare merge commits).32- Confirm commits adhere to the Atomic Commit Protocol (ACP): complete, self-contained units with corresponding tests.3334### 3. Local Test Ladder Execution35- Detect the project's local test runner in this order of precedence:36 - `justfile` $\rightarrow$ `just test` (or `just fast-fail`)37 - `Makefile` $\rightarrow$ `make test`38 - `pyproject.toml` / `uv.lock` $\rightarrow$ `uv run pytest`39 - `Cargo.toml` $\rightarrow$ `cargo test`40 - `package.json` $\rightarrow$ `npm test`41 - `go.mod` $\rightarrow$ `go test ./...`42- Execute the test suite, confirm exit code is 0, and note the test count and duration.4344### 4. GitHub Actions CI Status45- Check the status of remote GitHub Actions workflows for the current branch:46 ```bash47 gh run list --branch "$(git rev-parse --abbrev-ref HEAD)" --limit 3 --json databaseId,name,status,conclusion,url48 ```49- Check for any `failure`, `startup_failure` (permissions blocks), or ongoing runs.5051### 5. Pull Request Well-Formedness52- Check whether an open PR exists for the branch:53 ```bash54 gh pr view --json number,title,body,state,mergeable,reviewDecision,url55 ```56- If PR exists, audit against quality gates:57 - **Title:** Must follow Conventional Commits (`feat(auth): add OAuth2 provider`).58 - **Body Content:** Must not be blank; must detail *what*, *why*, and verification proof.59 - **Issue References:** Must link related tickets or issues (`Fixes #123`, `Resolves #456`, or Jira ticket keys).60 - **Template Conformance:** Check against `.github/PULL_REQUEST_TEMPLATE.md` (or `.github/pull_request_template.md`). Verify sections are completed without unedited template placeholders.61 - **Mergeability:** Confirm no merge conflicts (`mergeable: MERGEABLE`).62- If PR does NOT exist:63 - Provide a ready-to-use PR title and summary generated from the branch commits.6465---6667## Output Format6869```markdown70# 🏥 Branch Doctor Report7172- **Branch:** `feat/auth-token-validation` (base: `origin/main`)73- **Overall Status:** ✅ HEALTHY / ⚠️ WARNINGS / ❌ UNHEALTHY7475## Diagnostic Checks7677| Check | Status | Details |78|---|---|---|79| **Working Tree** | ✅ Clean | 0 unstaged, 0 untracked |80| **Commit History** | ✅ Sane | 3 commits, all valid Conventional Commits |81| **Local Tests** | ✅ Passing | 42 passed in 1.4s via `make test` |82| **GitHub CI** | ✅ Passing | All 3 workflow runs successful |83| **Pull Request** | ⚠️ Attention | PR #104 missing linked issue reference |8485## Findings & Action Items861. **Pull Request:** Add `Fixes #<issue>` to PR description before requesting review.87```