[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:
- Which PR is being worked on - The PR number and URL
- The correct push target branch - Especially when local branch name differs from remote tracking branch
- PR review comments - Which comments have been addressed vs. pending
Reproduction
- Start working on a PR (e.g.,
gh pr view 162) - Make multiple commits responding to review comments
- Wait for context compaction to occur (or trigger manually)
- 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:
- Run
gh pr view --json number,headRefName,urlto recover PR context - Run
git branch -vvto verify current tracking relationship - 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
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗