@@ -314,6 +314,306 @@ Replace spaces in topic with hyphens (e.g., "suspense boundaries" → "suspense-
314314- Issue #<number >: <title > - <url >
315315```
316316
317+ ## Error Code Research Mode
318+
319+ When invoked with ` error ` as the first argument, this skill switches to error-code research mode.
320+
321+ ### Invocation
322+
323+ ```
324+ /react-expert error 310
325+ /react-expert error 31
326+ ```
327+
328+ ### Step 1: Setup React Repo
329+
330+ Same as standard mode (see above).
331+
332+ ### Step 2: Look Up Error Message
333+
334+ Fetch the error codes JSON:
335+
336+ ``` bash
337+ curl -s https://raw.githubusercontent.com/facebook/react/main/scripts/error-codes/codes.json | python3 -c " import sys,json; codes=json.load(sys.stdin); print(codes.get('<CODE>', 'NOT FOUND'))"
338+ ```
339+
340+ Record the exact message template. Note the number of ` %s ` placeholders.
341+
342+ ### Step 3: Dispatch 7 Parallel Research Agents
343+
344+ Spawn these agents IN PARALLEL using the Task tool. Each agent receives the skepticism preamble plus the error message template.
345+
346+ | Agent | subagent_type | Focus |
347+ | -------| ---------------| -------|
348+ | error-source-finder | Explore | Find all throw sites for this error code |
349+ | test-explorer | Explore | Find tests that trigger this error |
350+ | source-explorer | Explore | Find related warnings and dev-mode messages |
351+ | pr-researcher | Explore | Find PRs that introduced or modified this error |
352+ | issue-hunter | Explore | Find GitHub issues reporting this error |
353+ | web-researcher | general-purpose | Web search for real-world developer struggles |
354+ | git-historian | Explore | Find commits related to this error |
355+
356+ ### Step 4: Error-Specific Agent Prompts
357+
358+ #### error-source-finder
359+ ```
360+ You are researching React error code <CODE>.
361+ Error message: "<MESSAGE>"
362+
363+ CRITICAL: Do NOT rely on your prior knowledge. Only report what you find in source files.
364+
365+ Your task: Find every location in the React source that throws error code <CODE>.
366+
367+ 1. Search: grep -rn "<CODE>" .claude/react/packages/*/src/ (look for the error code in error/invariant calls)
368+ 2. Also search: grep -rn "error(<CODE>" .claude/react/packages/*/src/
369+ 3. For each throw site, document:
370+ - The exact file path and line number
371+ - The condition (if statement / validation) that triggers the throw
372+ - What each %s argument resolves to at that call site
373+ - The function/module context
374+ 4. Determine which throw sites correspond to user-facing scenarios vs internal invariants
375+
376+ Format:
377+ ## Throw Sites
378+ ### Site 1: <file>:<line>
379+ **Condition:** <the if/validation check>
380+ **Arguments:** %s1 = <value>, %s2 = <value>
381+ **Context:** <function name and what it does>
382+ **User-facing:** Yes/No
383+ ```
384+
385+ #### test-explorer (error mode)
386+ ```
387+ You are researching React error code <CODE>.
388+ Error message: "<MESSAGE>"
389+
390+ CRITICAL: Do NOT rely on your prior knowledge. Only report what you find in source files.
391+
392+ Your task: Find test files in .claude/react that trigger or test error <CODE>.
393+
394+ 1. Search for the error code in test files: grep -rn "<CODE>" .claude/react/packages/*/src/__tests__/
395+ 2. Search for the error message text in tests
396+ 3. For each test, extract:
397+ - The test description (describe/it blocks)
398+ - The code that triggers the error
399+ - How the test asserts the error is thrown
400+ 4. Report findings with exact file paths and line numbers
401+
402+ Format:
403+ ## Test File: <path>
404+ ### Test: "<test description>"
405+ ```javascript
406+ <exact code from test>
407+ ```
408+ ** Triggers error by:** <what the test does to cause the error >
409+ ```
410+
411+ #### source-explorer (error mode)
412+ ```
413+ You are researching React error code <CODE >.
414+ Error message: "<MESSAGE >"
415+
416+ CRITICAL: Do NOT rely on your prior knowledge. Only report what you find in source files.
417+
418+ Your task: Find related warnings and dev-mode messages for error <CODE >.
419+
420+ 1 . Find the file(s) where error <CODE > is thrown
421+ 2 . Look for related console.error/console.warn calls near the throw sites
422+ 3 . Check if there's a different dev-mode message that provides more detail
423+ 4 . Document any related error codes thrown from the same functions
424+
425+ Format:
426+ ## Dev-Mode Messages
427+ | Message | Relationship to Error <CODE > | Source |
428+ | ---------| ------------------------------| --------|
429+ | "<message >" | <how it relates > | < file:line > |
430+
431+ ## Related Error Codes
432+ | Code | Message | Thrown From Same Location? |
433+ | ------| ---------| --------------------------|
434+ ```
435+
436+ #### web-researcher (error mode only)
437+ ```
438+ You are researching React error code <CODE >.
439+ Error message: "<MESSAGE >"
440+
441+ IMPORTANT: Web search IS allowed for error code research. Use WebSearch and WebFetch tools.
442+
443+ Your task: Find how real developers encounter and struggle with this error.
444+
445+ 1 . Search for:
446+ - "react error <CODE >"
447+ - "react minified error <CODE >"
448+ - "Minified React error #<CODE >"
449+ - The error message text itself
450+ 2 . Look at Stack Overflow, GitHub Discussions, Reddit r/reactjs, and blog posts
451+ 3 . For each relevant result, document:
452+ - What the developer was trying to do
453+ - What caused the error in their case
454+ - What solution worked
455+ - What they struggled with or found confusing
456+ 4 . Identify the most common real-world scenarios
457+
458+ Format:
459+ ## Real-World Occurrences
460+ ### Source: <URL >
461+ ** Scenario:** <what the developer was doing >
462+ ** Cause:** <what triggered the error >
463+ ** Solution:** <what fixed it >
464+ ** Confusion:** <what they found confusing >
465+
466+ ## Summary of Common Patterns
467+ 1 . Most common cause: ...
468+ 2 . Second most common: ...
469+ 3 . What confuses people most: ...
470+ ```
471+
472+ #### pr-researcher (error mode)
473+ ```
474+ You are researching React error code <CODE >.
475+ Error message: "<MESSAGE >"
476+
477+ CRITICAL: Do NOT rely on your prior knowledge. Only report what you find in PRs.
478+
479+ Your task: Find PRs related to error <CODE >.
480+
481+ 1 . Run: gh pr list -R facebook/react --search "error <CODE >" --state all --limit 20 --json number,title,url
482+ 2 . Also search: gh pr list -R facebook/react --search "<key words from error message >" --state all --limit 20 --json number,title,url
483+ 3 . For promising PRs, read details: gh pr view <number > -R facebook/react
484+ 4 . Look for: when this error was introduced, why, any changes to its behavior
485+
486+ Format:
487+ ## Key PRs
488+ ### PR #<number >: <title >
489+ ** URL:** <url >
490+ ** Summary:** <what it introduced/changed about this error>
491+ ** Design Rationale:** <why this error exists >
492+ ```
493+
494+ #### issue-hunter (error mode)
495+ ```
496+ You are researching React error code <CODE >.
497+ Error message: "<MESSAGE >"
498+
499+ CRITICAL: Do NOT rely on your prior knowledge. Only report what you find in issues.
500+
501+ Your task: Find GitHub issues where users report error <CODE >.
502+
503+ 1 . Search: gh issue list -R facebook/react --search "error <CODE >" --state all --limit 20 --json number,title,url
504+ 2 . Search: gh issue list -R facebook/react --search "Minified React error #<CODE >" --state all --limit 20 --json number,title,url
505+ 3 . Search: gh issue list -R reactjs/react.dev --search "error <CODE >" --state all --limit 20 --json number,title,url
506+ 4 . For each issue, identify:
507+ - What triggered the error
508+ - The resolution
509+ - Common misunderstandings
510+
511+ Format:
512+ ## Issues
513+ ### Issue #<number >: <title >
514+ ** Repo:** <repo >
515+ ** Trigger:** <what caused the error >
516+ ** Resolution:** <how it was resolved >
517+ ** Misunderstanding:** <if applicable >
518+ ```
519+
520+ #### git-historian (error mode)
521+ ```
522+ You are researching React error code <CODE >.
523+ Error message: "<MESSAGE >"
524+
525+ CRITICAL: Do NOT rely on your prior knowledge. Only report what you find in git history.
526+
527+ Your task: Find commits related to error <CODE >.
528+
529+ 1 . Run: cd .claude/react && git log --all --grep="<CODE >" --oneline -30
530+ 2 . Also: cd .claude/react && git log --all --grep="<key words from message >" --oneline -30
531+ 3 . For significant commits, read full message: git show <hash > --stat
532+ 4 . Look for when this error was introduced, modified, or discussed
533+
534+ Format:
535+ ## Key Commits
536+ ### <short hash > - <subject >
537+ ** Date:** <date >
538+ ** Context:** <why this change was made >
539+ ** Impact:** <what changed about this error >
540+ ```
541+
542+ ### Step 5: Synthesize Results
543+
544+ After all agents complete, combine findings into a research document. Prioritize:
545+ 1. Throw sites and their conditions
546+ 2. Real-world causes (ordered by frequency from web research)
547+ 3. Developer pain points and confusion
548+ 4. Design rationale
549+
550+ **DO NOT add information from your own knowledge.** Only include what agents found.
551+
552+ ### Step 6: Save Output
553+
554+ Write to `.claude/research/error-<CODE>.md`
555+
556+ ### Error Research Output Template
557+
558+ ```markdown
559+ # React Error Research: Error #<CODE>
560+
561+ > Generated by /react-expert error <CODE> on YYYY-MM-DD
562+ > Error message: "<message template>"
563+ > Sources: React repo (commit <hash>), N throw sites, M issues, K web results
564+
565+ ## Error Message
566+
567+ <exact template>
568+
569+ **Placeholders:** %s1 = <what it represents>, %s2 = ...
570+
571+ ## Throw Sites
572+
573+ [From error-source-finder]
574+
575+ ## Common Real-World Causes
576+
577+ [Synthesized from all agents — ordered by frequency from web research]
578+
579+ 1. **<cause>** — seen in N Stack Overflow posts, M GitHub issues
580+ 2. **<cause>** — seen in ...
581+
582+ ## Developer Pain Points
583+
584+ [From web-researcher — what confuses people]
585+
586+ ## Dev-Mode Messages
587+
588+ [From source-explorer — messages shown in development that differ from production]
589+
590+ ## Test Coverage
591+
592+ [From test-explorer — how React's own tests exercise this error]
593+
594+ ## Design Decisions
595+
596+ [From git-historian and pr-researcher — why this error exists]
597+
598+ ## GitHub Issues
599+
600+ [From issue-hunter]
601+
602+ ## Source Links
603+
604+ ### Commits
605+ - <hash>: <description>
606+
607+ ### Pull Requests
608+ - PR #<number>: <title> - <url>
609+
610+ ### Issues
611+ - Issue #<number>: <title> - <url>
612+
613+ ### Web Sources
614+ - <url>: <brief description>
615+ ```
616+
317617## Common Mistakes to Avoid
318618
3196191 . ** Trusting prior knowledge** - If you "know" something about the API, find the source evidence anyway
0 commit comments