Skip to content

Commit 80f501d

Browse files
authored
Merge pull request #81 from synonymdev/feat/claude-setup
chore: add claude code cli setup and github workflows
2 parents aaa627d + bdada9a commit 80f501d

56 files changed

Lines changed: 6258 additions & 3467 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Write|Edit",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "jq -r '.tool_input.file_path' | { read -r f; echo \"$f\" | grep -qE '\\.rs$' && rustfmt --edition 2021 \"$f\"; } 2>/dev/null || true",
10+
"timeout": 30,
11+
"statusMessage": "Formatting Rust..."
12+
}
13+
]
14+
}
15+
]
16+
}
17+
}

.claude/skills/build/SKILL.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: build
3+
description: Build platform bindings using build.sh. Pass a target as argument (ios, android, python, all). Use when you need to generate or test platform-specific bindings.
4+
disable-model-invocation: true
5+
---
6+
7+
Run `./build.sh $ARGUMENTS` from the project root.
8+
9+
If no arguments provided, ask the user which target to build (ios, android, python, all).
10+
11+
For release builds, remind the user to use `-r` with a version bump flag (`--patch`, `--minor`, or `--major`).

.claude/skills/verify/SKILL.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: verify
3+
description: Run clippy and tests to verify the codebase compiles cleanly and all tests pass. Use after making changes or before committing.
4+
---
5+
6+
Run the following checks in sequence, stopping on first failure:
7+
8+
1. `cargo clippy -- -D warnings` — ensure no lint warnings
9+
2. `cargo test` — run all tests
10+
11+
Report results concisely. If clippy or tests fail, show the relevant errors and suggest fixes.

.github/copilot-instructions.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# GitHub Copilot Code Review Instructions
2+
3+
When performing a code review, respond in English.
4+
5+
## Architecture & Patterns
6+
7+
When performing a code review, ensure new public types are properly exported via `src/lib.rs` for UniFFI binding generation.
8+
9+
When performing a code review, verify that modules follow the established structure: `mod.rs`, `types.rs`, `errors.rs`, `implementation.rs`, and optional `tests.rs`.
10+
11+
When performing a code review, check that UniFFI-exported types follow existing patterns (derive macros, enum representations, error types).
12+
13+
## Error Handling & Safety
14+
15+
When performing a code review, flag any use of `unwrap()` or `expect()` in non-test code and suggest proper error propagation with `?` or `Result`.
16+
17+
When performing a code review, ensure error types implement proper `Display` and `Error` traits and are exported for UniFFI.
18+
19+
When performing a code review, flag any `unsafe` blocks and verify they are necessary and well-documented.
20+
21+
## Code Quality & Readability
22+
23+
When performing a code review, ensure `cargo clippy` warnings are addressed — the project treats clippy warnings as errors.
24+
25+
When performing a code review, verify that `cargo fmt` formatting is applied consistently.
26+
27+
When performing a code review, focus on readability and avoid deeply nested match arms, replacing with early returns or helper functions where possible.
28+
29+
When performing a code review, ensure unused code is removed after refactoring.
30+
31+
When performing a code review, verify that existing utilities and helper functions are reused rather than creating duplicates.
32+
33+
## Dependencies & Platform
34+
35+
When performing a code review, verify that platform-specific dependencies use correct `#[cfg(target_os)]` guards (especially Trezor: BLE-only on iOS, USB+BLE elsewhere).
36+
37+
When performing a code review, check that new dependencies are justified and don't introduce unnecessary bloat to the FFI binary.
38+
39+
## Testing
40+
41+
When performing a code review, suggest tests for new functionality covering the most important cases.
42+
43+
When performing a code review, verify that tests use the established patterns (test modules in `tests.rs`, `#[cfg(test)]` gating).
44+
45+
## Bitcoin & Lightning Specific
46+
47+
When performing a code review, verify that Bitcoin/Lightning operations use proper types from the `bitcoin` and `bdk` crates.
48+
49+
When performing a code review, verify that proper Bitcoin and Lightning technical terms are used when naming code components.
50+
51+
## Build & Version
52+
53+
When performing a code review, check that version changes are synchronized across `Cargo.toml`, `Package.swift`, and `bindings/android/gradle.properties`.
54+
55+
When performing a code review, verify that changes to public API types don't break existing UniFFI bindings without updating the binding generation.

.github/pull_request_template.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Closes | Fixes | Resolves #ISSUE_ID -->
2+
<!-- Brief summary of the PR changes, linking to the related resources (issue/design/bug/etc) if applicable. -->
3+
4+
### Description
5+
6+
<!-- Extended summary of the changes, can be a list. -->
7+
8+
### Preview
9+
10+
<!-- Insert relevant screenshot / recording -->
11+
12+
### QA Notes
13+
14+
<!-- Add testing instructions for the PR reviewer to validate the changes. -->
15+
<!-- List the tests you ran, including regression tests if applicable. -->
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, ready_for_review, reopened]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
claude-review:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
pull-requests: write
17+
issues: write
18+
id-token: write
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v6
23+
with:
24+
fetch-depth: 1
25+
26+
- name: Minimize old Claude comments
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
REPO="${{ github.repository }}"
31+
PR_NUMBER="${{ github.event.pull_request.number }}"
32+
33+
# Minimize issue comments from claude[bot]
34+
gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "claude[bot]") | .node_id' | while read -r node_id; do
35+
if [ -n "$node_id" ]; then
36+
echo "Minimizing comment: $node_id"
37+
gh api graphql -f query='
38+
mutation($id: ID!) {
39+
minimizeComment(input: {subjectId: $id, classifier: OUTDATED}) {
40+
minimizedComment { isMinimized }
41+
}
42+
}' -f id="$node_id" || true
43+
fi
44+
done
45+
46+
- name: Run Claude Code Review
47+
id: claude-review
48+
uses: anthropics/claude-code-action@v1
49+
with:
50+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
51+
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
52+
plugins: 'code-review@claude-code-plugins'
53+
prompt: '/code-review:code-review --comment ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
54+
claude_args: |
55+
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Bash(git log:*),Bash(git diff:*),Bash(git blame:*),Read,Glob,Grep"

.github/workflows/claude.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') &&
17+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
18+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') &&
19+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') &&
21+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)) ||
22+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')) &&
23+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association))
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write # Allow creating branches/commits
27+
pull-requests: write # Allow pushing to PR branches
28+
issues: write # Allow updating issue comments
29+
id-token: write
30+
actions: read # Required for Claude to read CI results on PRs
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v6
34+
with:
35+
fetch-depth: 0 # Full history for git operations
36+
37+
- name: Run Claude Code
38+
id: claude
39+
uses: anthropics/claude-code-action@v1
40+
with:
41+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
42+
43+
# This is an optional setting that allows Claude to read CI results on PRs
44+
additional_permissions: |
45+
actions: read

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
target/
22
.idea/
33
.DS_Store
4+
.ai

AGENTS.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Rust FFI library (`bitkitcore`) providing Bitcoin & Lightning functionality with UniFFI-generated bindings for iOS (Swift), Android (Kotlin), and Python.
8+
9+
## Build
10+
11+
```bash
12+
cargo build # Rust library
13+
./build.sh <ios|android|python|all> # Platform bindings
14+
./build.sh -r --patch <target> # Bump version + build (--minor, --major)
15+
```
16+
17+
## Test
18+
19+
```bash
20+
cargo test # All tests
21+
cargo test modules::<module> # Single module (scanner, lnurl, onchain, activity, blocktank, trezor, pubky)
22+
```
23+
24+
## Lint & Format
25+
26+
```bash
27+
cargo clippy # Lint
28+
cargo fmt # Format Rust
29+
```
30+
31+
Android bindings use ktlint via Gradle plugin (`org.jlleitschuh.gradle.ktlint`), excluding generated code.
32+
33+
## Architecture
34+
35+
- `src/lib.rs` — UniFFI exports and module re-exports
36+
- `src/modules/` — Core modules: scanner, lnurl, onchain, activity, blocktank, trezor, pubky
37+
- `bindings/` — Platform-specific binding outputs (ios/, android/, python/)
38+
- `build.sh`, `build_ios.sh`, `build_android.sh`, `build_python.sh` — Build scripts
39+
40+
## Key Constraints
41+
42+
- **Version sync**: Version must match across `Cargo.toml`, `Package.swift`, and `bindings/android/gradle.properties`. Use `build.sh -r` to bump all three.
43+
- **UniFFI**: Public types exposed to bindings are declared in `src/lib.rs`. Follow existing UniFFI patterns when adding new types.
44+
- **Platform-specific deps**: Trezor uses Bluetooth-only on iOS, USB+Bluetooth on other platforms (see `Cargo.toml` target-specific dependencies).
45+
- **Android build**: `build_android.sh` temporarily modifies `Cargo.toml` crate-type and removes `example/main.rs` during build — don't run concurrent builds.
46+
47+
## Conventions
48+
49+
- Branch naming: `feat/*`, `fix/*`, `chore/*`

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

0 commit comments

Comments
 (0)