Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
input=$(cat)
model=$(echo "$input" | jq -r '.model.display_name // "unknown model"')
used=$(echo "$input" | jq -r '.context_window.used_percentage // empty')
branch=$(git -C "$(echo "$input" | jq -r '.workspace.current_dir')" --no-optional-locks rev-parse --abbrev-ref HEAD 2>/dev/null)
five_pct=$(echo "$input" | jq -r '.rate_limits.five_hour.used_percentage // empty')
five_resets=$(echo "$input" | jq -r '.rate_limits.five_hour.resets_at // empty')
week_pct=$(echo "$input" | jq -r '.rate_limits.seven_day.used_percentage // empty')
week_resets=$(echo "$input" | jq -r '.rate_limits.seven_day.resets_at // empty')
name review-as
description Given a GitHub username and a target PR, mines that person's recent PR review comments in this repo to build a concrete profile of how they review, then reviews the target PR in that style: tone, what they flag, what they let slide, severity calibration. Use when the user asks to review a PR "as", "in the style of", or "the way <person> would".

Review As

You are reviewing a pull request the way a specific person would review it — not how a generic careful reviewer would. That person's actual comment history in this repo is the only legitimate source for their style. You mine it, synthesize a concrete profile, then do real investigative work on the target PR and only write findings in their voice that survive verification. Style mimicry never licenses inventing concerns their history gives no evidence they'd raise, and it never excuses skipping the verification a real review requires.

Do not freestyle. Follow the phases below in order.

TypeScript + Sass Migration Plan — app/javascript/components/admin/order_issue/

Migrate the admin Order Issues V2 frontend from Flow-typed JavaScript with inline style objects to TypeScript (.tsx/.ts) with Sass CSS Modules (.module.sass), matching the established patterns in app/javascript/components/admin/investigations/ and app/javascript/ambassadors/. Behaviour, DOM structure, and visual rendering must be preserved exactly.

This document is a hand-off plan for an orchestrating agent session. It contains everything discovered about the codebase that the executor needs, the conversion rules, a phased execution plan designed for delegation to sub-agents via dynamic workflows, and a full verification battery.


1. Goal & success criteria

TypeScript + Sass Migration Plan — app/javascript/components/admin/order_issue/

Migrate the admin Order Issues V2 frontend from Flow-typed JavaScript with inline style objects to TypeScript (.tsx/.ts) with Sass CSS Modules (.module.sass), matching the established patterns in app/javascript/components/admin/investigations/ and app/javascript/ambassadors/. Behaviour, DOM structure, and visual rendering must be preserved exactly.

This document is a hand-off plan for an orchestrating agent session. It contains everything discovered about the codebase that the executor needs, the conversion rules, a phased execution plan designed for delegation to sub-agents via dynamic workflows, and a full verification battery.


1. Goal & success criteria

Atomic Commits

Purpose

Transform a branch with messy commit history into atomic, logical commits that are easy to review. Each atomic commit should represent one coherent change that builds on the previous state.

When to Use

  • User mentions "atomic commits", "break down commits", "restructure commits"
  • User wants to "make commits easier to review" or "reorganize commit history"
  • User asks to "split up commits" or "rewrite git history"
  • User has a branch they want to clean up before creating a PR

Order Issues V2 frontend migration plan

Flow → TypeScript, inline style objects → .module.sass, flat directory → Ambassadors-style feature layout.

Target: app/javascript/components/admin/order_issue/ — 65 files, 7,124 lines, 100% Flow .js, 100% inline style={} objects, 0 tests.

Reference patterns to copy: app/javascript/ambassadors/** (layout, graphql/ dir, .module.sass

  • hand-written .d.ts, local .eslintrc.json) and app/javascript/components/admin/investigations/**

Simplify

You are simplifying the code changes on the current branch. The goal is to leave the branch's code simpler and more readable than it was before — without changing behavior. You will spawn specialized sub-agents in parallel, synthesize their findings, get the user's approval per finding, and then apply everything they approved.

Do not freestyle. Follow the phases below in order.

Phase 1: Identify the diff

  1. Detect the base branch by checking which exists:
  • git rev-parse --verify main → use main

OOP Design Review & Refactoring Plan

You are an AI software engineer acting in the style of Sandi Metz: pragmatic, object-oriented, relentlessly focused on clarity, small interfaces, low coupling, and high cohesion.

Your job is to review and refactor a Ruby codebase using object-oriented design best practices. You are not here to show off cleverness or introduce unnecessary abstraction. You are here to make the code easier to understand, easier to change, and safer to extend.

Input

The user will provide a directory path or description of the code to review. If no target is given, ask for one before proceeding.

Flaky Test Guidance

Audience: coding agents (and humans) writing or editing tests in this repo.

This document is distilled from every "flaky"/"flake" test-fix PR merged in 2026 (33 PRs). Each rule below maps to a real flake we shipped, found in CI, and had to fix again later. The goal is simple: write the test correctly the first time so it never lands on this list.

Companion doc: best_practices/testing.md covers general test structure. This doc is specifically about non-determinism — tests that pass locally and on the author's

React / Frontend Rules

Codified from recurring code-review feedback on the admin-facing "Order Issues V2" React frontend (PRs #31657, #31665, #31709, #31719, reviewer: Carolina Martes). The goal is simple: a coding agent that reads this file should never trigger the same review comment twice.

Apply these proactively when writing or changing React/TypeScript/frontend code in this repo.

Context you must keep in mind

  • The admin-tools frontend is Flow-typed (// @flow, .js files, exact object types {| |}), but every rule here applies identically to TypeScript/React — treat any and Flow weak types (flowtype/no-weak-types) as the same thing.
  • "Styled components" in this repo means named plain style objects (e.g. const headingStyle = { ... }), not the styled-components library. Never introduce that library.
  • Admin-tools has no LocalisationProvider, so currency symbols/formatting are derived client-side.