Skip to content
Merged
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
51 changes: 51 additions & 0 deletions .claude/commands/pr-describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
model: claude-haiku-4-5
---

Review the current branch's diff against the base branch and update the GitHub PR with a clear title and description.

## Instructions

1. Determine the current branch and its base branch (usually `develop`). Run:
- `gh pr view --json number,title,body,baseRefName` to get the existing PR number and base branch
- `git log --oneline develop..HEAD` to see all commits on this branch
- `git diff develop...HEAD --stat` to see which files changed and by how much

**Token-saving rule:** Do NOT read the full diff (`git diff` without `--stat`). Commit messages + stat summary are sufficient. Only read the full diff for a specific file if the commit messages are unclear about what changed there.

2. Analyze the commit messages and file stats. Focus on **intent and impact**, not just file names.

3. Generate a PR title using conventional commits style:
- `feat:`, `fix:`, `chore:`, `refactor:`, `test:`, `docs:`
- Keep it under 70 characters
- Be specific about the scope, e.g. `feat(auth): support magic link login`

4. Generate a PR body using this exact structure:

```
## Summary

- Bullet point summary of major changes
- Focus on *what* changed and *why*
- Use emojis sparingly to improve scannability

## Scope Breakdown

| Area | Summary |
|------|---------|
| relevant/path/ | Brief description of changes in that area |

## Test plan

- [ ] Checklist of what should be tested
```
Comment on lines +25 to +41
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language specifier to the fenced code block.

The PR body template block has no language tag, causing the MD040 markdownlint warning. Use markdown or text to suppress it:

📝 Proposed fix
-```
+```markdown
 ## Summary
🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 25-25: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/commands/pr-describe.md around lines 25 - 41, The fenced code block
in the PR body template (.claude/commands/pr-describe.md) lacks a language
specifier causing MD040; update the opening triple-backtick for the template
block to include a language tag (e.g., "markdown" or "text") so the block starts
with ```markdown and suppresses the markdownlint warning while preserving the
existing template content.


5. Update the PR using `gh pr edit <number> --title "..." --body "..."`. Use a HEREDOC for the body to preserve formatting.

6. Return the PR URL when done.

**Rules:**
- Never fabricate changes — only describe what's in the diff
- If there's no open PR for the current branch, inform the user instead of creating one
- Keep the summary concise (3-8 bullet points)
- Only include the Scope Breakdown table if changes span 2+ distinct areas
245 changes: 245 additions & 0 deletions .claude/docs/CI_CHECKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
# CI Checks - Run Locally Before Pushing

This document describes the continuous integration (CI) checks that run on every pull request, and how to run them locally to catch issues before pushing.

## Overview

Our GitHub Actions CI workflow runs three checks on every PR. You should run all of these locally before pushing to ensure your changes will pass CI.

## The Three Checks

### 1. Lint
Checks code style and catches common errors using ESLint.

```bash
pnpm lint
```

**What it checks:**
- Code style violations
- Unused variables
- Import/export issues
- JSX formatting
- TypeScript ESLint rules

**Auto-fix many issues:**
```bash
pnpm lint --fix
```

### 2. TypeScript Type Check
Verifies all TypeScript types are correct.

```bash
pnpm tsc
```

**What it checks:**
- Type errors
- Missing types
- Incorrect type usage
- JSX type issues
- Module resolution

**Note:** This runs `tsc --noEmit`, so it only checks types without generating output files.

### 3. Unit Tests
Runs all unit tests with coverage reporting.

```bash
pnpm test run --coverage --passWithNoTests
```

**What it checks:**
- All test files pass
- Code coverage meets thresholds
- No test failures or errors

**For development (watch mode):**
```bash
pnpm test
```

## Run All Checks at Once

To run all three checks sequentially (mimicking CI):

```bash
pnpm lint && pnpm tsc && pnpm test run --coverage --passWithNoTests
```

Or create a convenient npm script in `package.json`:

```json
{
"scripts": {
"ci": "pnpm lint && pnpm tsc && pnpm test run --coverage --passWithNoTests"
}
}
```

Then run:
```bash
pnpm ci
```

## Pre-Push Checklist

Before pushing commits or creating a PR, verify:

- [ ] `pnpm lint` passes (or run with `--fix` to auto-fix)
- [ ] `pnpm tsc` passes with no type errors
- [ ] `pnpm test run --coverage --passWithNoTests` passes
- [ ] All files are properly formatted
- [ ] No uncommitted changes (unless intentional)

## Common Issues and Fixes

### Lint Failures

**Problem:** ESLint errors block CI
```
error: 'foo' is assigned a value but never used (@typescript-eslint/no-unused-vars)
```

**Fix:** Either use the variable or remove it. Run `pnpm lint --fix` for auto-fixable issues.

### TypeScript Errors

**Problem:** Type check fails
```
error TS2503: Cannot find namespace 'JSX'.
```

**Fix:**
- Ensure proper imports (e.g., React for JSX)
- Remove explicit type annotations if TypeScript can infer
- Add missing type definitions

### Test Failures

**Problem:** Tests fail locally but you're not sure why

**Fix:**
```bash
# Run tests in watch mode to debug
pnpm test

# Run specific test file
pnpm test path/to/test.spec.ts

# Run with verbose output
pnpm test run --reporter=verbose
```

## CI Configuration

The actual CI configuration is in `.github/workflows/test.yml`:

```yaml
matrix:
task:
- { name: "Lint", cmd: "pnpm lint" }
- { name: "Typecheck", cmd: "pnpm tsc" }
- { name: "Unit Tests", cmd: "pnpm test run --coverage --passWithNoTests" }
```

**Important:** Always keep your local checks in sync with the CI configuration. If the CI commands change, update this document and your local workflow.

## Git Hooks (Optional)

Consider setting up git hooks to automatically run checks:

### Pre-commit Hook
Run lint and type check before allowing commits:

```bash
# .git/hooks/pre-commit
#!/bin/sh
pnpm lint && pnpm tsc
```

### Pre-push Hook
Run all checks before pushing:

```bash
# .git/hooks/pre-push
#!/bin/sh
pnpm lint && pnpm tsc && pnpm test run --coverage --passWithNoTests
```

Make hooks executable:
```bash
chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/pre-push
```

## Troubleshooting

### "Command not found: pnpm"

Install pnpm globally:
```bash
npm install -g pnpm
```

Or use corepack (Node 16.9+):
```bash
corepack enable
```

### Cache Issues

If experiencing strange errors, clear caches:

```bash
# Clear pnpm cache
pnpm store prune

# Clear Next.js cache
rm -rf .next

# Clear test cache
rm -rf .vitest

# Reinstall dependencies
rm -rf node_modules
pnpm install
```

### CI Passes but Local Fails (or vice versa)

Ensure you're on the same Node version as CI:

```bash
# Check your Node version
node --version

# CI uses "lts/*" - update if needed
nvm use --lts
```

## Best Practices

1. **Run checks frequently** - Don't wait until you're ready to push
2. **Fix issues immediately** - Don't let them accumulate
3. **Use watch mode during development** - Catch issues in real-time
4. **Keep dependencies updated** - Outdated deps can cause check failures
5. **Review CI logs** - When CI fails, read the full error message

## Related Documentation

- [Contributing Guidelines](../../CONTRIBUTING.md)
- [PR Review Process](.claude/docs/PR_REVIEW_PROCESS.md)
- [Git Workflow](.claude/docs/GIT_WORKFLOW.md)

## Summary

**Before every push:**
```bash
pnpm lint && pnpm tsc && pnpm test run --coverage --passWithNoTests
```

**Keep these commands in sync with `.github/workflows/test.yml`**

This ensures your PR will pass CI checks and saves time in the review process! ✅
Loading