Back/Operations/Claude/GitHub Copilot
AdvancedOperations

Automate Your Git and Deployment Workflow with a Custom AI Command

Turn a local prototype into a shareable pull request with one `/deploy` command that handles prerequisites, branch creation, checks, GitHub setup, and CI repair in a visible loop.

Automate Your Git and Deployment Workflow with a Custom AI Command

Brian’s `/deploy` command checks GitHub prerequisites, creates a branch and PR, opens it in the browser, and keeps fixing CI failures until the selected checks pass.

Before you start

What you need

  • A local Git repository with changes
  • GitHub CLI and repository access
  • Known local and CI checks
  • A branch and pull request naming convention

What you’ll make

A pushed branch and open pull request whose required checks pass and whose URL opens in the browser.

Tools used

Step by step

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

5 steps

Step01

Build the Custom `/deploy` Command

Define a /deploy command that takes the current working changes from local repository to a shareable pull request. Tell it which local and CI checks matter and what success must look like.

Example prompt
/deploy --checks "typecheck, lint, test, preview"

The goal is to abstract away the complexity of Git for team members who are less familiar with the command line, empowering them to deploy their own work.

Step02

Add Prerequisite Checks

Before touching Git history, confirm that GitHub CLI is installed and authenticated, the repository has a remote, and the working tree changes belong in the deployment. Return setup guidance for any missing prerequisite.

Step03

Automate Branch Management and PR Creation

If the current branch is the default branch, create a descriptive feature branch. Review the diff, run local checks, stage the intended files, write a useful commit, and push the branch.

Example prompt
Review the current diff, create a descriptive feature branch if needed, run the configured local checks, stage only the intended files, write a conventional commit message that explains the change, and push the branch.
Step04

Create the Pull Request and Open in Browser

Create the pull request with the GitHub CLI and open its URL in the default browser. Include the purpose, implementation, validation, and any known limitations in the description.

Step05

Implement CI Monitoring with Self-Healing

Poll the selected CI checks every 30 to 60 seconds. For a failure, read its log, make the smallest relevant correction, rerun the matching local check, push, and continue. Stop when all named checks pass or report the unresolved blocker.

Example prompt
Monitor the required checks on this pull request. If one fails, read the failure log, identify the root cause, make the smallest relevant fix, run the matching local check, and push. Continue until every named check passes. Do not report success while a required check is pending or failed.

What good looks like

  • The command never pushes changes directly to the default branch.
  • Local checks run before the first push.
  • The pull request opens automatically in the browser.
  • Selected CI checks pass or the command reports the unresolved failure.

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

After the steps

Runbook notes

How to recover when the loop fails and where human judgment helps.

Recover

If it goes sideways

GitHub CLI is missing or unauthenticated
Detect the prerequisite before changing Git state and walk the user through installation or login.
The command starts on the default branch
Create and switch to a descriptive feature branch before staging or committing any file.
CI fails after the push
Read the failed check log, make the smallest fix, rerun the relevant local check, push, and continue monitoring.
The agent reports success before checks finish
Query the specific required check states and stop only when each is complete and successful.

Start shipping
better products.

Join 100,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start
No credit card
SOC 2 certified
Enterprise ready