Skip to content

Commit ff755ce

Browse files
committed
update gt submit command with --no-edit flag
1 parent f72c707 commit ff755ce

File tree

4 files changed

+352
-0
lines changed

4 files changed

+352
-0
lines changed

.alexignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
CODE_OF_CONDUCT.md
22
examples/
33
**/*/LICENSE.md
4+
.claude/
5+
CLAUDE.md

.claude/commands/ci-failures.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Check CI Failures
2+
3+
Analyze failing tests from PR CI runs with parallel subagent log analysis.
4+
5+
## Usage
6+
7+
```
8+
/ci-failures [pr-number]
9+
```
10+
11+
If no PR number provided, detect from current branch.
12+
13+
## Instructions
14+
15+
1. Get the PR number from argument or current branch:
16+
17+
```bash
18+
gh pr view --json number,headRefName --jq '"\(.number) \(.headRefName)"'
19+
```
20+
21+
2. **CRITICAL: Always fetch fresh run IDs** - never trust cached IDs from conversation summaries:
22+
23+
```bash
24+
gh api "repos/vercel/next.js/actions/runs?branch={branch}&per_page=10" \
25+
--jq '.workflow_runs[] | select(.name == "build-and-test") | "\(.id) attempts:\(.run_attempt) status:\(.status) conclusion:\(.conclusion)"'
26+
```
27+
28+
3. **Prioritize the MOST RECENT run, even if in-progress:**
29+
- If the latest run is `in_progress` or `queued`, check it FIRST - it has the most relevant failures
30+
- Individual jobs complete before the overall run - analyze them as they finish
31+
- Only fall back to older completed runs if the current run has no completed jobs yet
32+
33+
4. Get all failed jobs from the run (works for in-progress runs too):
34+
35+
```bash
36+
gh api "repos/vercel/next.js/actions/runs/{run_id}/jobs?per_page=100" \
37+
--jq '.jobs[] | select(.conclusion == "failure") | "\(.id) \(.name)"'
38+
```
39+
40+
**Note:** For runs with >100 jobs, paginate:
41+
42+
```bash
43+
gh api "repos/vercel/next.js/actions/runs/{run_id}/jobs?per_page=100&page=2"
44+
```
45+
46+
5. Spawn parallel haiku subagents to analyze logs (limit to 3-4 to avoid rate limits):
47+
- **CRITICAL: Use the API endpoint for logs, NOT `gh run view`**
48+
- `gh run view --job --log` FAILS when run is in-progress
49+
- **Do NOT group by job name** (e.g., "test dev", "turbopack") - group by failure pattern instead
50+
- Agent prompt should extract structured data using:
51+
```bash
52+
# Extract assertion failures with context:
53+
gh api "repos/vercel/next.js/actions/jobs/{job_id}/logs" 2>&1 | \
54+
grep -B3 -A10 "expect.*\(toBe\|toContain\|toEqual\|toStartWith\|toMatch\)" | head -100
55+
# Also check for test file paths:
56+
gh api "repos/vercel/next.js/actions/jobs/{job_id}/logs" 2>&1 | \
57+
grep -E "^\s+at Object\.|FAIL\s+test/" | head -20
58+
```
59+
- **Agent prompt template** (copy-paste for each agent):
60+
```
61+
Analyze CI logs for these jobs: {job_ids}
62+
For each failing test, extract:
63+
1. TEST FILE: (full path, e.g., test/production/required-server-files-ssr-404/test/index.test.ts)
64+
2. TEST NAME: (the specific test case name)
65+
3. EXPECTED: (exact expected value from assertion)
66+
4. RECEIVED: (exact received value from assertion)
67+
5. CATEGORY: (assertion|timeout|routing|source-map|build|cli-output)
68+
6. ROOT CAUSE: (one sentence hypothesis)
69+
Return structured findings grouped by TEST FILE, not by job.
70+
```
71+
72+
6. **Deduplicate by test file** before summarizing:
73+
- Group all failures by TEST FILE path, not by CI job name
74+
- If multiple jobs fail the same test file, count them but report once
75+
- Identify systemic issues (same test failing across many jobs)
76+
77+
7. Create summary table **grouped by test file**:
78+
| Test File | Issue (Expected vs Received) | Jobs | Priority |
79+
|-----------|------------------------------|------|----------|
80+
| `test/production/required-server-files-ssr-404/...` | `"second"` vs `"[slug]"` (routing) | 3 | HIGH |
81+
| `test/integration/server-side-dev-errors/...` | source map paths wrong | 5 | HIGH |
82+
| `test/e2e/app-dir/disable-logging-route/...` | "Compiling" appearing when disabled | 2 | MEDIUM |
83+
84+
8. Recommend fixes:
85+
- **HIGH priority**: Show specific expected vs actual values, include test file path
86+
- **MEDIUM priority**: Identify root cause pattern
87+
- **LOW priority**: Mark as likely flaky/transient
88+
89+
## Failure Categories
90+
91+
- **Infrastructure/Transient**: Network errors, 503s, timeouts unrelated to code
92+
- **Assertion Failures**: Wrong output, path mismatches, snapshot differences
93+
- **Build Failures**: Compilation errors, missing dependencies
94+
- **Timeout**: Tests hanging, usually indicates async issues or missing server responses
95+
- **Port Binding**: EADDRINUSE errors, parallel test conflicts
96+
- **Routing/SSR**: Dynamic params not resolved, wrong status codes, JSON parse errors
97+
- **Source Maps**: `webpack-internal://` paths, wrong line numbers, missing code frames
98+
- **CLI Output**: Missing warnings, wrong log order, "Ready" printed before errors
99+
100+
## Failure Extraction Patterns
101+
102+
Use these grep patterns to identify specific failure types:
103+
104+
```bash
105+
# Assertion failures (most common)
106+
grep -B3 -A10 "expect.*\(toBe\|toContain\|toEqual\|toStartWith\)" | head -100
107+
108+
# Routing issues (dynamic params, status codes)
109+
grep -E "Expected.*Received|\[slug\]|x-matched-path|Expected: [0-9]+" | head -50
110+
111+
# Source map issues
112+
grep -E "webpack-internal://|at .* \(webpack" | head -30
113+
114+
# CLI output issues (missing warnings)
115+
grep -E "Ready in|deprecated|Both middleware|Compiling" | head -30
116+
117+
# Timeout issues
118+
grep -E "TIMEOUT|TimeoutError|exceeded|Exceeded timeout" | head -20
119+
120+
# Test file paths (to identify which test is failing)
121+
grep -E "FAIL test/|at Object\.<anonymous> \(" | head -20
122+
```
123+
124+
## Common Gotchas
125+
126+
### In-Progress Runs
127+
128+
- `gh run view {run_id} --job {job_id} --log` **FAILS** when run is in-progress
129+
- `gh api "repos/.../actions/jobs/{job_id}/logs"` **WORKS** for any completed job
130+
- Always use the API endpoint for reliability
131+
132+
### Pagination
133+
134+
- GitHub API paginates at 100 jobs per page
135+
- Next.js CI has ~120+ jobs - always check page 2:
136+
```bash
137+
gh api ".../jobs?per_page=100&page=1" --jq '[.jobs[] | select(.conclusion == "failure")] | length'
138+
gh api ".../jobs?per_page=100&page=2" --jq '[.jobs[] | select(.conclusion == "failure")] | length'
139+
```
140+
141+
### Multiple Attempts
142+
143+
- CI runs can have multiple attempts (retries)
144+
- Check attempt count: `.run_attempt` field
145+
- Query specific attempt: `.../runs/{id}/attempts/{n}/jobs`
146+
- 404 on attempt endpoint means that attempt doesn't exist
147+
148+
## Quick Reference
149+
150+
```bash
151+
# Get failed jobs (works for in-progress runs)
152+
gh api "repos/vercel/next.js/actions/runs/{run_id}/jobs?per_page=100" \
153+
--jq '.jobs[] | select(.conclusion == "failure") | "\(.id) \(.name)"'
154+
155+
# Get logs for a specific job (works for in-progress runs)
156+
gh api "repos/vercel/next.js/actions/jobs/{job_id}/logs" 2>&1 | head -500
157+
158+
# Search logs for errors
159+
gh api "repos/vercel/next.js/actions/jobs/{job_id}/logs" 2>&1 | \
160+
grep -E "FAIL|Error|error:|✕|Expected|Received" | head -50
161+
```

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ test-timings.json
6363

6464
# Storybook
6565
*storybook.log
66+
67+
# Claude Code (local settings and session files)
68+
.claude/settings.local.json
69+
.claude/plans/
70+
.claude/todos.json
71+
CLAUDE.local.md

CLAUDE.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Next.js Development Guide
2+
3+
## Git Workflow
4+
5+
**Use Graphite for all git operations** instead of raw git commands:
6+
7+
- `gt create <branch-name> -m "message"` - Create a new branch with commit
8+
- `gt modify -a --no-edit` - Stage all and amend current branch's commit
9+
- `gt checkout <branch>` - Switch branches (use instead of `git checkout`)
10+
- `gt sync` - Sync and restack all branches
11+
- `gt submit --no-edit` - Push and create/update PRs (use `--no-edit` to avoid interactive prompts)
12+
- `gt log short` - View stack status
13+
14+
**Note**: `gt submit` runs in interactive mode by default and won't push in automated contexts. Always use `gt submit --no-edit` or `gt submit -q` when running from Claude.
15+
16+
**Graphite Stack Safety Rules:**
17+
18+
- Graphite force-pushes everything - old commits only recoverable via reflog
19+
- Never have uncommitted changes when switching branches - they get lost during restack
20+
- Never use `git stash` with Graphite - causes conflicts when `gt modify` restacks
21+
- Never use `git checkout HEAD -- <file>` after editing - silently restores unfixed version
22+
- Always use `gt checkout` (not `git checkout`) to switch branches
23+
- `gt modify --no-edit` with unstaged/untracked files stages ALL changes
24+
- `gt sync` pulls FROM remote, doesn't push TO remote
25+
- `gt modify` restacks children locally but doesn't push them
26+
- Always verify with `git status -sb` after stack operations
27+
- When resuming from summarized conversation, never trust cached IDs - re-fetch from git/GitHub API
28+
29+
**Safe multi-branch fix workflow:**
30+
31+
```bash
32+
gt checkout parent-branch
33+
# make edits
34+
gt modify -a --no-edit # Stage all, amend, restack children
35+
git show HEAD -- <files> # VERIFY fix is in commit
36+
gt submit --no-edit # Push immediately
37+
38+
gt checkout child-branch # Already restacked from gt modify
39+
# make edits
40+
gt modify -a --no-edit
41+
git show HEAD -- <files> # VERIFY
42+
gt submit --no-edit
43+
```
44+
45+
## Build Commands
46+
47+
```bash
48+
# Build the Next.js package (dev server only - faster)
49+
pnpm --filter=next build:dev-server
50+
51+
# Build everything
52+
pnpm build
53+
54+
# Run specific task
55+
pnpm --filter=next taskfile <task>
56+
```
57+
58+
## Fast Local Development
59+
60+
For iterative development, use watch mode + fast test execution:
61+
62+
**1. Start watch build in background:**
63+
64+
```bash
65+
# Runs taskr in watch mode - auto-rebuilds on file changes
66+
# Use Bash(run_in_background=true) to keep working while it runs
67+
pnpm --filter=next dev
68+
```
69+
70+
**2. Run tests fast (no isolation, no packing):**
71+
72+
```bash
73+
# NEXT_SKIP_ISOLATE=1 - skip packing Next.js for each test (much faster)
74+
# testonly - runs with --runInBand (no worker isolation overhead)
75+
NEXT_SKIP_ISOLATE=1 NEXT_TEST_MODE=dev pnpm testonly test/path/to/test.ts
76+
```
77+
78+
**3. When done, kill the background watch process.**
79+
80+
Only use full `pnpm --filter=next build` for one-off builds (after branch switch, before CI push).
81+
82+
**Always rebuild after switching branches:**
83+
84+
```bash
85+
gt checkout <branch>
86+
pnpm --filter=next build # Required before running tests
87+
```
88+
89+
## Testing
90+
91+
```bash
92+
# Run specific test file
93+
pnpm jest test/path/to/test.test.ts
94+
95+
# Run tests matching pattern
96+
pnpm jest -t "pattern"
97+
98+
# Run development tests
99+
pnpm testheadless test/development/
100+
```
101+
102+
## Investigating CI Test Failures
103+
104+
**Use `/ci-failures` for automated analysis** - analyzes failing jobs in parallel and groups by test file.
105+
106+
**CI Analysis Tips:**
107+
108+
- Don't spawn too many parallel agents hitting GitHub API (causes rate limits)
109+
- Prioritize blocking jobs first: lint, types, then test jobs
110+
- Use `gh api` for logs (works on in-progress runs), not `gh run view --log`
111+
112+
**Quick triage:**
113+
114+
```bash
115+
# List failed jobs for a PR
116+
gh pr checks <pr-number> | grep fail
117+
118+
# Get failed job names
119+
gh run view <run-id> --json jobs --jq '.jobs[] | select(.conclusion == "failure") | .name'
120+
121+
# Search job logs for errors
122+
gh run view <run-id> --job <job-id> --log 2>&1 | grep -E "FAIL|Error|error:" | head -30
123+
```
124+
125+
**Common failure patterns:**
126+
127+
- `rust check / build` → Run `cargo fmt -- --check` locally, fix with `cargo fmt`
128+
- `lint / build` → Run `pnpm prettier --write <file>` for prettier errors
129+
- Test failures → Run the specific test locally with `NEXT_TEST_MODE=dev pnpm jest <test-path>`
130+
131+
**Run tests in the right mode:**
132+
133+
```bash
134+
# Dev mode (Turbopack)
135+
NEXT_TEST_MODE=dev pnpm jest test/path/to/test.ts
136+
137+
# Prod mode
138+
NEXT_TEST_MODE=start pnpm jest test/path/to/test.ts
139+
```
140+
141+
## Key Directories
142+
143+
- `packages/next/src/` - Main Next.js source code
144+
- `server/` - Server runtime (dev server, router, rendering)
145+
- `client/` - Client-side code
146+
- `build/` - Build tooling (webpack, turbopack configs)
147+
- `cli/` - CLI entry points
148+
- `packages/next/dist/` - Compiled output
149+
- `turbopack/` - Turbopack bundler (Rust)
150+
- `test/` - Test suites
151+
- `development/` - Dev server tests
152+
- `production/` - Production build tests
153+
- `e2e/` - End-to-end tests
154+
155+
## Development Tips
156+
157+
- The dev server entry point is `packages/next/src/cli/next-dev.ts`
158+
- Router server: `packages/next/src/server/lib/router-server.ts`
159+
- Use `DEBUG=next:*` for debug logging
160+
- Use `NEXT_TELEMETRY_DISABLED=1` when testing locally
161+
162+
## Commit and PR Style
163+
164+
- Do NOT add "Generated with Claude Code" or co-author footers to commits or PRs
165+
- Keep commit messages concise and descriptive
166+
- PR descriptions should focus on what changed and why
167+
168+
## Development Anti-Patterns
169+
170+
### Testing
171+
172+
- Mode-specific tests need `skipStart: true` + manual `next.start()` in `beforeAll` after mode check
173+
- Don't rely on exact log messages - filter by content patterns, find sequences not positions
174+
175+
### Rust/Cargo
176+
177+
- cargo fmt uses ASCII order (uppercase before lowercase) - just run `cargo fmt`
178+
179+
### Node.js Source Maps
180+
181+
- `findSourceMap()` needs `--enable-source-maps` flag or returns undefined
182+
- Source map paths vary (webpack: `./src/`, tsc: `src/`) - try multiple formats
183+
- `process.cwd()` in stack trace formatting produces different paths in tests vs production

0 commit comments

Comments
 (0)