mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-20 11:09:59 +00:00
feat(ci): add CLAUDE.md and improve claude-code-action workflows
- Add CLAUDE.md with lerobot-specific review instructions (core abstractions, engineering principles, ML-specific checks, PR checklist) - Enable use_sticky_comment: true on both workflows (single updating comment per PR) - Add structured lerobot-specific review prompt to claude-code-review.yml - Upgrade permissions: contents/pull-requests/issues write for interactive claude.yml - Add actions: read to claude-code-review.yml for CI log access - Set FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true to suppress Node.js 20 deprecation warnings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,27 +3,18 @@ name: Claude Code Review
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, ready_for_review, reopened]
|
types: [opened, synchronize, ready_for_review, reopened]
|
||||||
# Optional: Only run on specific file changes
|
|
||||||
# paths:
|
|
||||||
# - "src/**/*.ts"
|
|
||||||
# - "src/**/*.tsx"
|
|
||||||
# - "src/**/*.js"
|
|
||||||
# - "src/**/*.jsx"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
claude-review:
|
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
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
pull-requests: read
|
pull-requests: write
|
||||||
issues: read
|
issues: read
|
||||||
id-token: write
|
id-token: write
|
||||||
|
actions: read
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -37,8 +28,20 @@ jobs:
|
|||||||
uses: anthropics/claude-code-action@26ddc358fe3befff50c5ec2f80304c90c763f6f8 # v1
|
uses: anthropics/claude-code-action@26ddc358fe3befff50c5ec2f80304c90c763f6f8 # v1
|
||||||
with:
|
with:
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
|
use_sticky_comment: true
|
||||||
plugins: 'code-review@claude-code-plugins'
|
prompt: |
|
||||||
prompt: '/code-review:code-review ${{ github.repository }}/pull/${{ github.event.pull_request.number }}'
|
Review this PR for the LeRobot robotics ML library. Provide structured, actionable feedback.
|
||||||
|
|
||||||
|
Focus areas (in priority order):
|
||||||
|
1. **Correctness**: Logic errors, off-by-ones, wrong tensor shapes, incorrect loss functions
|
||||||
|
2. **Type safety**: All new/modified Python code must pass `mypy --strict`; check for missing annotations
|
||||||
|
3. **Backwards compatibility**: Does this break `LeRobotDataset`, `Policy`, `Robot`, `Teleoperator`, or `Env` public APIs?
|
||||||
|
4. **Tests**: New features must have tests; no silent behavioral changes
|
||||||
|
5. **Code style**: Explicit over magic, minimal LOC, no unnecessary abstractions, no decorative comments
|
||||||
|
6. **HF integration**: Dataset streaming, `push_to_hub`, HF Hub compatibility preserved?
|
||||||
|
7. **pre-commit**: Would `pre-commit run -a` pass? (ruff, mypy, typos, zizmor)
|
||||||
|
|
||||||
|
Format findings as P1 (must fix) / P2 (should fix) / P3 (nice to have).
|
||||||
|
Skip P3 if the PR is already high quality.
|
||||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
# 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
|
# or https://code.claude.com/docs/en/cli-reference for available options
|
||||||
|
|||||||
@@ -19,11 +19,14 @@ jobs:
|
|||||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
pull-requests: read
|
pull-requests: write
|
||||||
issues: read
|
issues: write
|
||||||
id-token: write
|
id-token: write
|
||||||
actions: read # Required for Claude to read CI results on PRs
|
actions: read
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -36,14 +39,12 @@ jobs:
|
|||||||
uses: anthropics/claude-code-action@26ddc358fe3befff50c5ec2f80304c90c763f6f8 # v1
|
uses: anthropics/claude-code-action@26ddc358fe3befff50c5ec2f80304c90c763f6f8 # v1
|
||||||
with:
|
with:
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
|
use_sticky_comment: true
|
||||||
|
|
||||||
# This is an optional setting that allows Claude to read CI results on PRs
|
# This is an optional setting that allows Claude to read CI results on PRs
|
||||||
additional_permissions: |
|
additional_permissions: |
|
||||||
actions: read
|
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
|
# Optional: Add claude_args to customize behavior and configuration
|
||||||
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
# 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
|
# or https://code.claude.com/docs/en/cli-reference for available options
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
# LeRobot — Claude Code Instructions
|
||||||
|
|
||||||
|
You are a senior robotics ML engineer reviewing code for **LeRobot**, a PyTorch framework for real-world robot learning.
|
||||||
|
Apply these principles to every PR review, fix, or task.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Core Abstractions
|
||||||
|
|
||||||
|
These are the load-bearing types. Handle them with care — breaking changes here affect every user.
|
||||||
|
|
||||||
|
| Type | Location | Role |
|
||||||
|
| ---------------- | ---------------------------- | ------------------------------------------------------------ |
|
||||||
|
| `LeRobotDataset` | `src/lerobot/datasets/` | Streaming replay buffer; HF Hub integration |
|
||||||
|
| `Policy` | `src/lerobot/policies/` | Base class for all learning agents (ACT, Diffusion, SARM, …) |
|
||||||
|
| `Robot` | `src/lerobot/robots/` | Hardware abstraction; carries `_output_pipeline` |
|
||||||
|
| `Teleoperator` | `src/lerobot/teleoperators/` | Leader-side hardware abstraction; carries `_output_pipeline` |
|
||||||
|
| `Env` | `src/lerobot/envs/` | Gym-like robotics environments |
|
||||||
|
|
||||||
|
**Never break their public APIs without a migration note and explicit user approval.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Engineering Principles
|
||||||
|
|
||||||
|
### Code quality
|
||||||
|
|
||||||
|
- Minimize added LOC. Every line must earn its place.
|
||||||
|
- Explicit over magic — no hidden control flow, no implicit state.
|
||||||
|
- No deep inheritance trees. Prefer composition.
|
||||||
|
- No decorative comment separators (`===`, `---`, etc.).
|
||||||
|
- Add comments only where the logic is non-obvious.
|
||||||
|
- No over-engineering. YAGNI applies strictly.
|
||||||
|
|
||||||
|
### Type safety
|
||||||
|
|
||||||
|
- All new and modified Python code must be fully typed (PEP 484).
|
||||||
|
- `mypy --strict` must pass on changed files.
|
||||||
|
- Do not widen or weaken existing type signatures.
|
||||||
|
|
||||||
|
### Backwards compatibility
|
||||||
|
|
||||||
|
- Public API changes require migration notes.
|
||||||
|
- Additive changes are preferred over modifications.
|
||||||
|
- `so100_follower` / `so101_follower` are aliases — never bleed changes there unintentionally.
|
||||||
|
|
||||||
|
### HF ecosystem
|
||||||
|
|
||||||
|
- Use `push_to_hub()`, HF Hub dataset streaming, and `evaluate` scripts.
|
||||||
|
- Dataset changes must preserve streaming compatibility.
|
||||||
|
- Prefer reusing HF primitives over rolling custom solutions.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## PR Review Checklist
|
||||||
|
|
||||||
|
Before approving or marking P1 issues resolved, verify:
|
||||||
|
|
||||||
|
- [ ] `pre-commit run -a` would pass (ruff, mypy, typos, zizmor, bandit)
|
||||||
|
- [ ] All new/modified code is typed and passes `mypy --strict`
|
||||||
|
- [ ] New features have unit tests; no silent behavioral changes
|
||||||
|
- [ ] Public APIs of `LeRobotDataset`, `Policy`, `Robot`, `Teleoperator`, `Env` are unchanged (or migration note present)
|
||||||
|
- [ ] HF Hub streaming still works for dataset changes
|
||||||
|
- [ ] No unnecessary abstractions introduced
|
||||||
|
- [ ] No breaking changes to training scripts (`lerobot-train`, `lerobot-eval`, `lerobot-record`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ML-Specific Checks
|
||||||
|
|
||||||
|
Flag these as **P1** if found:
|
||||||
|
|
||||||
|
- **Data leakage**: train and val/test splits must be constructed before any normalization or augmentation that uses train statistics.
|
||||||
|
- **Loss function errors**: verify reduction mode (`mean` vs `sum`), correct masking, correct shape alignment.
|
||||||
|
- **Gradient flow**: new modules must have gradients flowing (check `requires_grad`, no detached tensors in the loss path by accident).
|
||||||
|
- **Distributed training**: operations on tensors must be DDP-safe; no in-place ops on parameters; batch norm needs `SyncBatchNorm` if used.
|
||||||
|
- **Memory leaks**: no accumulation of tensors outside the training loop; `optimizer.zero_grad()` called correctly.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## What to Skip
|
||||||
|
|
||||||
|
- Don't flag style nitpicks on unchanged surrounding code.
|
||||||
|
- Don't propose refactors outside the PR's scope.
|
||||||
|
- Don't add docstrings or comments to code the PR didn't touch.
|
||||||
|
- Don't suggest speculative future features (YAGNI).
|
||||||
Reference in New Issue
Block a user