[FEATURE] Persist PR workflow context across compaction

Resolved 💬 2 comments Opened Mar 6, 2026 by htcxy009 Closed Apr 3, 2026

Problem

When working on a GitHub PR and context compaction occurs, Claude loses track of:

  1. Which PR is being worked on - The PR number and URL
  2. The correct push target branch - Especially when local branch name differs from remote tracking branch
  3. PR review comments - Which comments have been addressed vs. pending

Reproduction

  1. Start working on a PR (e.g., gh pr view 162)
  2. Make multiple commits responding to review comments
  3. Wait for context compaction to occur (or trigger manually)
  4. Attempt to push changes

Actual behavior: Claude may attempt to push to wrong branch or ask user which branch to use

Expected behavior: Claude should automatically recover PR context and push to the correct branch

Real-world example

# Before compaction - Claude knows:
- PR #162 on branch feature/139-xchen-hook-free-coll-comm-messaging
- Remote tracking: origin/feature/139-xchen-hook-free-coll-comm-messaging

# After compaction - Claude attempts:
git push origin HEAD:feature/93-xchen-collective-comm-view-model-refactor
# (wrong branch from stale tracking info)

Proposed Solution

Option 1: Auto-memory for PR workflows

When Claude starts working on a PR, automatically save to auto-memory:

## Active PR
- PR: #162
- URL: https://github.com/org/repo/pull/162
- Branch: feature/139-xchen-hook-free-coll-comm-messaging
- Remote: origin/feature/139-xchen-hook-free-coll-comm-messaging

Option 2: Context recovery protocol

After compaction, if git operations are requested, Claude should:

  1. Run gh pr view --json number,headRefName,url to recover PR context
  2. Run git branch -vv to verify current tracking relationship
  3. Reconcile any discrepancies before proceeding

Option 3: Compaction-aware context preservation

Include essential workflow state (active PR, push targets) in compaction summary.

Impact

  • Prevents accidental pushes to wrong branches
  • Reduces user interruptions to clarify context
  • Makes long PR review sessions more reliable

Environment

  • Claude Code (CLI and VSCode extension)
  • Any git repository with GitHub PRs

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗