Skip to content

: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.

chore(devex): source pr problem statements and gate agent steering (#118362)

Julian Bezbb1786bdeb60
diff --git a/.agents/skills/writing-pr-descriptions/SKILL.md b/.agents/skills/writing-pr-descriptions/SKILL.md
index 296a437cdfc1..904c486abde4 100644
--- a/.agents/skills/writing-pr-descriptions/SKILL.md
+++ b/.agents/skills/writing-pr-descriptions/SKILL.md
@@ -3,7 +3,7 @@ name: writing-pr-descriptions
description: >-
Shapes a PR body so a reviewer can understand the problem and change quickly.
Use ALWAYS before writing or editing a PR description, before `gh pr create` or `gh pr edit --body`, or when asked to improve a description.
- States the actor's need in Problem, then the visible effect and mechanism in Changes.
+ States who is affected and what is wrong for them in Problem, taken from a source and never invented, then the visible effect and mechanism in Changes.
Selects bullets, tables, diagrams, screenshots, or collapsed blocks for each fact.
Removes unnecessary detail and checks one fact per bullet, sentences under 25 words, active voice, and no idioms.
Keeps the body complete without the diff, scales its length to the change, and links evidence or marks claims as unchecked.
@@ -39,23 +39,18 @@ gh pr edit <number> --body-file pr-body.md
Carry every image, video, link and ticked box into the new body, under the heading it belongs to, and add the heading when your draft has none.
Replace one only when the change made it wrong, and say in the body that you replaced it.
-## Pass 1: lead with the product intent
+## Pass 1: lead with the need
The first line is the one line you can count on being read.
You just spent an hour inside the mechanism, so the mechanism comes out first. Push it down and spend that line on the need that caused the work.
-Problem states the product intent, not the inverse of Changes.
-It names the actor who needs an outcome, the friction they face now, and why that friction matters.
-The actor can differ from the person who uses the new surface.
-The problem must stay true if the author chooses a different solution.
-
-- Line 1 of Problem says who needs a better outcome and what prevents it today. Name the affected workflow or surface. Four shapes cover almost every PR:
+- Line 1 of Problem says who is affected and what is wrong for them today. Name the surface or workflow they were on. Four shapes cover almost every PR:
- A fix: what breaks, and for whom.
- - A feature: the actor's goal, the current friction, and its cost. Do not define the problem as a missing version of the chosen solution.
+ - A feature: what the person is trying to get done, and what stands in the way. "Analysts who join tables in the SQL editor recompute the same derived column in every query."
- A refactor, a chore or an enabling change: who is blocked, what it costs them, or what class of failure it removes. Nobody sees it, but somebody is waiting.
- - A follow-up or a layer in a stack: which need the earlier PR left unmet. Link that PR and assume nobody read it.
-- Negating the first Changes bullet does not produce a problem statement. Phrases such as "there is no way", "cannot use X through Y", and "lacks a Y" usually restate the solution.
-- Ask why the capability matters until the answer describes an outcome or cost. Stop before the answer becomes a broad company goal.
+ - A follow-up or a layer in a stack: what the earlier PR left undone, and what this one adds. Link that PR and assume nobody read it.
+- Problem must stay true if the author picks a different solution. A missing version of your solution is not a problem: "there is no PDF export" is Changes with a "not" in it.
+- Take the need from a source: the request, a linked issue, a thread, a measurement. The writer of a body often has only the diff. Never invent an actor, a cost, or a frequency to make the line read better. When no source gives the reason, say so in one line, so the reviewer knows to ask.
- If line 1 opens with a symbol, a file path, a class, or a setting, you led with the mechanism. Rewrite it.
- Size the problem in one clause where you know it: how many teams, how often, since when.
- The mechanism follows, in the order a reviewer has to check it.
@@ -64,7 +59,7 @@ The problem must stay true if the author chooses a different solution.
- Say in one line which part of Changes is mechanical. A reviewer cannot otherwise tell a purely internal change from a visible one you described as internal.
- If one part of the diff is riskier than the rest, name that part and say the rest is mechanical.
-Most of the time you already wrote the product intent and put it third. Move it up rather than writing a new sentence.
+Most of the time you already wrote the need and put it third. Move it up rather than writing a new sentence.
Line 1 can be a bullet or a standalone sentence, whichever reads faster, but one sentence and never a paragraph.
@@ -72,13 +67,11 @@ Line 1 can be a bullet or a standalone sentence, whichever reads faster, but one
❌ The dashboard has no PDF export.
-✅ Account managers rebuild weekly dashboard summaries in slides, which delays customer updates.
-
-❌ Integrations cannot call the API through a typed TypeScript client.
+✅ Account managers rebuild weekly dashboard summaries in slides to send to customers (linked request).
-✅ Integration authors repeat endpoint discovery and request typing, which slows delivery and lets client behavior drift.
+✅ The request asks for a PDF export of a dashboard and gives no reason. (No source states the need, so the body says that and invents nothing.)
-Each good version leaves room for more than one solution. It also tells a reviewer why solving the problem has value.
+The first good version leaves room for more than one solution. The second is honest, and it tells the reviewer what to ask before approving.
### Worked example
@@ -274,9 +267,9 @@ Run both checks over the body you just wrote, before `gh pr create` or `gh pr ed
Read only the title, the first line of Problem, and the first bullet of Changes. Cover the rest.
-1. Do you know who needs an outcome, what friction they face, and why it matters?
+1. Do you know who is affected, and what is wrong for them today?
2. Would the problem stay true if the implementation changed?
-3. Do you know what this PR does about the problem?
+3. Do you know what this PR does about it?
4. Did you get there without a symbol, a file path, or a class name?
A "no" anywhere means the body is ordered for the writer, not the reader. Go back to pass 1. Nothing in the line check can rescue a body that fails here.
@@ -287,7 +280,7 @@ A "no" anywhere means the body is ordered for the writer, not the reader. Go bac
2. Does the size of the body track the size of the diff? A six-line change under a full-length body reads as filler.
3. Are Problem and Changes together longer than the sections under them? If not, cut the lower ones.
4. Read the body with the diff closed. Can you say why the PR exists and what it does? If not, you cut something a reader needs.
-5. Could you write Problem by negating Changes? If yes, replace the missing capability with the underlying outcome, friction, or cost.
+5. Does Problem state a need that no source in the request, an issue, or a thread gave? Delete it, and say the reason was not given.
6. Read Changes alone. Can you say what a person will now see or do differently, or that nothing user-visible changed? If neither, go back to pass 1.
7. Read each bullet and name the reader who needs it. Delete the ones you cannot.
8. Read each bullet alone. Does it state one fact? If it states two, split it.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index cd34a6715285..4c405c47bde7 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -2,8 +2,8 @@
## Problem
-<!-- State the product intent: who needs a better outcome, what friction they face today, and why it matters. The actor can differ from the person who uses the new surface. -->
-<!-- The problem must stay true if the implementation changes. Do not define it as the absence of the chosen solution, such as "there is no way" or "cannot use X through Y". Put the solution and code path under Changes. -->
+<!-- Who are we building for, what are their needs, why is this important? -->
+<!-- First line: who is affected and what is wrong for them today. A fix says what breaks; a feature names the goal and what stands in the way; a chore says who is blocked. It must stay true under a different solution. Take the need from the request or an issue, and say so when none gives one. The code path goes under Changes. -->
<!-- Does this fix an issue? Uncomment the line below with the issue ID to automatically close it when merged -->
<!-- Closes #ISSUE_ID -->
@@ -94,5 +94,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.
-- Shape and style: invoke the `/writing-pr-descriptions` skill before writing this body. In short: state the product intent independently of the chosen solution, then lead Changes with the effect a person sees rather than the code path behind it. Make the body stand alone for a reader who opens no files, size it to the change, link evidence rather than asserting what CI already reports, then hold what's left to one fact per bullet in under 25 words. A body that got longer as bullets was not cut.
+- Shape and style: invoke the `/writing-pr-descriptions` skill before writing this body. In short: lead Problem with who is affected and what is wrong for them, taken from a source and true under any solution, then lead Changes with the effect a person sees rather than the code path behind it. Make the body stand alone for a reader who opens no files, size it to the change, link evidence rather than asserting what CI already reports, 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/.github/workflows/ci-agent-skills.yml b/.github/workflows/ci-agent-skills.yml
index 80c6b93bde48..68fbecec0342 100644
--- a/.github/workflows/ci-agent-skills.yml
+++ b/.github/workflows/ci-agent-skills.yml
@@ -24,6 +24,7 @@ jobs:
name: Determine need to run skill checks
outputs:
skills: ${{ steps.filter.outputs.skills || 'true' }}
+ lint: ${{ steps.filter.outputs.lint || 'true' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
@@ -55,6 +56,37 @@ jobs:
# 'products/*/frontend/**', so a future deliberate frontend
# include here isn't silently vetoed.
- '!products/posthog_ai/frontend/**'
+ lint:
+ - '.agents/skills/**'
+ - 'products/*/skills/**'
+ - 'products/posthog_ai/scripts/build_skills/**'
+ - 'services/mcp/schema/**'
+ - '.github/workflows/ci-agent-skills.yml'
+
+ lint-skills:
+ name: Lint agent skills
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ needs: changes
+ if: needs.changes.outputs.lint == 'true'
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Install uv
+ uses: ./.github/actions/setup-uv
+ with:
+ enable-cache: false
+
+ # Same as `hogli lint:skills`. The lint needs no Django or database, so this job
+ # skips the dev environment that check-skills builds, and a .agents/skills edit
+ # gets the check without the full skills build.
+ - name: Lint skills
+ run: >-
+ uv run --no-project --python 3.12
+ --with jinja2==3.1.6 --with pydantic==2.12.5 --with pyyaml==6.0.3
+ python -m products.posthog_ai.scripts.build_skills --lint
check-skills:
name: Check agent skills
@@ -194,9 +226,6 @@ jobs:
- name: Install sqlx-cli
uses: ./.github/actions/setup-sqlx-cli
- - name: Lint skills
- run: ./bin/hogli lint:skills
-
- name: Wait for Docker services
env:
COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml
@@ -305,7 +334,7 @@ jobs:
name: Release agent skills
runs-on: ubuntu-24.04
timeout-minutes: 10
- needs: [check-skills, current-master]
+ needs: [lint-skills, check-skills, current-master]
if: github.repository_owner == 'PostHog' && github.ref == 'refs/heads/master' && needs.current-master.outputs.is-current == 'true'
permissions:
contents: write
diff --git a/.stamphog/README.md b/.stamphog/README.md
index bbff81382b83..cecebe47e0cc 100644
--- a/.stamphog/README.md
+++ b/.stamphog/README.md
@@ -15,6 +15,7 @@ It overrides `deny` and `allow`, and the differences are:
- `ci_workflows` is an extra, owner-only category. It matches every file under `.github/workflows/` and `.depot/workflows/`, and its `exempt_author_teams` lets stamphog approve there only for authors on `team-devex`.
- `stamphog_policy` also matches `packages/owners-yaml/`, `owners.yaml` and `product.yaml`, because those are gate inputs here.
- `devex_guardrails` is an extra category. It matches the semgrep rules, ratchet baselines, invariant tests and lint code that guard the house patterns, so an edit to a guard always gets a human review.
+- `agent_steering` is an extra, owner-only category. It matches the root `AGENTS.md`, the PR template, the `writing-pr-descriptions` skill, `.claude/settings.json`, `.claude/hooks/` and `.mcp.json`, and its `exempt_author_teams` lets stamphog approve there only for authors on `team-devex`.
- `workflows_delivery` is an extra, owner-only category. It matches the CDP, Workflows and Messaging API, models and plugin-server worker code, and its `exempt_author_teams` lets stamphog approve there only for authors on `team-workflows`.
- `allow` also lists `.github/CODEOWNERS`.
- Every `rationale` records the false positives that shaped the rule in this repository.
diff --git a/.stamphog/policy.yml b/.stamphog/policy.yml
index 7bed6d659fb3..3c511fefcb44 100644
--- a/.stamphog/policy.yml
+++ b/.stamphog/policy.yml
@@ -163,6 +163,20 @@ deny:
- '^tools/hogli-commands/hogli_commands/(api_ratchet|projections|tach_lint)\.py$'
- '^tools/hogli-commands/hogli_commands/product_structure\.yaml$'
- '^tools/hogli-commands/hogli_commands/product/'
+ agent_steering:
+ description: 'The root agent instructions, the PR authoring guidance, and the agent config that runs in every session.'
+ rationale: 'Owner-only: stamphog approves team-devex changes here and refuses everyone else. One edit changes how every agent-written PR reads, and the files are .md, so without this category they ride the allow-list to a T0 auto-approve. A change from outside team-devex now needs a human approval, which is where the owner discussion happens. .claude/settings.json and .mcp.json are .json and ride the same allow-list, but their hooks and MCP servers run commands in every agent session, so they belong here too. Other skills under .agents/skills stay out on purpose, because product teams own several and edit their own. Paths are anchored, so a nested AGENTS.md stays with its folder owner.'
+ match:
+ paths:
+ - '^agents\.md$'
+ - '^claude\.md$'
+ - '^\.github/pull_request_template\.md$'
+ - '^\.agents/skills/writing-pr-descriptions/'
+ - '^\.claude/settings\.json$'
+ - '^\.claude/hooks/'
+ - '^\.mcp\.json$'
+ exempt_author_teams:
+ - 'team-devex'
workflows_delivery:
description: 'CDP, Workflows and Messaging code that decides which customer configurations exist and what gets delivered.'
rationale: "Owner-only: stamphog approves team-workflows' own changes here and refuses everyone else's. Another team's change here breaks a customer silently: the API and models decide which of a tenant's rows get listed and updated, and the plugin-server worker decides what gets delivered. Teams usually edit these paths to carve out an exception for their own rows, their tests still pass, and existing customer configurations stop appearing or stop being delivered. Product frontends stay out, because a mistake there is visible. As in CODEOWNERS, only the API test directories and `*.test.ts` files stay out. Nothing else under the worker does: the template, legacy-plugin, legacy-webhook and segment directories hold live delivery code and mutable registries."
diff --git a/products/stamphog/packages/pr-approval-agent/test_policy.py b/products/stamphog/packages/pr-approval-agent/test_policy.py
index bffdc169127e..f065f01d906d 100644
--- a/products/stamphog/packages/pr-approval-agent/test_policy.py
+++ b/products/stamphog/packages/pr-approval-agent/test_policy.py
@@ -148,6 +148,17 @@ OLD_DENY_PATTERN_DEFS = {
"^tools/hogli-commands/hogli_commands/product/",
]
},
+ "agent_steering": {
+ "paths": [
+ "^agents\\.md$",
+ "^claude\\.md$",
+ "^\\.github/pull_request_template\\.md$",
+ "^\\.agents/skills/writing-pr-descriptions/",
+ "^\\.claude/settings\\.json$",
+ "^\\.claude/hooks/",
+ "^\\.mcp\\.json$",
+ ]
+ },
"workflows_delivery": {
"paths": [
"^products/cdp/backend/(api|models)/",