Skip to content
Back to skills

Watch Branch

ASecurity

Watch a GitHub branch for new commits using the gh-watch extension. Use when the user wants to be notified when new commits are pushed to a branch, monitor main for merges, or track branch activity.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 26, 2026
toolsbashgit

Works with

  • cli

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add justincampbell/gh-watch --skill watch-branch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Watch Branch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Watch Branch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/justincampbell-watch-branch/badge)](https://www.skillsdirectory.com/skills/justincampbell-watch-branch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: watch-branch
description: Watch a GitHub branch for new commits using the gh-watch extension. Use when the user wants to be notified when new commits are pushed to a branch, monitor main for merges, or track branch activity.
argument-hint: "<branch-name>"
---

# Watch a Branch

Monitor a branch for new commits using the `gh watch` CLI extension. It polls GitHub and emits one JSON event per line to stdout when the branch tip changes, which makes it a natural fit for the **Monitor tool** — each event arrives in the conversation as a notification.

## Prerequisites

Check if the extension is installed:

```
gh watch --help
```

If not installed:

```
gh extension install justincampbell/gh-watch
```

## Usage

Run with the **Monitor tool** (not `Bash` with `run_in_background`). The first notification is the `initial-state` snapshot; subsequent notifications are `new-commit` events as they land.

**Wait for the next commit on main, then exit:**

- `command`: `gh watch branch $ARGUMENTS --exit-on new-commit`
- `description`: `New commits on $ARGUMENTS`
- `persistent`: `false`
- `timeout_ms`: `3600000` (1 hour — raise/lower based on how long you're willing to wait)

**Watch the branch for the rest of the session** (every new commit reported as it lands):

- `command`: `gh watch branch $ARGUMENTS`
- `description`: `Commits on $ARGUMENTS`
- `persistent`: `true` (no timeout — stop with `TaskStop` or end of session)

## Flags

| Flag | Description | Default |
|------|-------------|---------|
| `--interval <duration>` | Polling interval | `60s` |
| `--exit` | Exit after any state change | `false` |
| `--exit-on <events>` | Exit after specific event types (comma-separated) | |

## Event types

| Event | Description |
|-------|-------------|
| `initial-state` | Snapshot of the branch tip at the moment watching started (always emitted first) |
| `new-commit` | A new commit was pushed to the branch |

## Output format

One JSON object per line on stdout. The **first line is always `initial-state`** — a snapshot of the branch at the moment watching began:

```json
{"timestamp":"...","event":"initial-state","summary":"Branch main at abc1234: Latest commit message","details":{"branch":"main","sha":"abc1234...","message_headline":"Latest commit message","author":"octocat"}}
```

Subsequent lines are change events:

```json
{"timestamp":"...","event":"new-commit","summary":"New commit on main: def5678 Add feature","details":{"branch":"main","sha":"def5678...","previous_sha":"abc1234...","message_headline":"Add feature","author":"octocat"}}
```

## Interpreting the output

**The first notification is always `initial-state`.** Report it to the user immediately — tell them the current branch tip (SHA, commit message, author). Don't just say "watching in background."

**Subsequent `new-commit` notifications** are full JSON events with the new SHA, message, author, and previous SHA — surface each one as it lands.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.