Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
prreview (0.7.0)
prreview (0.8.0)
base64 (~> 0.2)
clipboard (~> 2.0)
faraday-retry (~> 2.3)
Expand Down Expand Up @@ -113,6 +113,7 @@ GEM

PLATFORMS
arm64-darwin-24
arm64-darwin-25
x86_64-darwin-24

DEPENDENCIES
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Or use more options:
```
prreview --help
prreview https://github.com/owner/repo/pull/123 --all-content --prompt "Are there any security issues?"
prreview https://github.com/owner/repo/pull/123 --request-context
```

Now, just paste the PR details into ChatGPT, Claude, or any LLM for review.
Expand Down Expand Up @@ -49,6 +50,7 @@ However, in the future we might add some optional integrations.
- A well-written PR and linked issue description make a big difference — and are good practice anyway.
- Run `prreview` after you've thoroughly reviewed the PR. It works best when you understand the changes well.
- Don't hesitate to try different LLMs or refresh the response to see if something new comes up.
- Use `--request-context` when you want the LLM to ask for missing files or documentation before reviewing.
- Use `--all-content` and other extra options — they can significantly improve results for some PRs.
- After the LLM responds, to potentially uncover more issues:
- Ask "Anything else?".
Expand Down
17 changes: 9 additions & 8 deletions lib/prreview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@

module Prreview
class CLI
DEFAULT_PROMPT = <<~PROMPT
Your task is to review this pull request.
Patch lines starting with `-` are deleted.
Patch lines starting with `+` are added.
Focus on new problems, not ones that were already there.
Do you see any problems?
PROMPT
PROMPTS_DIR = File.expand_path('../prompts', __dir__)

DEFAULT_LINKED_ISSUES_LIMIT = 5

Expand Down Expand Up @@ -59,7 +53,7 @@ def process
private

def parse_options!
@prompt = DEFAULT_PROMPT
@prompt = load_prompt(:default)
@include_content = false
@linked_issues_limit = DEFAULT_LINKED_ISSUES_LIMIT
@optional_files = []
Expand All @@ -80,6 +74,9 @@ def parse_options!
parser.on('-o', '--optional PATHS', 'Comma‑separated paths to local files (relative or absolute, e.g. docs/description.md,/etc/hosts)') do |v|
@optional_files = v.split(',').map(&:strip)
end
parser.on('-c', '--request-context', 'Ask the LLM what extra context it needs before reviewing') do
@prompt = load_prompt(:request_context)
end
parser.on_tail('-v', '--version', 'Show version') do
puts VERSION
exit
Expand Down Expand Up @@ -334,5 +331,9 @@ def copy_result_to_clipboard
Clipboard.copy(@xml)
puts 'XML prompt generated and copied to your clipboard.'
end

def load_prompt(name)
File.read(File.join(PROMPTS_DIR, "#{name}.md"))
end
end
end
2 changes: 1 addition & 1 deletion lib/prreview/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Prreview
VERSION = '0.7.0'
VERSION = '0.8.0'
end
5 changes: 5 additions & 0 deletions prompts/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Your task is to review this pull request.
Patch lines starting with `-` are deleted.
Patch lines starting with `+` are added.
Focus on new problems, not ones that were already there.
Do you see any problems?
7 changes: 7 additions & 0 deletions prompts/request_context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Your task is to review this pull request.
Patch lines starting with `-` are deleted.
Patch lines starting with `+` are added.
Focus on new problems, not ones that were already there.
Identify which extra context would improve your review (files, documentation, decisions, etc).
Ask for specific, grouped items or clarifications.
If nothing else is needed, say you can proceed.
19 changes: 19 additions & 0 deletions spec/prreview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,23 @@
expect(abort_message).to eq('Error: GITHUB_TOKEN is not set.')
end
end

describe 'when --request-context is used' do
around do |example|
original_argv = ARGV.dup
ARGV.replace(%w[https://github.com/owner/repo/pull/123 --request-context])

example.run

ARGV.replace(original_argv)
end

it 'loads the request context prompt' do
cli = described_class.allocate
cli.send(:parse_options!)

prompt = cli.instance_variable_get(:@prompt)
expect(prompt).to eq(cli.send(:load_prompt, :request_context))
end
end
end