Skip to content

Commit 5f0edcd

Browse files
authored
Merge branch 'master' into fix/copy-mnemonic-toast
2 parents b0eb30f + 28f37a4 commit 5f0edcd

File tree

3 files changed

+180
-5
lines changed

3 files changed

+180
-5
lines changed

.claude/commands/pr.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
description: Create a PR on GitHub for the current branch
3+
argument_hint: "[branch] [--dry] [--draft]"
4+
allowed_tools: Bash, Read, Glob, Grep, Write, AskUserQuestion, mcp__github__create_pull_request, mcp__github__list_pull_requests, mcp__github__get_file_contents, mcp__github__issue_read
5+
---
6+
7+
Create a PR on GitHub using the `gh` CLI for the currently checked-out branch.
8+
9+
**Examples:**
10+
- `/pr` - Interactive mode, prompts for PR type
11+
- `/pr master` - Interactive with explicit base branch
12+
- `/pr --dry` - Generate description only, save to `.ai/`
13+
- `/pr --draft` - Create as draft PR
14+
- `/pr develop --draft` - Draft PR against develop branch
15+
16+
## Steps
17+
18+
### 1. Check for Existing PR
19+
Run `gh pr view --json number,url 2>/dev/null` to check if a PR already exists for this branch.
20+
- If PR exists: Output `PR already exists: [URL]` and stop
21+
- If no PR: Continue
22+
23+
### 2. Parse Arguments
24+
- `--dry`: Skip PR creation, only generate and save description
25+
- `--draft`: Create PR as draft
26+
- First non-flag argument: base branch (default: `master`)
27+
- **If no flags provided**: Use `AskUserQuestion` to prompt user:
28+
- Open PR (create and publish)
29+
- Draft PR (create as draft)
30+
- Dry run (save locally only)
31+
32+
### 3. Gather Context
33+
- Get current branch name: `git branch --show-current`
34+
- Read PR template from `.github/pull_request_template.md`
35+
- Fetch 10 most recent PRs (open or closed) from `synonymdev/bitkit-android` for writing style reference
36+
- Run `git log $base..HEAD --oneline` for commit messages
37+
- Run `git diff $base...HEAD --stat` for understanding scope of changes
38+
39+
### 4. Extract Linked Issues
40+
Scan commits for issue references:
41+
- Pattern to match: `#123` (just the issue number reference)
42+
- Extract unique issue numbers: `git log $base..HEAD --oneline | grep -oE "#[0-9]+" | sort -u`
43+
- Fetch each issue title: `gh api "repos/synonymdev/bitkit-android/issues/NUMBER" --jq '.title'`
44+
- These will be used to start the PR description with linking keywords (see Step 6)
45+
46+
### 5. Identify Suggested Reviewers
47+
Find potential reviewers based on:
48+
- `.github/CODEOWNERS` file patterns (if exists)
49+
- Recent contributors to changed files: `git log --format='%an' -- $(git diff $base..HEAD --name-only) | sort | uniq -c | sort -rn | head -3`
50+
- Exclude the current user from suggestions
51+
52+
### 6. Generate PR Description
53+
Starting from the template in `.github/pull_request_template.md`:
54+
55+
**Title Rules:**
56+
- Format: `prefix: title` (e.g., `feat: add user settings screen`)
57+
- Keep under 50 characters
58+
- Use branch name as concept inspiration
59+
- Prefixes: `feat`, `fix`, `chore`, `refactor`, `docs`, `test`
60+
61+
**Issue Linking (at the very start):**
62+
If linked issues were found in commit messages, begin the PR description with linking keywords:
63+
- Use `Fixes #123` for bug fixes
64+
- Use `Closes #123` for features/enhancements
65+
- One per line, before the "This PR..." opening separated by one empty line
66+
- Reference: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests
67+
68+
Example:
69+
```
70+
Fixes #528
71+
Closes #418
72+
73+
This PR adds support for...
74+
```
75+
76+
**Opening Format:**
77+
- Single change: Start with "This PR [verb]s..." as a complete sentence
78+
- Example: `This PR adds a Claude Code /pr command for generating PRs.`
79+
- Multiple changes: Start with "This PR:" followed by a numbered list
80+
- Example:
81+
```
82+
This PR:
83+
84+
1. Adds a Claude Code /pr command for generating PRs
85+
2. Fixes issue preventing Claude Code reviews to be added as PR comments
86+
3. Updates reviews workflow to minimize older review comments
87+
```
88+
- Each list item should start with a verb (Adds, Fixes, Updates, Removes, Refactors, etc.)
89+
90+
**Description Rules:**
91+
- Base content around all commit messages in the branch
92+
- Use branch name as the conceptual anchor
93+
- Match writing style of recent PRs
94+
- Focus on functionality over technical details
95+
- Avoid excessive bold formatting like `**this:** that`
96+
- Minimize code references like `TheClassName` or `someFunctionName`
97+
- Exception: for refactoring PRs (1:10 ratio of functionality to code changes), more technical detail is ok
98+
99+
**QA Notes / Testing Scenarios:**
100+
- Structure with numbered headings and steps
101+
- Make steps easily referenceable
102+
- Be specific about what to test and expected outcomes
103+
104+
**Preview Section:**
105+
- Create placeholders for media: `IMAGE_1`, `VIDEO_2`, etc.
106+
- Add code comment under each placeholder describing what it should show
107+
- Example: `<!-- VIDEO_1: Record the send flow by scanning a LN invoice and setting amount to 5000 sats -->`
108+
109+
### 7. Save PR Description
110+
Before creating the PR:
111+
- Get next PR number: `gh api "repos/synonymdev/bitkit-android/issues?per_page=1&state=all&sort=created&direction=desc" --jq '.[0].number'` then add 1
112+
- Create `.ai/` directory if it doesn't exist
113+
- Save to `.ai/pr_NN.md` where `NN` is the predicted PR number
114+
115+
### 8. Create the PR (unless --dry)
116+
If not dry run:
117+
```bash
118+
gh pr create --base $base --title "..." --body "..." [--draft]
119+
```
120+
- Add `--draft` flag if draft mode selected
121+
- If actual PR number differs from predicted, rename the saved file
122+
123+
### 9. Output Summary
124+
125+
**If PR created:**
126+
```
127+
PR Created: [PR URL]
128+
Saved: .ai/pr_NN.md
129+
130+
Suggested reviewers:
131+
- @username1 (X files modified recently)
132+
- @username2 (CODEOWNER)
133+
134+
## TODOs
135+
- [ ] IMAGE_1: [description]
136+
- [ ] VIDEO_2: [description]
137+
```
138+
139+
**If dry run:**
140+
```
141+
Dry run complete
142+
Saved: .ai/pr_NN.md
143+
144+
To create PR: /pr [--draft]
145+
146+
Suggested reviewers:
147+
- @username1 (X files modified recently)
148+
- @username2 (CODEOWNER)
149+
150+
## TODOs
151+
- [ ] IMAGE_1: [description]
152+
- [ ] VIDEO_2: [description]
153+
```
154+
155+
List all media placeholders as TODOs with their descriptions.

.github/workflows/claude-code-review.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,45 @@ jobs:
3131
with:
3232
fetch-depth: 1
3333

34+
- name: Minimize old Claude comments
35+
env:
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
REPO="${{ github.repository }}"
39+
PR_NUMBER="${{ github.event.pull_request.number }}"
40+
41+
# Minimize issue comments from claude[bot]
42+
gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "claude[bot]") | .node_id' | while read -r node_id; do
43+
if [ -n "$node_id" ]; then
44+
echo "Minimizing comment: $node_id"
45+
gh api graphql -f query='
46+
mutation($id: ID!) {
47+
minimizeComment(input: {subjectId: $id, classifier: OUTDATED}) {
48+
minimizedComment { isMinimized }
49+
}
50+
}' -f id="$node_id" || true
51+
fi
52+
done
53+
3454
- name: Run Claude Code Review
3555
id: claude-review
3656
uses: anthropics/claude-code-action@v1
3757
with:
3858
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39-
use_sticky_comment: true
4059
additional_permissions: "actions:read"
4160
prompt: |
4261
REPO: ${{ github.repository }}
4362
PR NUMBER: ${{ github.event.pull_request.number }}
4463
45-
Please review this pull request and provide feedback on:
64+
Please review this pull request and provide meaningful feedback on:
4665
- Code quality and best practices
4766
- Potential bugs or issues
4867
- Performance considerations
4968
- Security concerns
5069
- Test coverage
5170
52-
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
71+
Use the repository's CLAUDE.md for guidance on style and conventions.
72+
Be constructive, helpful, terse and stay relevant in your feedback.
5373
5474
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
5575
# or https://code.claude.com/docs/en/cli-reference for available options
56-
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ google-services.json
1818
.env
1919
*.keystore
2020
!debug.keystore
21-
keystore.properties
21+
keystore.*
22+
!*.template

0 commit comments

Comments
 (0)