PR Best Practices
Overview
This skill enforces safe PR workflows: no force pushing, automatic lint/format detection and execution, keeping branches up-to-date with the default branch, and running relevant tests before pushing.
Core Rules (Non-Negotiable)
1. Never Force Push
- Always add new commits instead of rewriting history
- Use
git commit --fixup for corrections, not git commit --amend
- Never use
git push --force or git push -f
- If a rebase is needed, create a new branch instead (exception: after merging master, you can stash and pop)
2. Never Commit to Protected Branches
- Always verify you're not on
main or master before committing
- Check with:
git branch --show-current
- If on a protected branch, create a feature branch first
- Follow repo-specific rules: Search for any existing branch protection rules or skills that define additional constraints for this repository
3. Keep Branch Up-to-Date
- Before pushing, check if behind the default branch
- Use
git merge origin/main (or origin/master) to incorporate changes
- Never rebase shared branches
4. Run Lint/Format Before Pushing
- Always detect and run repo-specific linting/formatting
- Fix any issues before committing
- See Auto-Detection Logic for tool detection
5. Run Relevant Tests
- Run tests related to changed files, not the entire test suite
- Use test filtering when available (e.g.,
pytest path/to/test_file.py)
- Ensure tests pass before pushing
Auto-Detection Logic
Before running any tooling, detect the repo's tools. See references/detection-patterns.md for comprehensive patterns.
Key principle: Always detect the correct tool before running commands. Never assume defaults.
Quick reference:
- JS/TS: Check lock files first (
yarn.lock → yarn, pnpm-lock.yaml → pnpm, package-lock.json → npm)
- Python: Check for
uv.lock, poetry.lock, Pipfile.lock, or pyproject.toml
- Pre-commit: If
.pre-commit-config.yaml exists, hooks run automatically on commit (no manual run needed)
- Makefile: Check for
lint, fmt, test targets
- Go/Rust: Standard tooling (
go fmt/cargo fmt, etc.)
Pre-Push Checklist
Run through this checklist before every push:
[ ] 1. Not on protected branch (main/master)
[ ] 2. Branch is up-to-date with default branch
[ ] 3. Lint/format passes
[ ] 4. Relevant tests pass
[ ] 5. No secrets or sensitive data in changes
Workflow Steps
When Preparing a PR
Verify branch safety
git branch --show-current # Must NOT be main/master
Sync with default branch
git fetch origin
git merge origin/main # or origin/master
Detect and run lint/format (see Auto-Detection Logic)
Run relevant tests (only for changed code paths)
Push changes
git push origin <branch-name> # Never use --force
When Fixing CI Failures
- Read the CI failure logs carefully
- Make fixes in new commits (don't amend)
- Run the same checks locally before pushing
- Push the fix commit (no force push)
When Addressing Review Comments
- Read the comment and understand what's being requested
- Make the fix in a new commit
- Push the fix
- Resolve the comment using
gh api (unless asked not to):gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "<thread_node_id>"}) {
thread { isResolved }
}
}'
To get the thread ID, fetch PR review threads first.
When Rebasing is Requested
If someone asks you to rebase:
- Explain the risks of force pushing
- Suggest alternatives:
- Merge the default branch instead
- Create a new branch with clean history
- Only proceed if explicitly confirmed and understood
Small, Focused Commits
Guidelines
- Each commit should do one thing well
- Commit message should describe what and why, not how
- If you need "and" in your commit message, consider splitting
Good Examples
Add user authentication endpoint
Fix null pointer in checkout flow
Update API rate limiting to 100 req/min
Bad Examples
Fix stuff (too vague)
Add auth and fix checkout and update tests (too many things)
WIP (not descriptive)
References
See references/detection-patterns.md for comprehensive tooling detection patterns.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: pr-best-practices3description: Enforces safe and consistent PR/fix workflows with automatic detection of repo-specific tooling. Use when creating PRs, fixing CI failures, preparing commits for review, or ensuring code quality before pushing. Use when this capability is needed.4---56# PR Best Practices78## Overview910This skill enforces safe PR workflows: no force pushing, automatic lint/format detection and execution, keeping branches up-to-date with the default branch, and running relevant tests before pushing.1112## Core Rules (Non-Negotiable)1314### 1. Never Force Push15- **Always add new commits** instead of rewriting history16- Use `git commit --fixup` for corrections, not `git commit --amend`17- Never use `git push --force` or `git push -f`18- If a rebase is needed, create a new branch instead (exception: after merging master, you can stash and pop)1920### 2. Never Commit to Protected Branches21- **Always verify** you're not on `main` or `master` before committing22- Check with: `git branch --show-current`23- If on a protected branch, create a feature branch first24- **Follow repo-specific rules**: Search for any existing branch protection rules or skills that define additional constraints for this repository2526### 3. Keep Branch Up-to-Date27- Before pushing, check if behind the default branch28- Use `git merge origin/main` (or `origin/master`) to incorporate changes29- Never rebase shared branches3031### 4. Run Lint/Format Before Pushing32- Always detect and run repo-specific linting/formatting33- Fix any issues before committing34- See [Auto-Detection Logic](#auto-detection-logic) for tool detection3536### 5. Run Relevant Tests37- Run tests related to changed files, not the entire test suite38- Use test filtering when available (e.g., `pytest path/to/test_file.py`)39- Ensure tests pass before pushing4041## Auto-Detection Logic4243Before running any tooling, detect the repo's tools. See `references/detection-patterns.md` for comprehensive patterns.4445**Key principle**: Always detect the correct tool before running commands. Never assume defaults.4647**Quick reference:**48- **JS/TS**: Check lock files first (`yarn.lock` → yarn, `pnpm-lock.yaml` → pnpm, `package-lock.json` → npm)49- **Python**: Check for `uv.lock`, `poetry.lock`, `Pipfile.lock`, or `pyproject.toml`50- **Pre-commit**: If `.pre-commit-config.yaml` exists, hooks run automatically on commit (no manual run needed)51- **Makefile**: Check for `lint`, `fmt`, `test` targets52- **Go/Rust**: Standard tooling (`go fmt`/`cargo fmt`, etc.)5354## Pre-Push Checklist5556Run through this checklist before every push:5758```59[ ] 1. Not on protected branch (main/master)60[ ] 2. Branch is up-to-date with default branch61[ ] 3. Lint/format passes62[ ] 4. Relevant tests pass63[ ] 5. No secrets or sensitive data in changes64```6566## Workflow Steps6768### When Preparing a PR69701. **Verify branch safety**71 ```bash72 git branch --show-current # Must NOT be main/master73 ```74752. **Sync with default branch**76 ```bash77 git fetch origin78 git merge origin/main # or origin/master79 ```80813. **Detect and run lint/format** (see [Auto-Detection Logic](#auto-detection-logic))82834. **Run relevant tests** (only for changed code paths)84855. **Push changes**86 ```bash87 git push origin <branch-name> # Never use --force88 ```8990### When Fixing CI Failures91921. **Read the CI failure logs** carefully932. **Make fixes in new commits** (don't amend)943. **Run the same checks locally** before pushing954. **Push the fix commit** (no force push)9697### When Addressing Review Comments98991. **Read the comment** and understand what's being requested1002. **Make the fix** in a new commit1013. **Push the fix**1024. **Resolve the comment** using `gh api` (unless asked not to):103 ```bash104 gh api graphql -f query='105 mutation {106 resolveReviewThread(input: {threadId: "<thread_node_id>"}) {107 thread { isResolved }108 }109 }'110 ```111 To get the thread ID, fetch PR review threads first.112113### When Rebasing is Requested114115If someone asks you to rebase:1161. **Explain the risks** of force pushing1172. **Suggest alternatives:**118 - Merge the default branch instead119 - Create a new branch with clean history1203. **Only proceed** if explicitly confirmed and understood121122## Small, Focused Commits123124### Guidelines125126- Each commit should do **one thing well**127- Commit message should describe **what and why**, not how128- If you need "and" in your commit message, consider splitting129130### Good Examples131- `Add user authentication endpoint`132- `Fix null pointer in checkout flow`133- `Update API rate limiting to 100 req/min`134135### Bad Examples136- `Fix stuff` (too vague)137- `Add auth and fix checkout and update tests` (too many things)138- `WIP` (not descriptive)139140## References141142See `references/detection-patterns.md` for comprehensive tooling detection patterns.143144---145> Converted and distributed by [TomeVault](https://tomevault.io/claim/assapir) — claim your Tome and manage your conversions.146<!-- tomevault:4.0:skill_md:2026-04-15 -->