home / skills / charlesjones-dev / claude-code-plugins-dev / workflow-ship

This skill automates preflight checks, fixes issues, commits, pushes, and creates PRs, streamlining shipping code with minimal interaction.

npx playbooks add skill charlesjones-dev/claude-code-plugins-dev --skill workflow-ship

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.9 KB
---
name: workflow-ship
version: 1.0.0
description: |
  Ship it. Runs preflight checks (typecheck, lint, tests), auto-fixes issues,
  then commits, pushes, and creates a PR. Bails early if preflight fixes were
  needed so you can review before shipping. Prompts for branch and PR target
  using quick multi-choice questions.
allowed-tools:
  - Bash
  - Read
  - Edit
  - Write
  - Grep
  - Glob
  - AskUserQuestion
  - Skill
disable-model-invocation: true
---

# /workflow-ship - Preflight, Commit, Push, PR

You are a shipping assistant. Your job is to get the current branch shipped by running quality checks, committing, pushing, and opening a PR. Use `AskUserQuestion` for all user prompts so the flow is fast with minimal typing.

## Process

### Step 1: Preflight checks

Run the `/workflow-preflight` skill to execute typecheck, lint, and test checks.

If any checks fail:
1. Attempt to auto-fix the issues (lint --fix, format, etc.)
2. Re-run the failing checks to confirm fixes worked
3. If fixes were applied, **STOP HERE** and tell the user:
   - What failed and what was fixed
   - Ask them to review the fixes before shipping
   - Tell them to run `/workflow-ship` again once they're satisfied
4. If fixes fail or issues can't be auto-resolved, **STOP HERE** and report the remaining issues

If all checks pass with no fixes needed, proceed to Step 2.

### Step 2: Branch + Commit

First, determine the current branch:
```bash
git branch --show-current
```

Then run `git status` (never -uall) and `git diff` to understand changes. If there are no changes, tell the user and stop.

**Branch prompt:** Use `AskUserQuestion` to ask the user where to commit:

- If on `main` or `master`: Do NOT allow committing directly. Present options:
  - "Create new branch" (description: "Create a feature/fix branch for these changes")
  - The user picks "Other" to type a custom branch name

- If on any other branch (staging, feature/*, fix/*, etc.): Present options:
  - "Current branch ({branch_name})" (description: "Commit directly to {branch_name}") - mark as first/recommended option
  - "Create new branch" (description: "Create a new branch off {branch_name} for these changes")

If the user chooses "Create new branch" or types a custom name via "Other":
1. Create and checkout the new branch: `git checkout -b <branch_name>`

Then proceed with the commit:
1. Run `git log --oneline -5` to match the repo's commit message style
2. Stage relevant files (prefer specific files over `git add -A`)
3. Draft a concise commit message focused on the "why"
4. Create the commit with the Co-Authored-By trailer:
   ```
   Co-Authored-By: Claude Opus 4.6 <[email protected]>
   ```
5. Use a HEREDOC for the commit message to ensure proper formatting

### Step 3: Push

1. Check if the current branch tracks a remote: `git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null`
2. Push to remote with `-u` flag if no upstream is set, otherwise a normal push
3. Verify the push succeeded

### Step 4: Create PR

First, gather context:
```bash
# Current branch
git branch --show-current

# Check if staging exists on origin
git ls-remote --heads origin staging

# Check if main exists on origin
git ls-remote --heads origin main
```

**PR target prompt:** Use `AskUserQuestion` to ask where the PR should merge into. Build the options dynamically based on what exists:

- If the current branch is `staging`: only offer `main` (and "Other" is always available for custom input)

- If the current branch is anything else (feature/*, fix/*, etc.):
  - If `staging` exists on origin: offer these options:
    - "staging" (description: "Merge into staging for pre-production review") - mark as first/recommended
    - "main" (description: "Merge directly into main/production")
  - If `staging` does NOT exist on origin: offer these options:
    - "main" (description: "Merge into main") - mark as first/recommended

The user can always pick "Other" to type any custom branch name.

Then create the PR:
1. Run `git log <target>..HEAD --oneline` to understand all commits being included
2. Run `git diff <target>...HEAD` to see the full diff
3. Create a PR using `gh pr create` with:
   - `--base <target_branch>` to set the merge target
   - A short title (under 70 characters)
   - A body with Summary bullets and Test plan
   - Use HEREDOC format for the body
   - Include the Claude Code attribution footer

Format:
```
gh pr create --base <target_branch> --title "the pr title" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>

## Test plan
<checklist of testing steps>

šŸ¤– Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
```

4. Return the PR URL to the user

## Important rules

- Always use `AskUserQuestion` for branch and PR target prompts (never assume)
- Never skip preflight checks
- Never force push
- Never commit or push directly to main/master
- If there are no changes to commit, tell the user and stop
- Do not commit files that look like secrets (.env, credentials, etc.)

Overview

This skill automates shipping a branch: it runs preflight checks (typecheck, lint, tests), attempts auto-fixes, then stages, commits, pushes, and opens a PR. It stops early whenever fixes were applied or manual review is required. Branch and PR targets are chosen via fast multi-choice prompts using AskUserQuestion.

How this skill works

It always runs the /workflow-preflight checks first and tries automatic fixes (lint --fix, format, etc.). If fixes changed files, the skill halts and reports what was fixed so you can review before continuing. When checks pass with no pending fixes, it prompts (AskUserQuestion) for commit/branch behavior, creates or uses a branch, crafts a focused commit with a Co-Authored-By trailer, pushes with proper upstream handling, and builds a PR using gh pr create with a structured title and body.

When to use it

  • Before merging or opening a PR to ensure code quality
  • When you want a repeatable preflight + ship flow with minimal typing
  • When you need a quick branch/PR creation guided by repository rules
  • When you want automatic lint/format fixes but want to review changes before shipping

Best practices

  • Never commit secrets — the skill will avoid files that look like credentials (.env, keys).
  • Review auto-fixed changes before re-running the ship flow; the tool will stop after applying fixes.
  • Do not attempt to commit directly to main/master; the prompts prevent it.
  • Prefer staging or feature branches; pick create-new-branch when unsure to keep history clean.
  • Provide a concise commit message focused on why, and include the Co-Authored-By trailer as required.

Example use cases

  • I made a small refactor and want to run typecheck/lint/tests, auto-fix style, and open a PR to staging.
  • I have multiple local changes and want a guided flow to create a feature branch, commit only relevant files, push, and create a PR.
  • CI failed on lint; run this locally to auto-fix formatting, inspect fixes, then re-run shipping once satisfied.
  • You finished a bugfix on a non-main branch and need a quick, consistent PR into main or staging with a test-plan and summary.

FAQ

What happens if preflight fixes change files?

The skill will stop after applying fixes and re-running checks. It reports what failed and what was fixed and asks you to review changes before running the ship flow again.

Can I commit directly to main or master?

No. The flow disallows direct commits to main/master. You must create a new branch or commit to a non-main branch.

How are branch and PR targets chosen?

All branch and PR prompts use AskUserQuestion. Options are tailored to current branch and remote state (origin/staging/main) and always include an Other option for custom names.