ci: code review: pass commit messages into prompt context
What changed, and why it matters
This commit changes Electrum's internal CI (continuous integration) script that runs an automated code review using Claude. It simply adds the git commit messages of a pull request into the prompt sent to Claude, so the AI has more context. It does not touch any wallet, networking, cryptography, or user-facing code, and there is no security issue in the change itself.
No security action required. This is a benign CI tooling improvement. Reviewers may optionally verify that commit messages do not contain secrets before they are passed into the prompt, but this is already standard practice for commit history in a public repository.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies contrib/ci/claude_security_review.py to call git log origin/<base>..HEAD, pass the resulting commit messages into build_prompt(), and include a new ‘## Commit messages’ section in the prompt before the diff. This is a tooling-only enhancement for an automated review helper. No executable product code is changed, no secrets are exposed, and no new attack surface is introduced beyond what the CI script already had (it already read the diff).
Changed components
contrib/ci/claude_security_review.pyInspect captured patch +13 / −2
diff --git a/contrib/ci/claude_security_review.py b/contrib/ci/claude_security_review.py
index 76d7280..ea1de7e 100755
--- a/contrib/ci/claude_security_review.py
+++ b/contrib/ci/claude_security_review.py
@@ -70,13 +70,17 @@ def get_pr_diff(base: str) -> str:
return git("diff", f"origin/{base}...HEAD")
+def get_commit_messages(base: str) -> str:
+ return git("log", f"origin/{base}..HEAD")
+
+
def changed_files_from_diff(diff: str) -> str:
return "\n".join(
m.group(1) for m in re.finditer(r"^diff --git a/.+ b/(.+)$", diff, re.MULTILINE)
)
-def build_prompt(diff: str, changed_files: str) -> str:
+def build_prompt(diff: str, changed_files: str, commit_messages: str) -> str:
with open(PROMPT_FILE) as f:
instructions = f.read()
@@ -84,6 +88,7 @@ def build_prompt(diff: str, changed_files: str) -> str:
f"{instructions}\n\n"
f"---\n\n"
f"## Changed files\n\n```\n{changed_files}\n```\n\n"
+ f"## Commit messages\n\n```\n{commit_messages}\n```\n\n"
f"## Diff\n\n```diff\n{diff}\n```"
)
@@ -217,6 +222,12 @@ def main() -> int:
print("Empty diff -- nothing to review.")
return 0
+ try:
+ commit_messages = get_commit_messages(base_branch)
+ except subprocess.CalledProcessError as exc:
+ print(f"ERROR: git log failed: {exc}")
+ return 2
+
changed_files = changed_files_from_diff(diff)
file_count = len(changed_files.splitlines())
print(f"Reviewing changes across {file_count} file(s)...")
@@ -225,7 +236,7 @@ def main() -> int:
print(f"ERROR: diff is {len(diff)} chars, exceeds maximum of {MAX_DIFF_CHARS}. Skipping review.")
return 2
- prompt = build_prompt(diff, changed_files)
+ prompt = build_prompt(diff, changed_files, commit_messages)
print(f"\nRunning Claude Code review (model: {CLAUDE_MODEL})...\n")
review = run_claude(prompt)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.