bikeindex/bike_index / .claude/skills/pr
pr
VerifiedCreate or update a pull request for the current branch. Trigger when the user asks to create/open/make a PR, or to edit/update/rewrite/fix the PR description, body, summary, or title — including bare phrasings like "update pr" or "update the PR" with no other object — for both new PRs and existing ones. Also trigger when the ask is to re-host, recreate, or duplicate an existing PR under this repo (e.g. "close this PR and open a new one of the same changes, not a fork") — that's still creating a PR even with no new diff to write. Note this runs `/simplify`, `bin/lint`, an AGENTS.md conformance pass and a merge from the base before writing the body — skipped when the ask is only to reword the description — and pushes the result. For frontend diffs, delegates the screenshot phase to `references/screenshots.md`, which captures desktop+mobile shots and posts them as a `## Screenshots` PR comment.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 17.5 KB |
| references/pre-push-cleanup.md | markdown | 18.7 KB |
| references/screenshots.md | markdown | 12.2 KB |
references/pre-push-cleanup.md
View on GitHub# Pre-push cleanup
The cleanup and migration halves of SKILL.md's **Prepare the branch**, in full. Everything here runs against committed work and diffs `origin/main...HEAD` — substitute the base branch from **Orient**, since shell state doesn't carry between commands. The audits inherit that: run them after committing, or pair them with a pass over `rtk proxy git diff HEAD`, or a comment you razored in the working tree still reads as present.
## Simplify, lint, and conform to AGENTS.md
Invoke the `/simplify` command to review the changed code for reuse, simplification, and efficiency cleanups and apply them. It's quality-only — it won't touch correctness — so it's safe to run unattended; if it reports nothing to clean up, move on.
Skip it when the diff has no code in it — a docs- or skill-only branch gives it nothing to review, and it fans out subagents to find that out. Config by file extension isn't the test: a `.github/workflows/*.yml` with a `run:` block is a shell script, and reviewing one is how the nightly-reseed branch found its only cleanup.
**Read `git diff` as soon as the agents return, before running anything.** An agent that stops mid-verification leaves its edit in the tree — including a sweeping edit it reverted to test, which then reads as your regression.
**Brief the agents with the constraint, not the shape you think satisfies it.** "A cell block is instance_exec'd, so a component method is unreachable inside one" is a fact they can work from; "the lambda is required, judge only how it's used" is a conclusion, and it hid that `method(:…)` is how four sibling org tables already bind exactly that. Likewise "the user asked for a shared component" is a constraint, while "the user requested this new component" is a conclusion — it kept `UI::BulkTableCard` from the reuse reviewer, when the shared component was `UI::Table::InCard` extended. Declining a finding is yours to do on the way back, not theirs to be told up front — the exception is a *second* run, where naming what a previous pass already triaged is what keeps them off it.
**On a second run against the same branch, scope it to the commits since the last one** — `/simplify` defaults to the whole branch diff, so re-running it resurfaces every finding already triaged, including the ones deliberately declined. Pass the range (`git diff <last-simplify-commit>..HEAD`) as its argument.
**The previous run's merge from the base names that commit** — `rtk proxy git log --merges -2 --format=%h origin/main..HEAD | tail -1`. It's the *second* one because **Prepare the branch** merges before it cleans, so this run's own merge is already the most recent by the time you get here, and `-1` scopes the range to that merge alone — an empty diff, which reads as a clean branch rather than a wrong range. A run that had nothing to merge left no commit, so the range can reach back further than the last run; that costs a re-triage, not a wrong scope. A merge made *between* runs — the user asking to merge main — errs the other way: it's newer than the last run, so the range silently drops the commits before it. Read the session for one before trusting the count.
**That range breaks when earlier branch work was split into its own PRs and merged.** Those commits return through a merge from the base, so `<last-simplify-commit>..HEAD` includes all of them plus everything else the base gained — hundreds of files, none of it yours. Check `git log --oneline <last-simplify-commit>..HEAD`; if it lists the base's merges, scope to your own commits (`git show` each) instead. `--no-merges` doesn't rescue it — it hides the merge commits, not the commits they brought in.
Then run `bin/lint` to auto-format (it also picks up whatever `/simplify` just changed). Always `bin/lint`, never another formatter or `standardrb` directly. Scope it to the branch's files rather than walking the whole repo:
```bash
{ rtk proxy git diff --name-only origin/main...HEAD
rtk proxy git diff --name-only HEAD
git ls-files --others --exclude-standard
} | sort -u | xargs bin/lint
```
`xargs` rather than `bin/lint $(…)` — command substitution splits on spaces in filenames. `rtk proxy` for the same reason the greps below need it: the hook rewrites these into a stat whose trailing `Changes:` line then arrives as a filename.
**All three are load-bearing.** `origin/main...HEAD` sees only *committed* work, and `/simplify` just edited the tree — a file it touched that the branch hadn't committed yet is invisible to that range and goes unlinted. `git diff HEAD` in turn sees only *tracked* files, so a file the branch adds is in neither until it's staged: a new component template lints clean by never being linted, and CI's `lint_and_scan` is what finds it. `--exclude-standard` keeps the gitignored paths out. Same union applies to the spec scoping and the audits below, which also run before the commit.
**Check that substitution produced something first.** With no arguments `bin/lint` lints the whole repo (it falls through to a bare `standardrb --fix`), so an empty diff turns the scoped command into exactly the whole-repo run it's avoiding.
A clean run over Ruby-only paths prints **nothing at all** — the summary table comes from the ERB formatter, so silence plus exit 0 is the pass. Take that status from `bin/lint` itself — piped to `tail` it's `tail`'s, and the ERB summary prints "All files are clean!" even when standardrb never ran. Paths the branch deleted are skipped silently — "Not found" means a path git has no history for, ie a typo. Files with no linter (`.haml`, `.scss`, `.md`) are skipped. It takes directories too, so `bin/lint app/components/foo` works while you're still iterating.
Scope specs the same way — the ones covering what the branch changed, never a bare `bundle exec rspec` or a whole top-level directory (see the `rspec-testing` skill). CI runs the full suite; a green PR isn't your job to prove locally. Scoping too far down is the live risk: walk the changed `app/` paths to their `spec/` siblings rather than the specs the change *feels* like it's about — a helper edited in passing has its own, and one like `spec/helpers/header_tag_helper_spec.rb` asserts its whole options hash with `eq`, so an added key reds it.
**`bin/rails tailwindcss:build` before the `:js` ones, after the last template edit.** Tailwind's content scan reads the templates, so adding or removing a class in an `.erb` changes the built CSS — and a system spec asserting a computed style (`spec/components/ui/dropdown/component_system_spec.rb` reads `getComputedStyle(...).color`) fails against the stale build until it's rebuilt. A merge that brings in `app/assets/tailwind/**` does it too. The failure names the assertion, not the build, so it reads as a real regression.
Then review the changed files against `AGENTS.md` (root and any nested ones in touched directories) and fix what doesn't conform — code style and testing conventions. A frontend diff also reads the `frontend-conventions` skill: `AGENTS.md` points there rather than stating the frontend rules, so checking it alone misses them — a component that should have been a partial went through this pass on #4308. Only touch lines this branch already changed.
### The spec audit
**Required, same as the comment audit below.** List the examples the branch adds:
```bash
rtk proxy git diff origin/main...HEAD -U0 -- 'spec/**/*_spec.rb' |
grep -E '^(\+\+\+ |\+\s*(it|scenario|specify) )'
```
Judge each one against a single question: **what bug does this fail on?** If you can't name a plausible edit that breaks the example *and* is wrong, delete it — a green assertion that can only go red when someone deliberately changes the thing it restates is a change-detector, and it costs a re-edit on every future change while catching nothing.
The ones to cut, all of which have been written here:
- **Framework behaviour.** `render_inline(described_class.new) { "content" }` then asserting the content rendered — that's ViewComponent's job, not the component's.
- **Passing an argument through.** Handing the component `title:` and asserting the title appears. Nothing between the input and the output can be wrong; assert what the component *decides* instead — which tab is active, which column is dropped.
- **A class list the template writes literally.** Pinning `class="tw:w-full tw:max-w-3xl"` re-asserts the source. The exception is a class the component *computes* — a conditional `active`, a width chosen from an argument — where the branch is the point.
- **What a request spec already covers.** A component spec listing the fields a form renders, next to a request spec that asserts the same names, is one of them maintained for nothing. Keep the one closest to the logic.
Keep, without hesitating, the ones tied to a failure mode: a conditional branch, a computed value, an argument guard that would otherwise fail silently, anything asserting what a fragment cache keys on, and any example written *because* something broke — say so in a comment above it, so the next audit doesn't mistake it for a change-detector.
This applies to the branch's specs, not the suite's. Don't delete pre-existing examples you merely moved between files.
### The documentation audit
When the branch adds or edits `AGENTS.md` or anything under `.claude/skills/`, check every
claim it makes against the code before pushing — a doc asserting *why* something is done is as capable of
being wrong as a comment, and nothing runs it. The wrong ones read as obvious. **Grep the file for the subject before adding a line** — a fact the branch states in one section is often already stated in another, and the two drift; #4425 added an architecture note restating the testing line it had edited in the same run, and got it wrong in the restating. Also check what the edit *moved* — a rule relocated into a skill is a rule
that only loads when that skill triggers.
### The churn audit
**Required.** Read the branch's own diff and ask of each hunk what it changes about what the code does. A moved argument, a re-ordered hash, a re-wrapped line: revert it rather than defending it in review.
```bash
rtk proxy git diff origin/main...HEAD --stat
```
Smallest files first — one at `+1 -1` is either the point of the branch or pure churn, and telling which takes a moment. `git checkout origin/main -- <file>` when the whole file is churn; when it rides along inside a real change, put the surrounding lines back so the diff shows only what moved.
**What `bin/lint` wrote is not churn** and stays, including in files the branch otherwise didn't touch — see the rule at the top of `AGENTS.md`.
Sweeping mechanical edits are where this collects.
### The comment audit
**Required, not conditional on the diff looking clean.** List the comments the branch adds or edits:
```bash
git diff origin/main...HEAD -U0 -- '*.rb' '*.erb' '*.haml' '*.js' '*.ts' '*.coffee' '*.scss' '*.css' '*.rake' '*.yml' 'bin/*' |
grep -E '^(\+\+\+ |\+.*(#|//|<%#|-#|/\*))'
```
The `+++ b/…` lines keep each hit attached to its file; the code-path filter keeps markdown headings out. It over-matches on `#{}` interpolation and catches trailing comments — the list is candidates to judge, not verdicts.
**An empty result on a non-empty diff means the pathspec missed the branch, not that the branch is clean** — the same silent-pass the rtk section below describes, from a different cause. `bin/kamal_review` (no extension) and `.github/workflows/*.yml` are why `bin/*` and `*.yml` are on the list; add whatever else the branch touches and re-run rather than reading the blank as a verdict.
Judge each against the **Comments** section of `AGENTS.md` and reach a verdict of keep / razor / delete on every line — a comment survives only by carrying a *why* the code can't. Deleting is the common outcome, razoring the next most common; leaving a block untouched should be the exception you can justify. Watch hardest for the ones you wrote to explain your own reasoning as you worked: narration of the change, mechanism the code already shows, and a second sentence justifying the first.
### The backfill audit
**Required.** Ask whether rows already in the database still fit the branch's code. The shapes that leave them behind:
- **A vocabulary stored as data** — an enum value, a jsonb key or list, a class name in a string column. #4458 replaced names `Export#options["headers"]` holds; `Backfills::NotificationDeliveryErrorRenameJob` is a rename.
- **A new column whose value depends on existing data**, not its default — `Backfills::OrganizationRolePriorityJob`.
- **A changed calculated attribute** — existing rows keep the old value until something re-saves them. `Backfills::OrganizationPaidMoneyJob`.
Find what reads the old form before calling one due. A value nothing reads again doesn't need one, and one recording what happened — `Export#written_headers` describes the file that was written — shouldn't be rewritten.
State the verdict in your reply to the user either way, naming the stored values you checked. When one is due, write it without asking — a job in `app/jobs/backfills/` with its spec — and lead the PR body with it (SKILL.md's **Write the summary body**).
### The asset audit
**Required when the branch adds a file under `app/assets/images/`.** List them:
```bash
rtk proxy git diff origin/main...HEAD --name-only --diff-filter=A -- app/assets/images
```
Icons and images both go through the markup audit below, which checks each one for a file the repo already has.
### The controller audit
**Required when the branch adds a Stimulus controller or wires one to new markup.** List both:
```bash
rtk proxy git diff origin/main...HEAD --name-only --diff-filter=A -- app/javascript/controllers
rtk proxy git diff origin/main...HEAD -G 'data-controller|controller:' --name-only
```
For each controller named, look for one that already does its job — a shared one in `app/javascript/controllers/ui/` or the top level, or a sibling in another namespace — and for two in the branch's namespace doing the same thing. Fold a duplicate into the shared one, an option on it rather than a second controller, and delete the copy. `bikebook--center-current` into `ui--tabs` and `bikebook--image-fallback` into `image-fallback` are the pattern. Name each one you kept and what it does that nothing shared covers.
### The component audit
**Required when the branch adds a directory under `app/components/`.** List them:
```bash
rtk proxy git diff origin/main...HEAD --name-only --diff-filter=A -- 'app/components/**/component.rb'
```
For each, name the existing component it renders or duplicates. One that wraps a single `UI::*` component in chrome is that component with an argument — ask the user whether to fold it in, since a new `UI::*` argument needs their permission. `UI::BulkTableCard` into `UI::Table::InCard`'s `column_settings:` is the pattern.
### The markup audit
**Required when the branch adds markup or an icon.** Run the `use-existing-markup` skill. It converts the hand-written markup to existing components without asking, covering marketing pages, buttons, icons and shadows. **Whenever it changes anything, tell the user in your reply.** List each conversion with the visible change it makes, and the commit it landed in. A page that looks different after a PR update, with no word about why, is what this prevents. Put its callouts (big shadows, and hover states on things that aren't buttons) in the same reply. When it changes nothing, say so in one line.
### The cycle-type translation check
`AGENTS.md`'s Translations section has the rule; this is how to find the branch's violations:
```bash
rtk proxy git diff origin/main...HEAD -- '*.en.yml' 'config/locales/en.yml' | grep -in '^+[^+].*bike'
rtk proxy git diff origin/main...HEAD -- '*.rb' | grep -in '^+[^+].*errors\.add.*bike'
```
The second one is load-bearing: a model's `errors.add(:base, "…")` reaches a flash through `full_messages`, never passing a locale file, so the YAML grep can't see it. `Sale#seller_is_owner` interpolates the cycle type into one.
Read each hit. Key names (`about_this_bike:`), the product name ("Bike Index"), and copy that really is bike-only are fine; a value saying "bike" about the registration is not. `Pages::Registrations::Show::CurrentAlerts::ClaimImpound` and `Pages::Registrations::Show::WrapperConsumer` are the pattern for fixing one, and `spec/components/pages/registrations/show/current_alerts/claim_impound/component_spec.rb` shows how to cover it.
### The product-name check
Copy spells the products "Bike Index" and "Bike Book" — never "BikeIndex", "Bike index", "BikeBook", "Bike book" or "Bikebook":
```bash
rtk proxy git diff origin/main...HEAD -- '*.yml' '*.erb' '*.haml' '*.rb' '*.js' '*.md' |
grep -nE '^\+[^+].*(BikeIndex|[Bb]ike index|BikeBook|Bike book|Bikebook)'
```
Fix every hit in copy. Code identifiers (`BikeIndexFormBuilder`, `BikeBookUpdateJob`, `Bikebook::`, `bikebook_path`) and the `BikeIndex.org` domain are fine.
### Only if you have rtk: `rtk proxy` anything you grep or count
Skip this section if `rtk` isn't installed — nothing below applies to a plain shell.
rtk's hook rewrites every `git diff` and `git log`. A `git diff` without `-U0` comes back summarized, its hunk lines indented, so `grep '^+…'` reads clean having matched nothing; `--name-only` gains a trailing `Changes:` line, so `wc -l` reports **1** for a diff that touches no matching path, and `bin/lint` takes it as a filename. `git log` loses its merge commits either way. Put `rtk proxy` on every diff you grep, count or hand to `xargs`.
Commit everything from this before re-dating migrations.
## Freshen stale migration timestamps
Every migration this branch adds must be dated within the past 2 days.
```bash
git diff origin/main...HEAD --name-only --diff-filter=A -- db/migrate db/analytics_migrate
date -d '2 days ago' +%Y%m%d%H%M%S 2>/dev/null || date -v-2d +%Y%m%d%H%M%S
```
(GNU `date` takes `-d`, BSD/macOS `date` takes `-v` — the fallback covers both.) Compare each filename's leading timestamp against that cutoff. No added migrations, nothing stale, or a timestamp in the *future* → skip. The rollback needs a working local database; if it isn't reachable, say so and leave the timestamps alone rather than failing mid-workflow.
For each stale migration, in this order (rollback must happen while the old version is still on disk):
1. Roll it back: `bin/rails db:migrate:down:primary VERSION=<old-timestamp>` (`db:migrate:down:analytics` for `db/analytics_migrate` files) — the un-namespaced `db:migrate:down` refuses in this multi-database app.
2. `git mv` the file to the same name with a fresh `date +%Y%m%d%H%M%S` timestamp — when re-dating several, keep their relative order with incrementing timestamps.
3. `bin/rails db:migrate` to re-apply and regenerate the structure files — never hand-edit `db/structure.sql`.
4. Commit the renames together with the regenerated structure files.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |