From 2572e748ebbb6177c56b96890440867b5a4c3d3a Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Mon, 26 Jan 2026 18:06:14 -0500 Subject: [PATCH] Init claude config --- .claude/agents/docs-reviewer.md | 77 +++ .claude/docs/react-docs-patterns.md | 637 ++++++++++++++++++ .claude/settings.json | 26 + .claude/skills/docs-components/SKILL.md | 142 ++++ .claude/skills/docs-sandpack/SKILL.md | 315 +++++++++ .claude/skills/docs-writer-learn/SKILL.md | 66 ++ .claude/skills/docs-writer-reference/SKILL.md | 117 ++++ .gitignore | 3 + CLAUDE.md | 52 ++ 9 files changed, 1435 insertions(+) create mode 100644 .claude/agents/docs-reviewer.md create mode 100644 .claude/docs/react-docs-patterns.md create mode 100644 .claude/settings.json create mode 100644 .claude/skills/docs-components/SKILL.md create mode 100644 .claude/skills/docs-sandpack/SKILL.md create mode 100644 .claude/skills/docs-writer-learn/SKILL.md create mode 100644 .claude/skills/docs-writer-reference/SKILL.md create mode 100644 CLAUDE.md diff --git a/.claude/agents/docs-reviewer.md b/.claude/agents/docs-reviewer.md new file mode 100644 index 00000000000..6d769cb6f5f --- /dev/null +++ b/.claude/agents/docs-reviewer.md @@ -0,0 +1,77 @@ +--- +name: docs-reviewer +description: "Use after editing docs to review changes. Orchestrates docs-writer-learn, docs-writer-reference, docs-components, and docs-sandpack skills to validate structure, components, and style" +model: opus +color: cyan +--- + +# React Documentation Reviewer Agent + +You are an expert reviewer for React documentation. Your role is to validate documentation changes for consistency, correctness, and adherence to established patterns. + +## Available Skills + +You have access to specialized skills that define the authoritative patterns for React docs. **Always invoke the relevant skills** to get the current patterns: + +| Skill | When to Use | +|-------|-------------| +| `docs-writer-learn` | Reviewing files in `src/content/learn/` | +| `docs-writer-reference` | Reviewing files in `src/content/reference/` | +| `docs-components` | Validating MDX components (DeepDive, Pitfall, Note, Recipes, Challenges) | +| `docs-sandpack` | Validating interactive code examples | + +## Review Process + +1. **Identify changed files** - Check git status or read the files to review +2. **Determine document type** based on path: + - `src/content/learn/**` → Invoke `docs-writer-learn` + - `src/content/reference/**` → Invoke `docs-writer-reference` +3. **Invoke component skills** for any MDX components or Sandpack examples in the file +4. **Read the patterns reference** at `.claude/docs/react-docs-patterns.md` for comprehensive details +5. **Validate against each skill's requirements** +6. **Run verification commands** +7. **Report issues with specific line numbers and fixes** + +## Verification Commands + +These commands can help identify issues (user may run manually): + +```bash +yarn lint-heading-ids # Check heading ID format +yarn lint # Check for ESLint issues +yarn deadlinks # Check for broken links +``` + +## Issue Reporting Format + +``` +## Documentation Review Results + +### Errors (must fix) +- **Line 45**: Missing heading ID. Change `## Events` to `## Events {/*events*/}` +- **Line 78**: `` missing `####` heading as first child + +### Warnings (recommended) +- **Line 23**: Capitalize "effect" to "Effect" when referring to the React concept + +### Summary +- Errors: X +- Warnings: Y +- Status: PASS | BLOCKED (fix errors before committing) +``` + +## Key Validation Points + +These are quick checks - see the skills for full details: + +### All Documents +- All `##`, `###`, `####` headings have explicit IDs: `{/*lowercase-with-hyphens*/}` +- React terms capitalized: Hook, Effect, State, Context, Ref, Component +- Uses "you" to address the reader +- No time estimates ("quick", "simple", "easy") +- Internal links use relative paths (`/learn/...`, `/reference/...`) + +### Invoke Skills For +- **Structure validation** → `docs-writer-learn` or `docs-writer-reference` +- **Component usage** → `docs-components` +- **Code examples** → `docs-sandpack` diff --git a/.claude/docs/react-docs-patterns.md b/.claude/docs/react-docs-patterns.md new file mode 100644 index 00000000000..f8df03d0b39 --- /dev/null +++ b/.claude/docs/react-docs-patterns.md @@ -0,0 +1,637 @@ +# React Documentation Patterns Reference + +Comprehensive reference for React documentation patterns. Use this when writing or reviewing docs. + +--- + +## Document Templates + +### Learn Page Template (`src/content/learn/`) + +```mdx +--- +title: Your Page Title +--- + + + +Opening paragraph introducing the topic. Use *italics* for new terms being defined. Keep it to 1-2 sentences that hook the reader. + + + + + +* Bullet point of what reader will learn +* Another learning outcome +* Keep to 3-5 items + + + +## First Section {/*first-section*/} + +Content with examples... + + + +* Summary bullet of key point +* Another summary point + + + + + +#### Challenge Title {/*challenge-id*/} + +Challenge description... + + +{/* problem code */} + + + + +Explanation and solution... + + +{/* solution code */} + + + + + +``` + +### Reference Page Template (`src/content/reference/`) + +```mdx +--- +title: hookName +--- + + + +`hookName` is a React Hook that lets you [brief description]. + +\`\`\`js +const result = hookName(arg) +\`\`\` + + + + + +--- + +## Reference {/*reference*/} + +### `hookName(arg)` {/*hookname*/} + +Call `hookName` at the top level of your component to... + +\`\`\`js +import { hookName } from 'react'; + +function MyComponent() { + const result = hookName(initialValue); + // ... +\`\`\` + +[See more examples below.](#usage) + +#### Parameters {/*parameters*/} + +* `arg`: Description of the parameter. + +#### Returns {/*returns*/} + +Description of return value. + +#### Caveats {/*caveats*/} + +* Caveat about usage. +* Another important caveat. + +--- + +## Usage {/*usage*/} + +### Common Use Case {/*common-use-case*/} + +Explanation with examples... + +--- + +## Troubleshooting {/*troubleshooting*/} + +### Common Problem {/*common-problem*/} + +How to solve it... +``` + +--- + +## Tone & Voice Guidelines + +### Learn Pages +- Conversational, friendly +- Address the reader as "you" +- "Here's what that looks like..." +- "You might be wondering..." +- "Let's see how this works..." + +### Reference Pages +- Precise, technical +- Still use "you" but more direct +- "Call `useState` at the top level..." +- "This Hook returns..." + +### Universal Rules +- **Capitalize React terms:** Hook, Effect, State, Context, Ref, Component, Transition +- **Capitalize:** Server Component, Client Component, Server Action, Error Boundary, Suspense +- **Use proper product names:** ESLint, TypeScript, JavaScript (not lowercase) +- **Use bold** for key concepts: **state variable**, **event handler** +- **Use italics** for new terms being defined: *event handlers* +- Avoid "simple", "easy", "just" - these can be dismissive +- Prefer concrete examples over abstract explanations +- No time estimates ("quick", "takes X minutes") +- Frame feature differences as "capabilities" not "advantages/disadvantages" +- Avoid passive voice and jargon + +### Avoiding Jargon + +React docs explain technical concepts in plain language. Follow these patterns: + +**Don't use CS jargon without explanation:** +- ❌ "State updates are atomic" +- ✅ "React waits until all state updates are done before re-rendering" + +- ❌ "Components must be idempotent" +- ✅ "Given the same inputs, a component always returns the same output" + +- ❌ "Rendering must be deterministic" +- ✅ "React expects the same inputs to produce the same result" + +**Terms to avoid or always explain:** +- "atomic" → describe what actually happens (all-or-nothing, batched together) +- "idempotent" → "same inputs, same output" +- "deterministic" → "predictable", "same result every time" +- "memoize/memoization" → "remember the result", "skip recalculating" +- "referentially transparent" → avoid entirely, explain the behavior +- "invariant" → "rule that must always be true", "requirement" +- "reify" → avoid entirely, describe what's being created + +**Use analogies the docs already establish:** +- Rendering = preparing food in a kitchen +- Committing = placing the order on the table +- Batching = waiter collecting the full order before going to kitchen +- State = snapshot/photograph at a moment in time +- Pure functions = math formulas (y = 2x always gives same result) + +**Pattern: Explain behavior, then name it** +```markdown +React waits until all code in the event handlers has run before +processing your state updates. This is called *batching*. +``` + +Not: +```markdown +React uses batching to process state updates atomically. +``` + +--- + +## Code Style Rules (Enforced in PR Review) + +These rules are strictly enforced during PR review: + +### Component Definitions +```js +// ✅ Correct - function declaration +function MyInput({ value, onChange, ref }) { + return ; +} +export default MyInput; + +// 🚫 Wrong - arrow function for component +const MyInput = ({ value, onChange, ref }) => { + return ; +}; +``` + +### Event Handlers +```js +// ✅ Correct - use 'e' for event parameter +