-
-
Notifications
You must be signed in to change notification settings - Fork 635
Add Claude Code GitHub Workflow #1255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sindresorhus
wants to merge
6
commits into
main
Choose a base branch
from
add-claude-github-actions-1759198490273
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+190
−0
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
02b8546
"Claude PR Assistant workflow"
sindresorhus 219cc72
"Claude Code Review workflow"
sindresorhus 32b147e
Add CLAUDE.md instructions file
sindresorhus 6e27ebc
Update claude-code-review.yml
sindresorhus 3a8c129
Update claude-code-review.yml
sindresorhus c785a2c
Update claude.yml
sindresorhus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Claude Code Review | ||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
jobs: | ||
claude-review: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: read | ||
issues: read | ||
id-token: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v5 | ||
with: | ||
fetch-depth: 1 | ||
- name: Run Claude Code Review | ||
id: claude-review | ||
uses: anthropics/claude-code-action@v1 | ||
with: | ||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
prompt: | | ||
REPO: ${{ github.repository }} | ||
PR NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
Please review this pull request and provide feedback on: | ||
- Code quality and best practices | ||
- Potential bugs or issues | ||
- Performance considerations | ||
- Security concerns | ||
- Test coverage | ||
|
||
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback. | ||
|
||
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR. | ||
|
||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md | ||
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options | ||
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Claude Code | ||
on: | ||
issue_comment: | ||
types: [created] | ||
pull_request_review_comment: | ||
types: [created] | ||
issues: | ||
types: [opened, assigned] | ||
pull_request_review: | ||
types: [submitted] | ||
jobs: | ||
claude: | ||
if: | | ||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || | ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || | ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || | ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: read | ||
issues: read | ||
sindresorhus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
id-token: write | ||
actions: read # Required for Claude to read CI results on PRs | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
- name: Run Claude Code | ||
id: claude | ||
uses: anthropics/claude-code-action@v1 | ||
with: | ||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} | ||
additional_permissions: | | ||
actions: read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# type-fest | ||
|
||
TypeScript utility types library. Pure type-level programming—no runtime code. | ||
|
||
**Read `.github/contributing.md` for complete guidelines.** | ||
|
||
## Commands | ||
|
||
```bash | ||
npm test # MUST pass before committing (runs all below) | ||
npm run test:tsc # TypeScript compiler | ||
npm run test:tsd # Type tests (tsd) | ||
npm run test:xo # Linter | ||
``` | ||
|
||
## File Structure | ||
|
||
``` | ||
source/type-name.d.ts → Type definition (.d.ts REQUIRED) | ||
test-d/type-name.ts → Tests (tsd) | ||
index.d.ts → Export (MUST add, lint enforces) | ||
readme.md → API docs (add to category) | ||
source/internal/ → Shared helpers (not exported) | ||
``` | ||
|
||
## Code Patterns | ||
|
||
```ts | ||
// ✅ CORRECT | ||
import type {IsNever} from './is-never.d.ts'; // Include .d.ts | ||
export type MyType<Value extends string> = ... // Descriptive names (not T/U) | ||
export {}; // REQUIRED at end | ||
|
||
// ❌ WRONG | ||
import type {IsNever} from './is-never'; // Missing .d.ts | ||
export type MyType<T> = ...; // Single-letter | ||
|
||
/** | ||
Creates a tuple type of specified length with elements of specified type. | ||
|
||
Use-cases: | ||
- Define fixed-length arrays with specific types | ||
|
||
@example | ||
``` | ||
import type {TupleOf} from 'type-fest'; | ||
type RGB = TupleOf<3, number>; //=> [number, number, number] | ||
``` | ||
|
||
@category Array | ||
*/ | ||
export type TupleOf<Length extends number, Fill = unknown> = ...; | ||
export {}; | ||
``` | ||
|
||
Type params: `Value`, `Target`, `Item`, `Length`, `Element`, `Key` (not `T`, `U`, `V`, `K`) | ||
Docs: No `*` prefix. First line → readme. Include use-cases, examples, `@category`. | ||
|
||
## Testing | ||
|
||
**ALWAYS test edge cases** (`any`, `never`, `unknown`). | ||
|
||
```ts | ||
expectType<string>('' as MyType<'foo'>); // Basic | ||
expectType<any>('' as MyType<any>); // any/never/unknown | ||
expectNotAssignable<MyType<'foo'>>({wrong: true}); // Negative | ||
expectError<MyType<number>>(); // Should error | ||
``` | ||
|
||
Study: `source/tuple-of.d.ts`, `is-equal.d.ts`, `literal-union.d.ts`, `internal/*.d.ts` | ||
|
||
## Workflow | ||
|
||
1. Research - Study `source/` similar types + online research | ||
2. Define - `source/type-name.d.ts` with docs | ||
3. Test - `test-d/type-name.ts` with edge cases | ||
4. Export - Add to `index.d.ts` + readme.md | ||
5. Verify - `npm test` must pass | ||
6. Commit - ``Add `TypeName` type`` or `` `TypeName`: Fix description`` | ||
|
||
## Critical Rules | ||
|
||
1. Import paths MUST include `.d.ts` extension | ||
2. Files MUST end with `export {};` | ||
3. Types MUST be exported from `index.d.ts` | ||
4. Type params MUST use descriptive names (not `T`/`U`) | ||
5. MUST test `any`, `never`, `unknown` edge cases | ||
6. First doc line MUST be concise (goes in readme) | ||
7. Use realistic examples with `//=>` comments | ||
8. Include `@category` tags | ||
9. Fix lint issues, don't disable rules | ||
|
||
## Type Programming | ||
|
||
- Conditionals: `T extends U ? X : Y` | ||
- Recursion: `type Loop<T, Acc> = ... Loop<...> ...` | ||
- Extract: `infer Item` | ||
- Distribute: `T extends any ? ... : never` | ||
- Count via tuple `['length']` | ||
- Union distribution is tricky—test it | ||
|
||
## Philosophy | ||
|
||
- Correctness > cleverness | ||
- Real problems only | ||
- Docs teach how, not what | ||
- Edge cases mandatory | ||
- One concept per PR | ||
- Descriptive names > brevity | ||
|
||
## Troubleshooting | ||
|
||
- Tests fail? Check `.d.ts` imports, `export {};`, edge cases (`any`, `never`, `unknown`) | ||
- Lint errors? Add to `index.d.ts`, fix issues (don't disable rules) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.