Skip to content

chore: add porting-code-prs skill for the desktop migration - #76335

Merged
charlesvien merged 1 commit into
masterfrom
chore/porting-code-prs-skill
Aug 1, 2026
Merged

chore: add porting-code-prs skill for the desktop migration#76335
charlesvien merged 1 commit into
masterfrom
chore/porting-code-prs-skill

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

PostHog/code's main is frozen after the desktop import (#72483), so every open PR there has to be remade by hand against products/desktop/. There was no documented procedure, and the non-obvious parts (path remapping, the 3-way fallback, the paths that must not be blind-applied) get rediscovered per PR.

Changes

Adds a repo-internal skill, .agents/skills/porting-code-prs, that walks an agent through porting one PR or sweeping all of an author's open PostHog/code PRs onto the monorepo:

  • git am -3 --directory=products/desktop/ to remap paths while preserving each commit's original author and message, with a fetch of the source PR head so the 3-way fallback has the blobs it needs
  • excludes for the paths that must be re-derived instead of applied: .github/** (transformed workflows per MIGRATION.md's mapping table), and the lockfiles that carry local security override pins
  • defers to products/desktop/MIGRATION.md as the authoritative contract for conflicts in drift-listed files
  • PR recreation rules: monorepo template, PostHog/code#N reference rewriting, draft state and assignee carried over

How did you test this code?

hogli lint:skills passes. Verified the core mechanics against a live PR (PostHog/code#4063): gh pr diff --patch + git apply --check --directory=products/desktop applies cleanly, and confirmed --exclude matches after the --directory prefix is prepended (the patterns in the skill carry the prefix for that reason).

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

N/A (the skill is the doc)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored with Claude Code. Invoked /writing-skills for conventions and placed the skill in .agents/skills/ (repo-internal engineering skill) rather than products/desktop/skills/ (customer-distributed) or products/desktop/.claude/skills/ (overwritten on resync per MIGRATION.md). Chose patch-based git am --directory over a subtree/cherry-pick approach because the import was an archive copy, not a git merge, so source commits don't graft directly.

@charlesvien charlesvien added the skip-agent-review Save $$$, skip auto agent reviews (Greptile) — use for trivial or chore PRs label Aug 1, 2026
@charlesvien charlesvien self-assigned this Aug 1, 2026
@trunk-io

trunk-io Bot commented Aug 1, 2026

Copy link
Copy Markdown

😎 This pull request was merged.

@charlesvien
charlesvien marked this pull request as ready for review August 1, 2026 08:22
@charlesvien
charlesvien merged commit f4cd018 into master Aug 1, 2026
253 of 264 checks passed
@charlesvien
charlesvien deleted the chore/porting-code-prs-skill branch August 1, 2026 08:22
@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
.agents/skills/porting-code-prs/SKILL.md:49-54
**Excluded-only commits halt porting**

When a source commit changes only an excluded workflow or lockfile, filtering removes its entire patch, but `--empty=drop` does not handle commits emptied by path exclusion, causing `git am` to stop mid-port without the documented recovery step.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "chore: add porting-code-prs skill for th..." | Re-trigger Greptile

Comment on lines +49 to +54
gh pr diff <N> --repo PostHog/code --patch > "$PATCH"
git fetch https://github.com/PostHog/code.git refs/pull/<N>/head
```

2. Apply with authorship preserved:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Excluded-only commits halt porting

When a source commit changes only an excluded workflow or lockfile, filtering removes its entire patch, but --empty=drop does not handle commits emptied by path exclusion, causing git am to stop mid-port without the documented recovery step.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .agents/skills/porting-code-prs/SKILL.md
Line: 49-54

Comment:
**Excluded-only commits halt porting**

When a source commit changes only an excluded workflow or lockfile, filtering removes its entire patch, but `--empty=drop` does not handle commits emptied by path exclusion, causing `git am` to stop mid-port without the documented recovery step.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.


4. Treat conflicts in drift-listed files (local security patches, `pnpm-workspace.yaml` overrides) as intentional monorepo divergence: keep the monorepo side and re-apply the PR's intent on top of it.

5. Verify from `products/desktop/`: `pnpm install --frozen-lockfile`, `pnpm typecheck` and `pnpm --filter <pkg> test` for the packages the PR touches. The desktop CI suite runs on the monorepo PR itself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Untrusted source PR code is executed with trusted credentials

An attacker can add commands to a package lifecycle or test script in their source PR, and this step executes them on the maintainer's workstation. Once pushed as a same-repository monorepo PR, desktop CI also supplies secrets that the ported code can read; require an explicit trust/review gate before running code or pushing the port to a trusted branch, and keep untrusted ports on a secretless CI path.

@veria-ai

veria-ai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

PR overview

This pull request adds a porting-code-prs skill that documents the workflow for moving desktop migration changes into the target repository and validating them.

One security issue remains open: the workflow can execute code from an untrusted source pull request on a maintainer’s workstation and later in CI with trusted credentials. A malicious contributor could use lifecycle or test scripts to execute commands or access secrets unless a trust gate and secretless CI path are added. No issues have yet been addressed.

Open issues (1)

Fixed/addressed: 0 · PR risk: 8/10

@deployment-status-posthog

deployment-status-posthog Bot commented Aug 1, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-01 08:59 UTC Run
prod-us ✅ Deployed 2026-08-01 09:15 UTC Run
prod-eu ✅ Deployed 2026-08-01 09:14 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-agent-review Save $$$, skip auto agent reviews (Greptile) — use for trivial or chore PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant