Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
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://code.claude.com/docs/en/cli-reference 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:*)"'
93 changes: 93 additions & 0 deletions .github/workflows/claude-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Claude Fix Issue

on:
issues:
types: [labeled]

jobs:
claude-fix:
if: github.event.label.name == 'claude-fix'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"

- name: Run Claude to Fix Issue
id: claude-fix
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
ISSUE #${{ github.event.issue.number }}: ${{ github.event.issue.title }}

${{ github.event.issue.body }}

---

You are tasked with fixing this issue using strict Test-Driven Development (TDD).

IMPORTANT RULES:
1. You may create PRs but NEVER merge them
2. Only create a PR if you have a working fix with passing tests

FOLLOW THIS PROCESS:

## Step 1: Understand the Issue
- Read and analyze the issue carefully
- Search the codebase to understand the relevant code
- Comment on the issue acknowledging you're working on it

## Step 2: Reproduce the Problem (TDD Red Phase)
- Write or identify a failing test that demonstrates the bug/missing feature
- Run the test and SHOW THE FAILING OUTPUT
- If you cannot reproduce the issue with a test, comment on the issue explaining why and stop

## Step 3: Implement the Fix (TDD Green Phase)
- Write the MINIMAL code needed to make the test pass
- Run the test again and SHOW THE PASSING OUTPUT
- Run the appropriate test suite to ensure all tests pass

## Step 4: Refactor if Needed
- Clean up the code if necessary
- Ensure tests still pass

## Step 5: Create PR (only if fix is successful)
- Create a new branch: `fix/issue-${{ github.event.issue.number }}`
- Commit your changes with a clear message referencing the issue
- Push the branch and create a PR
- The PR description should include:
- What the issue was
- The failing test output (before)
- The passing test output (after)
- Brief explanation of the fix
- Link the PR to the issue with "Fixes #${{ github.event.issue.number }}"

## If You Cannot Fix the Issue
- Comment on the issue explaining what you tried and why it didn't work
- Do NOT create a PR with a non-working fix

claude_args: '--allowedTools "Bash(grep:*),Bash(rg:*),Bash(find:*),Bash(ls:*),Bash(cat:*),Bash(head:*),Bash(tail:*),Bash(python:*),Bash(python3:*),Bash(pip:*),Bash(nox:*),Bash(pytest:*),Bash(make:*),Bash(pnpm:*),Bash(node:*),Bash(npm:*),Bash(npx:*),Bash(git status:*),Bash(git diff:*),Bash(git branch:*),Bash(git checkout:*),Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git log:*),Bash(gh issue view:*),Bash(gh issue comment:*),Bash(gh pr create:*),Bash(gh pr view:*),Bash(gh pr list:*),Edit,Read,Write,Glob,Grep"'
49 changes: 49 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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
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:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read

# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'

# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'
87 changes: 87 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Braintrust SDK

Multi-language SDK for Braintrust - an AI/ML evaluation and observability platform.

## Repository Structure

```
sdk/
├── py/ # Python SDK (main package: braintrust)
├── js/ # JavaScript/TypeScript SDK
├── core/ # Shared core code
│ ├── py/ # Python core
│ └── js/ # JavaScript core
└── integrations/ # Framework integrations
├── langchain-py/ # LangChain Python
├── adk-py/ # ADK Python
└── otel-js/ # OpenTelemetry JS (see integrations/otel-js/CLAUDE.md)
```

## Development Commands

### Python SDK (py/)

```bash
# Install dev dependencies
cd py && make install-dev

# Run all tests (via nox)
make nox # from root
cd py && nox # from py/

# Run specific test session
cd py && nox -s test_core
cd py && nox -s test_openai
cd py && nox -s test_anthropic

# Lint
cd py && make lint

# Full verification
cd py && make verify
```

### JavaScript SDK (js/)

```bash
# Install dependencies (from root)
pnpm install

# Build
pnpm run build

# Run tests
pnpm run test
cd js && make test

# Lint
pnpm run lint
```

### Linting & Formatting (Both)

```bash
# Run pre-commit hooks (format + lint)
make fixup
```

## Testing Guidelines

- Python uses `pytest` via `nox` for test isolation across dependency versions
- JavaScript uses `vitest`
- Always run relevant tests before submitting changes
- For Python integration tests, check which nox sessions are relevant (e.g., `test_openai`, `test_anthropic`, `test_temporal`)

## Key Files

- `py/noxfile.py` - Python test session definitions
- `py/pyproject.toml` - Python package configuration
- `js/package.json` - JavaScript package configuration
- `pnpm-workspace.yaml` - Workspace configuration

## Code Style

- Follow existing patterns in the codebase
- Python: Use type hints, follow PEP 8
- JavaScript/TypeScript: Follow existing ESLint configuration
- Avoid unnecessary comments - code should be self-documenting
Loading