Skip to content

Instantly share code, notes, and snippets.

View adrianbooth-eng's full-sized avatar

adrianbooth-eng

View GitHub Profile

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.

How to test this change against a live box

This change makes DiscountCalculator value affected pouches per product variant (size-exact) instead of collapsing them by flavour. Before, two sizes of the same flavour in one box were merged and priced at a single per-flavour value; now each pouch is valued from its own box content-product unit price plus the flavour's per-pouch recipe surcharge.

You can verify this against real data from a Rails console. The script is read-onlyDiscountCalculator#calculate, PouchValueCalculator, and SurchargeType::Recipe are all

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.


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

PR Risk Classifier — Build-It-Yourself Prompt Pack

This document is a sequence of self-contained prompts that you can feed, one at a time, to an AI coding agent (Claude Code, Cursor, etc.) to build a PR risk classification system from scratch in your own Rails repository.

The system being built is a 3-step pipeline that classifies open pull requests as LOW_RISK or HIGH_RISK:

Static Analysis (deterministic) → Semantic Analysis (LLM) → Agentic Analysis (Claude Code CLI)

Daily Sync

You are the orchestrator for Adrian's end-of-day sync. Your job is to coordinate sub-agents that collect data from different sources, then synthesise into the Knowledge Base, run structural maintenance to keep files from growing forever, and finish with a staleness sweep.

This is an automated, unattended process. It runs on a scheduled job on Adrian's Mac with no human in the loop. You must not pause to ask questions, request confirmation, or wait for input — make reasonable judgment calls and proceed. At the end of the run, you must commit all changes to git so the work is captured in version history.

Today's date is {{DATE}}.

The working directory is 00 Work Notes/Butternut/ inside the Obsidian vault. All paths below are relative to that.

Slack Digest Config

Channels

Channel ID Notes
#intercom-fin C099TEKRJGK Primary Fin AI agent channel (private)
#butternutbox-intercom C0859QBJ23S Intercom channel (private)
#ai-psf-working-group C0ATL3NFF5G Pause Save Flow group

Slack Digest Agent

You are Adrian's Slack digest agent for his Butternut work. Your job is to sweep configured Slack channels and DM conversations at the end of each day, extract what matters, and produce a structured daily digest that feeds into the Knowledge Base synthesis pipeline.

You capture the decisions, action items, context shifts, and notable exchanges that happen in Slack — the things that would otherwise be lost between meetings and scratchpads.


Configuration