Skip to content

Commit e0093eb

Browse files
ci: enhance Claude GitHub Actions and documentation (#1890)
* Claude PR Assistant workflow * Claude Code Review workflow * ci: enhance Claude GitHub Actions configuration - Add comprehensive code review prompts for CryoET Data Portal - Enable sticky comments and sequential thinking MCP - Add context-aware review criteria for frontend and Python code - Configure allowed tools for development commands - Add detailed custom instructions for repository context 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: migrate Claude commands to repository root - Move .claude/commands/ from frontend/ to repository root - Add comprehensive CLAUDE.md with project overview and commands - Remove duplicate command files from frontend directory - Consolidate development guidance in single location 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: enhance frontend development documentation - Add comprehensive command reference with individual linters - Document E2E testing setup and browser installation - Add CSS build tooling and typed CSS modules setup - Include development workflow and testing configuration - Document code quality standards and TypeScript setup 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: update PR creation to reference issues at top of body - Move issue reference to the very top of PR body as #ISSUE_NUMBER - Remove 'Closes #' keyword to avoid auto-closing issues - Add clear example of PR body format with issue reference - Clarify that issue number should be on its own line --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent af4dc6f commit e0093eb

File tree

6 files changed

+596
-45
lines changed

6 files changed

+596
-45
lines changed

frontend/.claude/commands/create-commits.md renamed to .claude/commands/create-commits.md

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,74 @@ This command automates the creation of logical, well-structured commits with int
55
## Command Usage
66

77
- `create-commits` - Basic usage with current branch
8-
- `create-commits --base develop` - Create commits with custom base branch reference
9-
10-
### Flag Details
11-
12-
- `--base <branch-name>` - Specify the base branch for reference (default: main)
13-
- Useful when working with feature branches or dependent branches
14-
- Helps determine which changes are new since branching from base
158

169
## Workflow
1710

1811
### 1. Branch Management
1912

2013
- Check current branch name using `git branch --show-current`
21-
- Determine base branch (default: `main`, or value from `--base` flag)
22-
- Validate base branch exists: `git show-ref --verify refs/heads/<base-branch>` or `git ls-remote --heads origin <base-branch>`
14+
- Determine base branch (default: `main`)
15+
- Validate base branch exists: `git show-ref --verify refs/heads/main` or `git ls-remote --heads origin main`
2316
- If current branch is same as base branch:
2417
- Analyze staged and unstaged changes to determine scope
2518
- Create new branch with format: `<scope>/auto-<timestamp>-<short-description>`
2619
- Example: `feat/auto-20250625-dataset-metadata-updates`
2720
- If current branch is different from base branch:
2821
- Use existing branch for commit creation
29-
- Verify branch is not behind remote base branch: `git merge-base --is-ancestor origin/<base-branch> HEAD`
22+
- Verify branch is not behind remote base branch: `git merge-base --is-ancestor origin/main HEAD`
3023

3124
### 2. Pre-Commit Validation
3225

3326
Execute the following commands in sequence and stop if any fail:
3427

35-
- Run `pnpm lint` to check for linting issues
36-
- If linting fails, run `pnpm lint:fix` to auto-fix issues
37-
- Run `pnpm data-portal type-check` to verify TypeScript types
28+
**For Frontend Changes:**
29+
30+
- Run `cd frontend && pnpm lint` to check for linting issues
31+
- If linting fails, run `cd frontend && pnpm lint:fix` to auto-fix issues
32+
- Run `cd frontend && pnpm data-portal type-check` to verify TypeScript types
3833
- If type check fails, report specific errors and require manual fixes before proceeding
3934

35+
**For Python Client Changes:**
36+
37+
- Run `cd client/python/cryoet_data_portal && make coverage` to run Python tests
38+
- If tests fail, report specific errors and require manual fixes before proceeding
39+
40+
**For Documentation Changes:**
41+
42+
- Run `cd docs && make html` to build documentation
43+
- If build fails, report specific errors and require manual fixes before proceeding
44+
4045
### 3. Change Analysis and Commit Splitting
4146

4247
Analyze all staged and unstaged changes to intelligently group them:
4348

4449
#### File Grouping Logic:
4550

46-
- **UI Components**: Group `*.tsx` files in `/components/` together
47-
- **GraphQL Operations**: Group `*.server.ts` files in `/graphql/` together
48-
- **Type Definitions**: Group `__generated_v2__/**/*.ts` files together
49-
- **Translations**: Group `translation.json` changes separately
50-
- **Configuration**: Group config files (`*.config.*`, `package.json`, etc.) together
51-
- **Tests**: Group test files (`*.test.*`, `*.spec.*`) together
52-
- **Documentation**: Group `*.md` files together
51+
**Frontend Changes:**
52+
53+
- **UI Components**: Group `frontend/**/*.tsx` files in `/components/` together
54+
- **GraphQL Operations**: Group `frontend/**/*.server.ts` files in `/graphql/` together
55+
- **Type Definitions**: Group `frontend/**/__generated_v2__/**/*.ts` files together
56+
- **Translations**: Group `frontend/**/translation.json` changes separately
57+
- **Frontend Config**: Group frontend config files (`frontend/**/*.config.*`, `frontend/package.json`, etc.) together
58+
- **Frontend Tests**: Group frontend test files (`frontend/**/*.test.*`, `frontend/**/*.spec.*`) together
59+
60+
**Python Client Changes:**
61+
62+
- **Python Source**: Group `client/python/**/*.py` files by module
63+
- **Python Tests**: Group `client/python/**/test_*.py` files together
64+
- **Python Config**: Group Python config files (`client/python/**/pyproject.toml`, `client/python/**/Makefile`, etc.) together
65+
66+
**Documentation Changes:**
67+
68+
- **Docs**: Group `docs/**/*.md`, `docs/**/*.rst` files together
69+
- **Website Docs**: Group `website-docs/**/*.mdx` files together
70+
71+
**Repository-wide Changes:**
72+
73+
- **Root Configuration**: Group root config files (`*.config.*`, `package.json`, `pyproject.toml`, etc.) together
74+
- **CI/CD**: Group `.github/**/*` files together
75+
- **Root Documentation**: Group root `*.md` files together
5376

5477
#### Commit Creation Strategy:
5578

@@ -98,25 +121,31 @@ For each commit group:
98121

99122
### Lint Failures:
100123

101-
- Attempt auto-fix with `pnpm lint:fix`
124+
- Attempt auto-fix with `cd frontend && pnpm lint:fix`
102125
- If still failing, list specific errors and pause for manual resolution
103126

104127
### Type Check Failures:
105128

106129
- Display TypeScript errors clearly
107130
- Require manual fixes before proceeding
108-
- Suggest running `pnpm data-portal build:codegen` if GraphQL types are stale
131+
- Suggest running `cd frontend && pnpm data-portal build:codegen` if GraphQL types are stale
132+
133+
### Python Test Failures:
134+
135+
- Display Python test errors clearly
136+
- Require manual fixes before proceeding
137+
- Suggest running `cd client/python/cryoet_data_portal && make test-infra` if test infrastructure needs setup
109138

110139
### Git Conflicts:
111140

112-
- If branch is behind base branch, suggest rebasing first: `git rebase origin/<base-branch>`
141+
- If branch is behind base branch, suggest rebasing first: `git rebase origin/main`
113142
- If conflicts exist, pause and request manual resolution
114143

115144
### Base Branch Validation:
116145

117146
- If specified base branch doesn't exist locally or remotely, list available branches and exit
118147
- If current branch is the same as base branch, require creation of new branch first
119-
- If base branch is not accessible, suggest fetching: `git fetch origin <base-branch>`
148+
- If base branch is not accessible, suggest fetching: `git fetch origin main`
120149

121150
### Empty Changes:
122151

@@ -145,10 +174,10 @@ After successful commit creation:
145174

146175
### Base Branch Validation Requirements:
147176

148-
1. **Branch Existence Check**: Verify base branch exists using `git show-ref --verify refs/heads/<base-branch>` (local) or `git ls-remote --heads origin <base-branch>` (remote)
149-
2. **Branch Accessibility**: Ensure base branch is up-to-date with remote: `git fetch origin <base-branch>`
177+
1. **Branch Existence Check**: Verify base branch exists using `git show-ref --verify refs/heads/main` (local) or `git ls-remote --heads origin main` (remote)
178+
2. **Branch Accessibility**: Ensure base branch is up-to-date with remote: `git fetch origin main`
150179
3. **Self-Reference Prevention**: Prevent creating commits when current branch equals base branch without creating new branch first
151-
4. **Branch Relationship Validation**: Check if current branch has diverged from base branch using `git merge-base <base-branch> HEAD`
180+
4. **Branch Relationship Validation**: Check if current branch has diverged from base branch using `git merge-base main HEAD`
152181

153182
## Workflow Summary
154183

Lines changed: 78 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,45 @@ This command automates the creation of pull requests from existing commits. It s
1919
- `--draft` - Create PR in draft mode
2020
- `--issue <number>` - Link PR to issue number
2121

22+
## Argument Parsing
23+
24+
```bash
25+
# Parse command line arguments
26+
DRAFT_FLAG=false
27+
ISSUE_NUMBER=""
28+
BASE_BRANCH="main"
29+
30+
# Parse arguments
31+
while [[ $# -gt 0 ]]; do
32+
case $1 in
33+
--draft)
34+
DRAFT_FLAG=true
35+
shift
36+
;;
37+
--issue)
38+
ISSUE_NUMBER="$2"
39+
shift 2
40+
;;
41+
--issue=*)
42+
ISSUE_NUMBER="${1#*=}"
43+
shift
44+
;;
45+
--base)
46+
BASE_BRANCH="$2"
47+
shift 2
48+
;;
49+
--base=*)
50+
BASE_BRANCH="${1#*=}"
51+
shift
52+
;;
53+
*)
54+
echo "Unknown argument: $1"
55+
shift
56+
;;
57+
esac
58+
done
59+
```
60+
2261
## Prerequisites
2362

2463
This command expects that `/create-commits` has been run first to create logical commits. The workflow will:
@@ -32,9 +71,9 @@ This command expects that `/create-commits` has been run first to create logical
3271
### 1. Branch and Commit Validation
3372

3473
- Check current branch name using `git branch --show-current`
35-
- Determine base branch (default: `main`, or value from `--base` flag)
36-
- Validate base branch exists: `git show-ref --verify refs/heads/<base-branch>` or `git ls-remote --heads origin <base-branch>`
37-
- Verify current branch is different from base branch
74+
- Determine base branch (using parsed BASE_BRANCH variable, default: `main`)
75+
- Validate base branch exists: `git show-ref --verify refs/heads/$BASE_BRANCH` or `git ls-remote --heads origin $BASE_BRANCH`
76+
- Verify current branch is different from base branch ($BASE_BRANCH)
3877
- Check for unpushed commits using `git log origin/<current-branch>..HEAD` or `git rev-list --count @{u}..HEAD`
3978
- If no unpushed commits exist, inform user and exit
4079

@@ -44,32 +83,48 @@ This command expects that `/create-commits` has been run first to create logical
4483
- If branch doesn't exist on remote OR has unpushed commits, push: `git push -u origin <branch-name>`
4584
- Analyze existing commit messages to determine primary scope and generate PR title
4685
- Create PR body with:
86+
- **Issue**: If ISSUE_NUMBER is provided, add "#$ISSUE_NUMBER" at the very top on its own line
4787
- **Summary**: Brief overview of changes made (derived from commit messages)
4888
- **Changes**: Bullet list of major modifications (from commit history)
4989
- **Testing**: Instructions for testing the changes
50-
- **Issue Link**: If `--issue` flag provided, add "Closes #<number>"
5190

5291
#### PR Title Generation:
5392

54-
- Analyze commit messages from `git log <base-branch>..HEAD --oneline`
93+
- Analyze commit messages from `git log $BASE_BRANCH..HEAD --oneline`
5594
- Extract primary scope from most recent or most significant commit
5695
- Use format: `<primary-scope>: <concise-description>`
5796
- Example: `feat: add dataset metadata display functionality`
5897

98+
#### PR Body Format:
99+
100+
When ISSUE_NUMBER is provided, the PR body should start with the issue reference on its own line:
101+
```
102+
#1806
103+
104+
## Summary
105+
Brief overview of changes...
106+
107+
## Changes
108+
- List of modifications...
109+
110+
## Testing
111+
- Testing instructions...
112+
```
113+
114+
When no issue number is provided, start directly with the Summary section.
115+
59116
#### PR Creation Command:
60117

61118
```bash
62119
gh pr create \
63120
--title "<scope>: <title>" \
64121
--body "<generated-body>" \
65-
$(if draft flag: --draft) \
122+
$(if $DRAFT_FLAG; then echo "--draft"; fi) \
66123
--head <branch-name> \
67-
--base <base-branch>
124+
--base $BASE_BRANCH
68125
```
69126

70-
Where `<base-branch>` is determined by:
71-
- Value from `--base` flag if provided
72-
- Default to `main` if no `--base` flag specified
127+
Where the base branch is determined by the parsed BASE_BRANCH variable (default: `main`)
73128

74129
## Error Handling
75130

@@ -80,14 +135,14 @@ Where `<base-branch>` is determined by:
80135

81136
### Git Conflicts:
82137

83-
- If branch is behind base branch, suggest rebasing first: `git rebase origin/<base-branch>`
138+
- If branch is behind base branch, suggest rebasing first: `git rebase origin/$BASE_BRANCH`
84139
- If conflicts exist, pause and request manual resolution
85140

86141
### Base Branch Validation:
87142

88143
- If specified base branch doesn't exist locally or remotely, list available branches and exit
89144
- If current branch is the same as base branch, inform user they need to create commits on a feature branch first
90-
- If base branch is not accessible, suggest fetching: `git fetch origin <base-branch>`
145+
- If base branch is not accessible, suggest fetching: `git fetch origin $BASE_BRANCH`
91146

92147
### Push Failures:
93148

@@ -100,24 +155,29 @@ After successful PR creation:
100155

101156
1. Display PR URL
102157
2. Show commit summary with messages (from git log)
103-
3. Confirm if created as draft (if applicable)
104-
4. Show linked issue number (if applicable)
158+
3. Confirm if created as draft (if DRAFT_FLAG is true)
159+
4. Show linked issue number (if ISSUE_NUMBER is provided)
105160
5. Display instructions for next steps (review process, testing, etc.)
106161

107162
## Advanced Features
108163

109164
### PR Body Generation:
110165

166+
- If issue number is provided, place it at the very top as "#ISSUE_NUMBER" on its own line
111167
- Parse commit messages to extract meaningful summary
112168
- Group related commits to describe feature scope
113-
- Include testing instructions based on changed files
169+
- Include testing instructions based on changed files:
170+
- **Frontend changes**: Include `cd frontend && pnpm test` and `cd frontend && pnpm e2e`
171+
- **Python client changes**: Include `cd client/python/cryoet_data_portal && make coverage`
172+
- **Documentation changes**: Include `cd docs && make html`
173+
- Note: Do NOT use closing keywords like "Closes", "Fixes", or "Resolves" with issue references
114174

115175
### Base Branch Validation Requirements:
116176

117-
1. **Branch Existence Check**: Verify base branch exists using `git show-ref --verify refs/heads/<base-branch>` (local) or `git ls-remote --heads origin <base-branch>` (remote)
118-
2. **Branch Accessibility**: Ensure base branch is up-to-date with remote: `git fetch origin <base-branch>`
177+
1. **Branch Existence Check**: Verify base branch exists using `git show-ref --verify refs/heads/$BASE_BRANCH` (local) or `git ls-remote --heads origin $BASE_BRANCH` (remote)
178+
2. **Branch Accessibility**: Ensure base branch is up-to-date with remote: `git fetch origin $BASE_BRANCH`
119179
3. **Self-Reference Prevention**: Prevent creating PR where current branch equals base branch
120-
4. **Branch Relationship Validation**: Check if current branch has diverged from base branch using `git merge-base <base-branch> HEAD`
180+
4. **Branch Relationship Validation**: Check if current branch has diverged from base branch using `git merge-base $BASE_BRANCH HEAD`
121181

122182
## Workflow Summary
123183

0 commit comments

Comments
 (0)