# Commit

> Stage, commit, push, open a PR, and merge to main. Use ONLY on explicit commit intent — user says "commit", "ship it", "push this", "open a PR", "merge to main", "let's commit this", or prefixes with `/commit`. Do NOT auto-invoke on vague end-of-task phrases ("we're done", "wrap up") — those require explicit confirmation first. Runs the standard commit-PR-merge cycle; never force-pushes or skips hooks.

- Skill: `ipea/commit-2` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ipea/commit-2`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ipea/commit-2/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: ipea (https://skillmd.com/u/ipea)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/ipea/commit-2

---


# Commit, PR, and Merge

Stage changes, verify quality gates, commit with a descriptive message, create a PR, and merge to main.

## Steps

### Step 0: Verification Gate (Pre-Commit)

**Run before branching.**

```bash
Rscript scripts/verify_pipeline.R
```

- **Any check FAIL:** halt and report the findings with their numbers. The user either fixes them
  or explicitly overrides ("commit anyway" / "skip the gate"); record the override reason in the
  commit body.
- **Any check SKIP:** report which checks did not run and why. A skip is not a pass — say so
  before proceeding.
- **All PASS:** continue.

For changes touching interpolation, aggregation, or geometry, also spawn the **verifier** agent
(`Task` with `subagent_type=verifier`) and report its findings before committing.

### Step 0b: Scope check (Pre-Commit)

**Runs unconditionally.** Confirm the diff contains only what this task was meant to change:

```bash
git status --short
git diff --stat
```

- No `data_raw/` contents, no `_targets/` object files, no `.Rproj.user/`
- No unrelated reformatting — if `air format` touched files this task did not otherwise change,
  unstage them
- No absolute machine paths introduced: `git diff -U0 | grep -nE '^\+.*(C:[\/]Users|/home/|L:[\/]Proj)'`
  must return nothing

Halt on any hit and report it. Do not proceed past this gate on "commit anyway" — an accidental
data blob or a machine path in the pipeline is exactly what it exists to catch.

### Step 1: Check current state

```bash
git status
git diff --stat
git log --oneline -5
```

### Step 2: Create a branch

```bash
git checkout -b <short-descriptive-branch-name>
```

### Step 3: Stage files

Add specific files (never use `git add -A`):

```bash
git add <file1> <file2> ...
```

Do NOT stage `.claude/settings.local.json` or any files containing secrets.

### Step 4: Commit with a descriptive message

If `$ARGUMENTS` is provided, use it as the commit message. Otherwise, analyze the staged changes and write a message that explains *why*, not just *what*.

```bash
git commit -m "$(cat <<'EOF'
<commit message here>
EOF
)"
```

### Step 5: Push and create PR

```bash
git push -u origin <branch-name>
gh pr create --title "<short title>" --body "$(cat <<'EOF'
## Summary
<1-3 bullet points>

## Test plan
<checklist>

🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
```

### Step 6: Merge and clean up

```bash
gh pr merge <pr-number> --merge --delete-branch
git checkout main
git pull
```

### Step 7: Report

Report the PR URL and what was merged.

## Important

- **Never skip Step 0.** The gate catches population leaks, invalid geometry, and hardcoded paths before they reach `main`. If the user insists on skipping, record their override reason in the commit message.
- Always create a NEW branch — never commit directly to main.
- Exclude `settings.local.json` and sensitive files from staging.
- Use `--merge` (not `--squash` or `--rebase`) unless asked otherwise.
- If the commit message from `$ARGUMENTS` is provided, use it exactly.

