Skip to content
Open
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
82 changes: 82 additions & 0 deletions .claude/skills/pre-pr-checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: pre-pr-checks
description: "Pre-PR checks for ai-sdk-go. Runs license headers, lint, and unit tests matching the CI pipeline (task ci)."
---

# Pre-PR Checks β€” ai-sdk-go

Run these before pushing changes or creating a PR.

## Quick Check (all CI steps)

```bash
task ci
```

This runs: `license:check` β†’ `lint` β†’ `test:unit` (matches CI exactly).

## Individual Steps

### 1. License Headers

```bash
# Check
task license:check

# Auto-fix (add missing headers)
task license
```

### 2. Lint

```bash
# Full lint with auto-fix
task lint

# Only new issues (faster, what the Stop hook runs)
task lint:new
```

Common lint rules that catch people:
- **wsl_v5** β€” requires blank lines before `if`, `return`, and between declarations and logic
- **funcorder** β€” constructors must appear before methods on the same struct
- **gocritic** β€” catches duplicate branch bodies, unnecessary conversions, etc.

### 3. Tests

```bash
# Unit tests only (fast, no API keys needed) β€” this is what CI runs
task test:unit

# Single package
go test ./providers/openai/ -short -count=1 -v

# Single test
go test ./providers/openai/ -run TestResolveModelFamily -v -count=1

# All tests including integration (requires API keys)
task test
```

### 4. Security (optional, not in CI gate)

```bash
task security
```

## CI β†’ Local Mapping

| CI Step | Local Command |
|---------|--------------|
| License check | `task license:check` |
| Lint (all issues, with fix) | `task lint` |
| Unit tests | `task test:unit` |
| All of the above | `task ci` |

## Common Failures

1. **Missing license header** β€” Fix: `task license`
2. **wsl_v5 whitespace** β€” Add blank lines before `if`/`return` after multi-line blocks
3. **funcorder** β€” Move constructor `NewFoo()` above `Foo.Method()`
4. **Test flakes on integration** β€” Integration tests hit live APIs; re-run or use `task test:unit`
5. **Import grouping** β€” gofumpt enforced: stdlib, then external, then internal