Skip to content

Conversation

@ranyhb
Copy link
Contributor

@ranyhb ranyhb commented Jan 29, 2026

Overview

Adds a new workflow example (pr-review-with-caching.yml) that demonstrates how to use session caching with commit tracking to enable incremental PR reviews.

Key Features

  • Session Caching: Caches Claude's session (~/.claude/projects) per PR and commit using GitHub Actions cache
  • Commit Tracking: Tracks last reviewed commit SHA in .last-reviewed-commit file
  • Dual Prompt System: Two environment variables for smart prompt selection:
    • PROMPT_FULL: Comprehensive prompt for first review
    • PROMPT_SIMPLE: Incremental prompt for subsequent reviews
  • Session Continuity: Uses --continue flag when previous session exists
  • Git Operations: Supports git diff, git log, and git cat-file for analyzing changes

How It Works

First Commit (Full Review):

  1. No cached session exists
  2. Loads PROMPT_FULL with comprehensive review instructions
  3. Claude performs full PR review
  4. Saves commit SHA to .last-reviewed-commit
  5. Session cached with unique key

Subsequent Commits (Incremental Review):

  1. Cache restored from previous commit via prefix match
  2. Reads .last-reviewed-commit to get previous commit SHA
  3. Loads PROMPT_SIMPLE with {LAST_COMMIT} variable injected
  4. Claude uses --continue flag to resume from previous session
  5. Reviews ONLY changes since last commit using git diff/log
  6. Saves new commit SHA and updates cache

Benefits

  • Faster reviews - No re-analysis of entire PR every commit
  • 🧠 Context preservation - Remembers previous discussions and decisions
  • 🎯 Focused feedback - Only reviews new changes
  • 💾 Per-PR isolation - Each PR has its own cache namespace

Testing

This workflow can be tested by:

  1. Creating a test PR with multiple commits
  2. Observing the full review on first commit
  3. Pushing additional commits and seeing incremental reviews
  4. Checking GitHub Actions cache for session persistence

@ranyhb ranyhb changed the title exmpale using caching for pr review Add example workflow for PR review with session caching Jan 29, 2026
@ranyhb
Copy link
Contributor Author

ranyhb commented Jan 29, 2026

@claude what do u think ?

@ranyhb
Copy link
Contributor Author

ranyhb commented Jan 29, 2026

@ashwin-ant what do u think? already tested and working

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant