:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(agents): move PR description rules into a skill (#76838)
Raúl Negrón-Otero8058c8c101a2
diff --git a/.agents/skills/writing-pr-descriptions/SKILL.md b/.agents/skills/writing-pr-descriptions/SKILL.mdnew file mode 100644index 000000000000..4e77d0a0e0b0--- /dev/null+++ b/.agents/skills/writing-pr-descriptions/SKILL.md@@ -0,0 +1,142 @@+---+name: writing-pr-descriptions+description: >+ Shapes a PR body into something a reviewer understands at a glance.+ Use ALWAYS before writing or editing a PR description, before `gh pr create` or `gh pr edit --body`, and when asked to improve an existing description.+ Routes each fact to the form that carries it fastest (bullet, table, diagram, screenshot, collapsed block), cuts everything a reviewer does not need, then holds what survives to a checkable shape: one fact per bullet, sentences under 25 words, active voice, no idioms.+ Ends with a self-check the agent runs over its own draft, including the test that the rewrite got shorter.+ Not for commit messages (see AGENTS.md, "Commit types") or user-facing product copy (see `/writing-user-facing-copy`).+---++# Writing PR descriptions++A reviewer scans a description in seconds and decides where to spend attention. The body is a scanning surface, not an essay. Everything below serves one goal: a reviewer understands the change without reading twice.++Work in four passes: route, cut, shape, check. Run all four.++## Pass 1: route each fact to a form++Prose is the slowest form on the page. Before writing a sentence, ask what carries the fact faster.++| The fact you have | The form that carries it |+| ------------------------------------------------------------------------------------ | --------------------------------------------------------- |+| A visual change (any UI a person sees) | Screenshot, before and after. Mandatory, not optional |+| A change to a flow or topology (CI wiring, pipelines, state machines, request paths) | Two `flowchart` blocks, before first |+| Several values compared across the same dimensions | A markdown table |+| A config or setting change | A fenced `diff` block |+| Existing code a reviewer needs to see | A line-range permalink, which GitHub renders as a snippet |+| Test output, logs, long command transcripts | A `<details>` block |+| A behavior change or a risk a reviewer must not miss | `> [!WARNING]` or `> [!NOTE]` |+| Anything else | Bullets, under the shape rule in pass 3 |++No PR needs every form. Reach for one because it makes review faster, never as decoration. An empty section gets one bullet or "None".++### Screenshots++Upload with `hogli pr:upload-image <file>` and paste the markdown it prints. The first run only warns; re-run with `--yes`. The assets are public forever, so never upload customer data, customer names, secrets, or internal info.++### Mermaid++Keep diagrams simple. A syntax error renders as an error block. Pick `TD` for tall pipelines, `LR` for wide paths. Mermaid cannot read CSS vars, so use the hex directly, and pair every `fill` with a text `color` so nodes stay legible in GitHub light and dark.++```text+classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;+classDef phRed fill:#f54e00,stroke:#f54e00,color:#fff;+classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000;+classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;+```++Assign by role (`class NodeA,NodeB phBlue;`): `phBlue` agents and primary paths, `phRed` APIs and external systems, `phYellow` entry and exit, `phGray` data and artifacts. Shape by kind: `{{hexagon}}` agents, `[rect]` steps.++## Pass 2: cut++One fact per bullet makes prose checkable. It does not make it shorter: a dense paragraph exploded into twelve bullets moves the reviewer's cost rather than removing it.++So cut first, and shape only what survives. A fact earns a line when a reviewer needs it to judge the change, approve it, or know what to watch after it ships.++Delete:++- Anything reconstructable from the diff. The reviewer can read the code.+- Rationale for a choice nobody would question. Keep the reason only where you rejected an obvious alternative.+- Restatements of the title, and summaries of the sections above.+- Process narration. "Then I ran X, then Y" is a fact about your session, not about the change.+- Hedges on facts that are not in doubt.+- The follow-up sentence in any "here is the reason, and here is why the reason matters" pair.+- Any bullet whose reader you cannot name.++Budget, as a ceiling and not a target:++- A one-file fix: 3 to 6 bullets across the whole body.+- A typical PR: Problem and Changes together fit in about 10 bullets.+- Numbers, file paths and identifiers survive cutting. Adjectives and second explanations do not.++The test: **the body must come out shorter than your first draft.** Pass 4 checks it.++## Pass 3: shape what survives++The shape is checkable. Tone is not, which is why this skill does not ask for one.++1. One fact per bullet.+2. Sentences under 25 words.+3. Active voice, with a stated subject. Use the passive only where the actor is genuinely unknown or irrelevant.+4. Simple tenses. No perfect or progressive forms: "the builder took entry 1", not "the builder has been taking entry 1".+5. The same word for the same thing, every time. Never vary for style.+6. Keep the articles. "The job downloads the artifact", not "job downloads artifact".+7. Noun strings of at most three words. "The flag evaluation column codec" becomes "the codec on the flag evaluation column".+8. No idioms, no figurative language, no jokes.++A reviewer scans, stops, checks one claim, moves on. A sentence that packs four facts into three clauses makes them hold all four to check any one. Split it.++This governs prose only. A table cell is not a sentence, and a diagram is not prose.++### Worked example++❌ One bullet, five links in a causal chain, 28 words:++> When the signals job's artifact glob matches one artifact (every selective-mode run), `download-artifact` extracts it flat, so spans get `job_key ...:None` and re-run recovery joins miss.++✅ Three bullets, each checkable on its own, 22 words:++> - In selective mode, `download-artifact` extracts the files flat.+> - The span gets the job key `...:None`.+> - Re-run recovery cannot join on that key.++The cut removed the glob matching one artifact, which is the mechanism behind "in selective mode" and reachable from the diff. It kept every identifier, and every link in the chain a reviewer has to check.++Copy the second one. It is shorter, not just flatter.++### Other prose rules++- No em-dashes. Use en-dashes only if needed.+- Sentence case for titles, headings, and bolded text. Only the first word and proper nouns.+- Spare use of inline code. Limited use of the colon and semicolon.+- Do not hard-wrap at a column width and do not space-align tables. GitHub renders markdown and flows the text.+- Write in first person as the author. When an agent did the work, say so: "I (actually Claude) moved the derivation into one place."++## Pass 4: check your own draft++Run this over the body you just wrote, before `gh pr create` or `gh pr edit`. Fix what fails.++1. Is the body shorter than your first draft? If it is longer, you split without cutting. Go back to pass 2.+2. Read each bullet and name the reader who needs it. Delete the ones you cannot.+3. Read each bullet alone. Does it state one fact? If it states two, split it.+4. Count the words in the longest sentence. Over 25, split it.+5. Find every passive sentence. Rewrite it in active voice, unless the actor is genuinely unknown.+6. Find every noun string longer than three words. Break it with a preposition.+7. Does the PR change anything a person sees? If yes, is a screenshot in the body?+8. Does it change a flow or topology? If yes, are the before and after diagrams there?+9. Is any comparison sitting in prose that belongs in a table?+10. Is the `## 🤖 Agent context` section filled, listing the skills invoked?+11. Does the body claim manual testing that did not happen? Delete it.+12. Does the body name an internal customer, incident, Slack quote, or operational metric? This repo is public. Delete it.+13. Read the first three bullets only. Do they tell a reviewer what changed and why? If not, reorder.++## Background++`references/examples.md` runs two merged PRs through all four passes, with a table of what each cut removed and why. Read it when you want the rule applied end to end rather than to one sentence.++Pass 3 adapts a subset of the 53 writing rules in [ASD-STE100 Simplified Technical English](https://www.asd-ste100.org/) (Issue 9, January 2025). The 25-word ceiling is the standard's limit for descriptive text; it caps procedural text at 20, which a PR body rarely contains. Rule 1 is our own: STE writes "one instruction per sentence" for procedures and "one topic per paragraph" for descriptions, and a bullet sits between the two.++The other half of the standard, a dictionary of roughly 900 approved words each carrying one meaning, is licensed and deliberately not part of this. Vocabulary stays a judgment call.++Nothing here is enforced by a check. Pass 4 is the enforcement.diff --git a/.agents/skills/writing-pr-descriptions/references/examples.md b/.agents/skills/writing-pr-descriptions/references/examples.mdnew file mode 100644index 000000000000..7c5bd10630de--- /dev/null+++ b/.agents/skills/writing-pr-descriptions/references/examples.md@@ -0,0 +1,140 @@+# Worked examples++Two merged PRs, as shipped and after all four passes. Read these when the rule in `SKILL.md` is clear but you want to see it applied end to end.++Both examples are shorter after the rewrite. That is the point: bullets are how you cut to the facts that matter, not how you restate a paragraph at greater length.++---++## Example 1: a long causal chain++[fix(data-warehouse): recognize Neon's pooler rejection of libpq options](https://github.com/PostHog/posthog/pull/77899). Problem and Changes only.++### As shipped, 297 words++```markdown+## Problem++Transaction-mode connection poolers reject the libpq `options` startup parameter, so `_connect_with_options_fallback` drops `options` and reconnects. The match is on the exact wording those poolers use:++FATAL: unsupported startup parameter: options++Neon's pooled endpoint names the offending setting instead of the parameter:++ERROR: unsupported startup parameter in options: statement_timeout.+Please use unpooled connection or remove this parameter from the startup package.++`"unsupported startup parameter: options"` is not a substring of that, so the fallback never fires and the connect just fails.++On the CDC path that connect is the first thing `cdc_extract_activity` does, and the stream reader always sends `options` (`statement_timeout=1800000 -c idle_in_transaction_session_timeout=0`). So every extraction run against a Neon pooled endpoint fails at `stream_reader.connect()`, forever. It classifies as a generic retryable `connection_failed`, so the user sees "Could not connect to the source database. PostHog will keep retrying — if this persists, check that the database is reachable and accepting connections" for a database that is reachable and perfectly healthy. There is nothing they can do to make that message go away, because it isn't describing their problem.++One source has been in this state since the day it was created. It never had a single successful extraction run.++## Changes++Match on the prefix `unsupported startup parameter in options` so any setting Neon names is covered, alongside the existing exact-wording and RDS Proxy matches.++The stale comment on the CDC stream reader claimed CDC sources never sit behind a pooler that rejects `options`. They do. Neon's pooler serves the `pg_logical_slot_peek_binary_changes` calls the reader uses just fine, so dropping the two server-side timeouts is the difference between working change capture and none at all. Updated it to say so, and to note that the activity's start-to-close and heartbeat timeouts still bound a stalled peek once the server-side ceiling is gone.+```++### After the four passes, 197 words++````markdown+## Problem++- Transaction-mode connection poolers reject the libpq `options` startup parameter.+- `_connect_with_options_fallback` drops `options` and reconnects when it sees the exact wording those poolers use:++```+FATAL: unsupported startup parameter: options+```++- Neon's pooled endpoint names the setting instead of the parameter:++```+ERROR: unsupported startup parameter in options: statement_timeout.+```++- That is not a substring of the match, so the fallback never fires.+- The CDC stream reader always sends `options`, and that connect is the first thing `cdc_extract_activity` does.+- Every extraction run against a Neon pooled endpoint therefore fails at `stream_reader.connect()`, forever.+- It classifies as a retryable `connection_failed`, so the user is told to check a database that is reachable and healthy.+- One source has never had a successful extraction run since the day it was created.++## Changes++- The match now uses the prefix `unsupported startup parameter in options`, so any setting Neon names is covered.+- The stream reader's comment claimed CDC sources never sit behind a pooler that rejects `options`. They do, and the comment now says so.+- Dropping the two server-side timeouts is the difference between working change capture and none.++> [!NOTE]+> Retry and classification behavior do not change. This makes the connection succeed where it currently cannot be opened at all.+````++### What the passes did++Pass 2 cut 100 words:++| Cut | Why |+| ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |+| The second line of Neon's error, and the full quoted user-facing message | The reviewer needs the phrasing that breaks the match, not the whole string |+| `statement_timeout=1800000 -c idle_in_transaction_session_timeout=0` | "Always sends `options`" is the fact. The values are in the diff |+| "There is nothing they can do to make that message go away, because it isn't describing their problem" | Second half of a reason pair. The bullet above it already says the database is healthy |+| "Neon's pooler serves the `pg_logical_slot_peek_binary_changes` calls the reader uses just fine" | Supports a claim nobody will dispute |+| The start-to-close and heartbeat timeout note | Belongs in the code comment it describes, and is there |++Pass 3 split the 76-word failure chain, which was the densest sentence in the description, into the five links a reviewer checks one at a time.++Both fenced blocks survived untouched. Pass 3 governs prose only.++---++## Example 2: two independent reasons in one paragraph++[fix(flags): drop custom codecs from flag_evaluations columns](https://github.com/PostHog/posthog/pull/77910). Problem and Changes only.++### As shipped, 190 words++```markdown+## Problem++Migration 0292 gave `flag_evaluations` explicit per-column codecs, mirroring the pattern the events tables use: `ZSTD(1)` on the plain String columns, `DoubleDelta, ZSTD(1)` on the datetime columns. That's the wrong call here. Compression on this cluster is tuned centrally at the ClickHouse server level, so pinning a codec on a column just takes it out of that cluster-wide tuning instead of improving anything. DoubleDelta specifically pays off when values trend with the sort order, and `flag_evaluations` sorts by `(team_id, flag_key, toDate(timestamp), cityHash64(distinct_id))`, which doesn't lead with time, so it isn't earning its keep there either.++## Changes++Migration 0293 sets the codecs 0292 declared and then removes them with `MODIFY COLUMN ... REMOVE CODEC`, across the sharded data table, the writable distributed table, and the read-path distributed table. Setting before removing means the migration applies cleanly whether 0292 already ran (codecs exist) or a fresh install already built the tables codec-free from the updated DDL (`REMOVE CODEC` errors on a column with no codec).++`posthog/models/flag_evaluations/sql.py` is the shared column template other DDL reads from, so the per-column `CODEC(...)` clauses are stripped there too. The HCL golden/SQL mirrors and the `test_schema.ambr` snapshot are regenerated to match.+```++### After the four passes, 111 words++```markdown+## Problem++- Migration 0292 gave `flag_evaluations` per-column codecs, mirroring the events tables.+- This cluster tunes compression centrally, so pinning a codec only takes the column out of that tuning.+- DoubleDelta pays off when values trend with the sort order. `flag_evaluations` sorts by `(team_id, flag_key, toDate(timestamp), cityHash64(distinct_id))`, which does not lead with time.++## Changes++- Migration 0293 sets the codecs 0292 declared, then removes them with `MODIFY COLUMN ... REMOVE CODEC`, across all three tables.+- `REMOVE CODEC` errors on a column with no codec, so setting first keeps the migration safe on a fresh install.+- `posthog/models/flag_evaluations/sql.py` is the shared column template, so the `CODEC(...)` clauses are stripped there too.+- The HCL goldens and the `test_schema.ambr` snapshot are regenerated.+```++### What the passes did++Pass 2 cut 79 words:++| Cut | Why |+| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |+| `ZSTD(1)` on Strings, `DoubleDelta, ZSTD(1)` on datetimes | The reviewer reads migration 0292 in the diff |+| "That's the wrong call here" | The next two bullets say why. The verdict adds nothing they don't reach on their own |+| "instead of improving anything", "so it isn't earning its keep there either" | Restate the claim already made in the same sentence |+| The three table names, listed in full | "All three tables" is enough. The migration names them |++Pass 3 separated the two independent reasons the codecs were wrong. They were welded into one paragraph, so a reviewer who wanted to dispute the DoubleDelta argument had to disentangle it from the central-tuning argument first.++Pass 4 item 1 is what makes this a rewrite rather than a reformat: the body has to come out shorter. Both examples do: 297 words to 197, and 190 to 111.diff --git a/.github/pull_request_template.md b/.github/pull_request_template.mdindex bbd8d272015a..958897fd9275 100644--- a/.github/pull_request_template.md+++ b/.github/pull_request_template.md@@ -70,22 +70,5 @@- Do not add a human Co-authored-by just for the sake of attribution — if no human was involved in the changes, own it as agent-authored.- Agent-authored PRs always require human review — do not self-merge or auto-approve.- Do NOT claim manual testing you haven't done.-- GitHub PR descriptions render markdown, not fixed-width text. Do not hard-wrap prose at a column width or use space-aligned tables — use real markdown tables, headings, and fenced code blocks, and let GitHub flow the text.-- Use GitHub's rich markdown when it makes review faster, never as decoration:- - If the change alters a flow or topology (CI wiring, pipelines, state machines, request paths), include before/after mermaid diagrams as two separate `flowchart` blocks, before first. Pick `TD` (tall pipelines) or `LR` (wide paths). Keep them simple; a syntax error renders as an error block. Skip for trivial changes.- - Brand the nodes with PostHog colors: use the hex directly (mermaid can't read CSS vars), and pair every `fill` with a text `color` so nodes stay legible in GitHub light and dark.- ```- classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;- classDef phRed fill:#f54e00,stroke:#f54e00,color:#fff;- classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000;- classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;- ```- Assign by role (`class NodeA,NodeB phBlue;`): `phBlue` agents/primary, `phRed` APIs/external, `phYellow` entry+exit, `phGray` data/artifacts. Shape by kind: `{{hexagon}}` agents, `[rect]` steps.- - Use alerts (`> [!WARNING]`, `> [!NOTE]`) for behavior changes and risk callouts.- - If you have to include long supporting content (test output, logs), collapse it in `<details>` blocks.- - Use fenced `diff` code blocks for config before/after.- - Line-range permalinks to code in this repo render as embedded snippets: prefer them over pasting existing code.-- Write with a crisp, direct Silicon Valley communication style. Use concise language that gets straight to the point. Sentences that are easy on the reader, paragraphs that are each about one thing. Prioritize clarity and brevity over elaborate explanations. Avoid corporate jargon, buzzwords, and unnecessary embellishments. Communicate as if you're explaining a complex concept to a smart colleague over coffee, keeping the tone light but substantive. No em-dashes, only en-dashes if needed. Spare use of inline code. Limited use of the colon and semicolon.-- Write from a first person perspective of the author of a human-driven PR. Although if something was done by an agent (i.e. you), make that clear with something like "I (or, actually Claude/Codex/etc.) did blah".-- For titles, headings, or bolded parts use "Sentence case" rather than "Title Case" (i.e. only capitalize the first word of the title/heading/bold text).+- Shape and style: invoke the `/writing-pr-descriptions` skill before writing this body. In short: put each fact in the form that reads fastest (screenshot, diagram, table, bullet), cut what a reviewer doesn't need, then hold what's left to one fact per bullet in under 25 words. A body that got longer as bullets was not cut.-->diff --git a/AGENTS.md b/AGENTS.mdindex 5b645c3357a8..7f79c4ac75fe 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -65,6 +65,7 @@ Examples:**Required:** Before creating any PR, read `.github/pull_request_template.md` and use its exact section structure.Do not invent a different format.+**Shape:** invoke `/writing-pr-descriptions` before writing the body. Cut to the facts a reviewer needs, then one fact per bullet, sentences under 25 words, active voice, no idioms. A description that got longer as bullets was not cut.Always fill the `## 🤖 Agent context` section when creating PRs.NEVER share sensitive information in a PR description. Users may share sensitive data in an agent session, but those should never surface to a PR description, or comments.@@ -234,6 +235,7 @@ ALWAYS invoke the matching skill **before** writing or reviewing code in these a- `/writing-tests` — adding or substantially changing any test (pytest, Jest, or Playwright)- `/writing-user-facing-copy` — writing or editing any text a user reads (UI labels, tooltips, empty/error states, notifications, docs, support replies), or any code change that adds or changes a visible string- `/writing-code-comments` — writing or editing a code comment in any language, or reviewing a diff that adds comments+- `/writing-pr-descriptions` — writing or editing any PR body, before `gh pr create` or `gh pr edit --body`**Invoke when in the area:**