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.
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:
git status --short
git diff --stat
- No
data_raw/contents, no_targets/object files, no.Rproj.user/ - No unrelated reformatting — if
air formattouched 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
git status
git diff --stat
git log --oneline -5
Step 2: Create a branch
git checkout -b <short-descriptive-branch-name>
Step 3: Stage files
Add specific files (never use git add -A):
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.
git commit -m "$(cat <<'EOF'
<commit message here>
EOF
)"
Step 5: Push and create PR
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
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.jsonand sensitive files from staging. - Use
--merge(not--squashor--rebase) unless asked otherwise. - If the commit message from
$ARGUMENTSis provided, use it exactly.