Skip to content

Commit 1293ae1

Browse files
authored
Merge branch 'canary' into mischnic/scope-hoisting-pure-enum
2 parents 9364a6a + baad064 commit 1293ae1

File tree

1,473 files changed

+28239
-10566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,473 files changed

+28239
-10566
lines changed
File renamed without changes.

.claude/skills/update-docs/references/CODE-TO-DOCS-MAPPING.md renamed to .agents/skills/update-docs/references/CODE-TO-DOCS-MAPPING.md

File renamed without changes.

.claude/skills/update-docs/references/DOC-CONVENTIONS.md renamed to .agents/skills/update-docs/references/DOC-CONVENTIONS.md

File renamed without changes.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
name: write-api-reference
3+
description: |
4+
Produces API reference documentation for Next.js APIs: functions, components, file conventions, directives, and config options.
5+
6+
**Auto-activation:** User asks to write, create, or draft an API reference page. Also triggers on paths like `docs/01-app/03-api-reference/`, or keywords like "API reference", "props", "parameters", "returns", "signature".
7+
8+
**Input sources:** Next.js source code, existing API reference pages, or user-provided specifications.
9+
10+
**Output type:** A markdown (.mdx) API reference page with YAML frontmatter, usage example, reference section, behavior notes, and examples.
11+
agent: Plan
12+
context: fork
13+
---
14+
15+
# Writing API Reference Pages
16+
17+
## Goal
18+
19+
Produce an API reference page that documents a single API surface (function, component, file convention, directive, or config option). The page should be concise, scannable, and example-driven.
20+
21+
Each page documents **one API**. If the API has sub-methods (like `cookies.set()`), document them on the same page. If two APIs are independent, they get separate pages.
22+
23+
## Structure
24+
25+
Identify which category the API belongs to, then follow the corresponding template.
26+
27+
### Categories
28+
29+
1. **Function** (`cookies`, `fetch`, `generateStaticParams`): signature, params/returns, methods table, examples
30+
2. **Component** (`Link`, `Image`, `Script`): props summary table, individual prop docs, examples
31+
3. **File convention** (`page`, `layout`, `route`): definition, code showing the convention, props, behavior, examples
32+
4. **Directive** (`use client`, `use cache`): definition, usage, serialization/boundary rules, reference
33+
5. **Config option** (`basePath`, `images`, etc.): definition, config code, behavioral sections
34+
35+
### Template
36+
37+
````markdown
38+
---
39+
title: {API name}
40+
description: {API Reference for the {API name} {function|component|file convention|directive|config option}.}
41+
---
42+
43+
{One sentence defining what it does and where it's used.}
44+
45+
```tsx filename="path/to/file.tsx" switcher
46+
// Minimal working usage
47+
```
48+
49+
```jsx filename="path/to/file.js" switcher
50+
// Same example in JS
51+
```
52+
53+
## Reference
54+
55+
{For functions: methods/params table, return type.}
56+
{For components: props summary table, then `#### propName` subsections.}
57+
{For file conventions: `### Props` with `#### propName` subsections.}
58+
{For directives: usage rules and serialization constraints.}
59+
{For config: options table or individual option docs.}
60+
61+
### {Subsection name}
62+
63+
{Description + code example + table of values where applicable.}
64+
65+
## Good to know
66+
67+
- {Default behavior or implicit effects.}
68+
- {Caveats, limitations, or version-specific notes.}
69+
- {Edge cases the developer should be aware of.}
70+
71+
## Examples
72+
73+
### {Example name}
74+
75+
{Brief context, 1-2 sentences.}
76+
77+
```tsx filename="path/to/file.tsx" switcher
78+
// Complete working example
79+
```
80+
81+
```jsx filename="path/to/file.js" switcher
82+
// Same example in JS
83+
```
84+
85+
## Version History
86+
87+
| Version | Changes |
88+
| -------- | --------------- |
89+
| `vX.Y.Z` | {What changed.} |
90+
````
91+
92+
**Category-specific notes:**
93+
94+
- **Functions**: Lead with the function signature and `await` if async. Document methods in a table if the return value has methods (like `cookies`). Document options in a separate table if applicable.
95+
- **Components**: Start with a props summary table (`| Prop | Example | Type | Required |`). Then document each prop under `#### propName` with description, code example, and value table where useful.
96+
- **File conventions**: Show the default export signature with TypeScript types. Document each prop (`params`, `searchParams`, etc.) under `#### propName` with a route/URL/value example table.
97+
- **Directives**: No `## Reference` section. Use `## Usage` instead, showing correct placement. Document serialization constraints and boundary rules.
98+
- **Config options**: Show the `next.config.ts` snippet. Use subsections for each behavioral aspect.
99+
100+
## Rules
101+
102+
1. **Lead with what it does.** First sentence defines the API. No preamble.
103+
2. **Show working code immediately.** A minimal usage example appears right after the opening sentence, before `## Reference`.
104+
3. **Use `switcher` for tsx/jsx pairs.** Always include both. Always include `filename="path/to/file.ext"`.
105+
4. **Use `highlight={n}` for key lines.** Highlight the line that demonstrates the API being documented.
106+
5. **Tables for simple APIs, subsections for complex ones.** If a prop/param needs only a type and one-line description, use a table row. If it needs a code example or multiple values, use a `####` subsection.
107+
6. **Behavior section uses `> **Good to know**:`or`## Good to know`.** Use the blockquote format for brief notes (1-3 bullets). Use the heading format for longer sections. Not "Note:" or "Warning:".
108+
7. **Examples section uses `### Example Name` subsections.** Each example solves one specific use case.
109+
8. **Version History table at the end.** Include when the API has changed across versions. Omit for new APIs.
110+
9. **No em dashes.** Use periods, commas, or parentheses instead.
111+
10. **Mechanical, observable language.** Describe what happens, not how it feels. "Returns an object" not "gives you an object".
112+
11. **Link to related docs with relative paths.** Use `/docs/app/...` format.
113+
12. **No selling or justifying.** No "powerful", "easily", "simply". State what the API does.
114+
115+
| Don't | Do |
116+
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
117+
| "This powerful function lets you easily manage cookies" | "`cookies` is an async function that reads HTTP request cookies in Server Components" |
118+
| "You can conveniently access..." | "Returns an object containing..." |
119+
| "The best way to handle navigation" | "`<Link>` extends the HTML `<a>` element to provide prefetching and client-side navigation" |
120+
121+
## Workflow
122+
123+
1. **Ask for reference material.** Ask the user if they have any RFCs, PRs, design docs, or other context that should inform the doc.
124+
2. **Identify the API category** (function, component, file convention, directive, config).
125+
3. **Research the implementation.** Read the source code to understand params, return types, edge cases, and defaults.
126+
4. **Check e2e tests.** Search `test/` for tests exercising the API to find real usage patterns, edge cases, and expected behavior.
127+
5. **Check existing related docs** for linking opportunities and to avoid duplication.
128+
6. **Write using the appropriate category template.** Follow the rules above.
129+
7. **Review against the rules.** Verify: one sentence opener, immediate code example, correct `switcher`/`filename` usage, tables vs subsections, "Good to know" format, no em dashes, mechanical language.
130+
131+
## References
132+
133+
Read these pages in `docs/01-app/03-api-reference/` before writing. They demonstrate the patterns above.
134+
135+
- `04-functions/cookies.mdx` - Function with methods table, options table, and behavior notes
136+
- `03-file-conventions/page.mdx` - File convention with props subsections and route/URL/value tables
137+
- `02-components/link.mdx` - Component with props summary table and detailed per-prop docs
138+
- `01-directives/use-client.mdx` - Directive with usage section and serialization rules
139+
- `04-functions/fetch.mdx` - Function with troubleshooting section and version history
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
name: write-guide
3+
description: |
4+
Generates technical guides that teach real-world use cases through progressive examples.
5+
6+
**Auto-activation:** User asks to write, create, or draft a guide or tutorial. Also use when converting feature documentation, API references, or skill knowledge into step-by-step learning content.
7+
8+
**Input sources:** Feature skills, API documentation, existing code examples, or user-provided specifications.
9+
10+
**Output type:** A markdown guide with YAML frontmatter, introduction, 2-4 progressive steps, and next steps section.
11+
agent: Plan
12+
context: fork
13+
---
14+
15+
# Writing Guides
16+
17+
## Goal
18+
19+
Produce a technical guide that teaches a real-world use case through progressive examples. Concepts are introduced only when the reader needs them.
20+
21+
Each guide solves **one specific problem**. Not a category of problems. If the outline has 5+ steps or covers multiple approaches, split it.
22+
23+
## Structure
24+
25+
Every guide follows this arc: introduction, example setup, 2-5 progressive steps, next steps.
26+
27+
Each step follows this loop: working code → new requirement → friction → explanation → resolution → observable proof.
28+
29+
Sections: introduction (no heading, 2 paragraphs max), `## Example` (what we're building + source link), `### Step N` (action-oriented titles, 2-4 steps), `## Next steps` (summary + related links).
30+
31+
Headings should tell a story on their own. If readers only saw the headings, they'd understand the guide's takeaway.
32+
33+
### Template
34+
35+
````markdown
36+
---
37+
title: {Action-oriented, e.g., "Building X" or "How to Y"}
38+
description: {One sentence}
39+
nav_title: {Short title for navigation}
40+
---
41+
42+
{What the reader will accomplish and why it matters. The friction and how this approach resolves it. 2 paragraphs max.}
43+
44+
## Example
45+
46+
As an example, we'll build {what we're building}.
47+
48+
We'll start with {step 1}, then {step 2}, and {step 3}.
49+
50+
{Source code link.}
51+
52+
### Step 1: {Action-oriented title}
53+
54+
{Brief context, 1-2 sentences.}
55+
56+
```tsx filename="path/to/file.tsx"
57+
// Minimal working code
58+
```
59+
60+
{Explain what happens.}
61+
62+
{Introduce friction: warning, limitation, or constraint.}
63+
64+
{Resolution: explain the choice, apply the fix.}
65+
66+
{Verify the fix with observable proof.}
67+
68+
### Step 2: {Action-oriented title}
69+
70+
{Same pattern: context → code → explain → friction → resolution → proof.}
71+
72+
### Step 3: {Action-oriented title}
73+
74+
{Same pattern.}
75+
76+
## Next steps
77+
78+
You now know how to {summary}.
79+
80+
Next, learn how to:
81+
82+
- [Related guide 1]()
83+
- [Related guide 2]()
84+
````
85+
86+
### Workflow
87+
88+
1. **Research**: Check available skills for relevant features. Read existing docs for context and linking opportunities.
89+
2. **Plan**: Outline sections. Verify scope (one problem, 2-4 steps). Each step needs a friction point and resolution.
90+
3. **Write**: Follow the template above. Apply the rules below.
91+
4. **Review**: Re-read the rules, verify, then present.
92+
93+
## Rules
94+
95+
1. **Progressive disclosure.** Start with the smallest working example. Introduce complexity only when the example breaks. Name concepts at the moment of resolution, after the reader has felt the problem. Full loop: working → new requirement → something breaks → explain why → name the fix → apply → verify with proof → move on.
96+
2. **Show problems visually.** Console errors, terminal output, build warnings, slow-loading pages. "If we refresh the page, we can see the component blocks the response."
97+
3. **Verify resolutions with observable proof.** Before/after comparisons, browser reloads, terminal output. "If we refresh the page again, we can see it loads instantly."
98+
4. **One friction point per step.** If a step has multiple friction points, split it.
99+
5. **Minimal code blocks.** Only the code needed for the current step. Collapse unchanged functions with `function Header() {}`.
100+
6. **No em dashes.** Use periods, commas, or parentheses instead.
101+
7. **Mechanical, observable language.** Describe what happens, not how it feels.
102+
8. **No selling, justifying, or comparing.** No "the best way," no historical context, no framework comparisons.
103+
104+
| Don't | Do |
105+
| ---------------------------------------------------- | -------------------------------------------------------- |
106+
| "creates friction in the pipeline" | "blocks the response" |
107+
| "needs dynamic information" | "depends on request-time data" |
108+
| "requires dynamic processing" | "output can't be known ahead of time" |
109+
| "The component blocks the response — causing delays" | "The component blocks the response. This causes delays." |
110+
111+
## References
112+
113+
Read these guides in `docs/01-app/02-guides/` before writing. They demonstrate the patterns above.
114+
115+
- `public-static-pages.mdx` — intro → example → 3 progressive steps → next steps. Concepts named at point of resolution. Problems shown with build output.
116+
- `forms.mdx` — progressive feature building without explicit "Step" labels. Each section adds one capability.

.alexignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ examples/
44
.claude/
55
AGENTS.md
66
CLAUDE.md
7+
packages/next/dist/docs/

.alexrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"attacks",
44
"color",
55
"dead",
6+
"dirty",
67
"execute",
78
"executed",
89
"executes",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
id: no-context-format
2+
snapshots:
3+
foo.bar().context(format!("{} failed", name)):
4+
fixed: foo.bar().with_context(|| format!("{} failed", name))
5+
labels:
6+
- source: foo.bar().context(format!("{} failed", name))
7+
style: primary
8+
start: 0
9+
end: 45
10+
'foo.context(format!("error: {}", msg))':
11+
fixed: 'foo.with_context(|| format!("error: {}", msg))'
12+
labels:
13+
- source: 'foo.context(format!("error: {}", msg))'
14+
style: primary
15+
start: 0
16+
end: 38
17+
foo.context(format!("simple message")):
18+
fixed: foo.with_context(|| format!("simple message"))
19+
labels:
20+
- source: foo.context(format!("simple message"))
21+
style: primary
22+
start: 0
23+
end: 38
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
id: no-context-turbofmt
2+
snapshots:
3+
foo.bar().context(turbofmt!("{} failed", name)):
4+
fixed: foo.bar().with_context(|| turbofmt!("{} failed", name))
5+
labels:
6+
- source: foo.bar().context(turbofmt!("{} failed", name))
7+
style: primary
8+
start: 0
9+
end: 47
10+
foo.bar().context(turbofmt!("{} failed", name).await?):
11+
labels:
12+
- source: foo.bar().context(turbofmt!("{} failed", name).await?)
13+
style: primary
14+
start: 0
15+
end: 54
16+
'foo.context(turbofmt!("error: {}", msg))':
17+
fixed: 'foo.with_context(|| turbofmt!("error: {}", msg))'
18+
labels:
19+
- source: 'foo.context(turbofmt!("error: {}", msg))'
20+
style: primary
21+
start: 0
22+
end: 40
23+
'foo.context(turbofmt!("error: {}", msg).await?)':
24+
labels:
25+
- source: 'foo.context(turbofmt!("error: {}", msg).await?)'
26+
style: primary
27+
start: 0
28+
end: 47
29+
foo.context(turbofmt!("simple message")):
30+
fixed: foo.with_context(|| turbofmt!("simple message"))
31+
labels:
32+
- source: foo.context(turbofmt!("simple message"))
33+
style: primary
34+
start: 0
35+
end: 40
36+
foo.context(turbofmt!("simple message").await?):
37+
labels:
38+
- source: foo.context(turbofmt!("simple message").await?)
39+
style: primary
40+
start: 0
41+
end: 47
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
id: no-context-format
2+
valid:
3+
- 'foo.context("static string")'
4+
- 'foo.with_context(|| format!("error: {}", msg))'
5+
- 'foo.context(msg)'
6+
invalid:
7+
- 'foo.context(format!("error: {}", msg))'
8+
- 'foo.context(format!("simple message"))'
9+
- 'foo.bar().context(format!("{} failed", name))'
10+
---
11+
id: no-context-turbofmt
12+
valid:
13+
- 'foo.context("static string")'
14+
- 'foo.context(msg)'
15+
invalid:
16+
- 'foo.context(turbofmt!("error: {}", msg).await?)'
17+
- 'foo.context(turbofmt!("simple message").await?)'
18+
- 'foo.bar().context(turbofmt!("{} failed", name).await?)'

0 commit comments

Comments
 (0)