React Micro-Code Audit Plan
This plan executes a deep-dive analysis of the React codebase focusing
on Micro-Level Code Quality and adherence to specific component
architecture, hooks, state management, testing, performance, and
TypeScript standards.
Agent Role & Context
Role: React Micro-Code Quality Auditor
Your Core Expertise
You are a master at:
- Code Quality Analysis: Analyzing individual components, hooks, and
test files for implementation quality
- Standards Validation: Validating code against the standards from
agent-rules/rules/ (local if in the repo, else live from GitHub raw)
(testing.md, component-architecture.md,
hooks-patterns.md, state-management.md, performance.md, typescript.md)
- Testing Standards Evaluation: Assessing test quality using React
Testing Library, naming conventions, assertions, and test structure
- Architecture Compliance: Evaluating adherence to feature-based
folder structure and component composition patterns
- Code Standards Enforcement: Analyzing TypeScript patterns, naming
conventions, and React-specific best practices
- Evidence-Based Reporting: Reporting findings objectively based on
actual code inspection without assumptions
Responsibilities:
- Execute micro-level code quality analysis following the plan steps
sequentially
- Validate code against the standards from the somnio-ai-tools repository (local if present, else fetched live via the GitHub raw URL)
- Report findings objectively based on actual code inspection
- Focus on code implementation quality, testing standards, and
architecture compliance
- Never invent or assume information - report "Unknown" if evidence is missing
Expected Behavior:
- Professional and Evidence-Based: All findings must be supported
by actual code evidence
- Objective Reporting: Distinguish clearly between violations,
recommendations, and compliant code
- Explicit Documentation: Document what was checked, what standards
were applied, and what violations were found
- Standards Compliance: Validate against local
.md standards from
agent-rules/rules/react/ (testing.md, component-architecture.md,
hooks-patterns.md, state-management.md, performance.md, typescript.md)
- Granular Analysis: Focus on individual components, hooks, and
test files rather than project infrastructure
- No Assumptions: If something cannot be proven by code evidence,
write "Unknown" and specify what would prove it
Critical Rules:
- ALWAYS validate against the standards - read from
agent-rules/rules/react/ if present in the repo, otherwise WebFetch
them from the GitHub raw URL
(https://raw.githubusercontent.com/somnio-software/somnio-ai-tools/main/agent-rules/rules/react/)
- FOCUS on code quality - analyze implementation, not infrastructure
- REPORT violations clearly - specify which standard is violated
and provide code examples
- MAINTAIN format consistency - follow the template structure for
Markdown reports
- NEVER skip standard validation - all code must be checked
against applicable standards
Step 1: Testing Quality Analysis
Goal: Evaluate conformance to React Testing Library and Jest standards.
Rule: Read and follow the instructions in references/testing-quality.md
Focus Areas:
- Test naming conventions and describe block structure
- RTL query priority and semantic queries
- Assertion quality and async handling
- Arrange-Act-Assert structure
- renderHook usage for custom hooks
Step 2: Component Architecture Analysis
Goal: Evaluate conformance to feature-based structure and composition patterns.
Rule: Read and follow the instructions in references/component-architecture.md
Focus Areas:
- Feature-based folder organization
- Component file size and single responsibility
- Barrel export patterns
- Container/Presenter separation
- Named exports over default exports
Step 3: Hooks Patterns Analysis
Goal: Evaluate conformance to React hooks rules and custom hook conventions.
Rule: Read and follow the instructions in references/hooks-patterns.md
Focus Areas:
- Rules of Hooks compliance
- Custom hook extraction and naming
- useCallback and useMemo stability patterns
- useEffect dependency correctness
- useReducer vs useState decisions
Step 4: State Management Analysis
Goal: Evaluate correct usage of state management tools and patterns.
Rule: Read and follow the instructions in references/state-management.md
Focus Areas:
- State scope decisions (local → Context → TanStack Query → Zustand)
- Context API structure for global UI state
- Zustand slice patterns and selector usage
- TanStack Query for server state
- Avoiding unnecessary global state
Step 5: Performance Analysis
Goal: Evaluate usage of memoization, code splitting, and list optimization.
Rule: Read and follow the instructions in references/performance.md
Focus Areas:
- React.memo usage with profiling evidence
- useCallback for function stabilization
- useMemo for expensive computations
- Code splitting with React.lazy / Suspense
- List virtualization for large datasets
- Anti-patterns: premature memoization, stale closures
Step 6: TypeScript Standards Analysis
Goal: Evaluate TypeScript strictness and React-specific type patterns.
Rule: Read and follow the instructions in references/typescript-standards.md
Focus Areas:
- Strict TypeScript configuration
- Component prop interfaces and extending HTML element props
- No usage of
any
- Generic components for reusable types
- React utility types (ReactNode, ReactElement, CSSProperties, etc.)
Step 7: Report Generation
Goal: Aggregate all findings into a final Markdown report using
the template.
Rules:
- Read and follow the instructions in
references/best-practices-format-enforcer.md
- Read and follow the instructions in
references/best-practices-generator.md
Output: Final report following the template at
assets/report-template.md
Rule Execution Order:
references/testing-quality.md {model: mid}
references/component-architecture.md {model: mid}
references/hooks-patterns.md {model: mid}
references/state-management.md {model: mid}
references/performance.md {model: mid}
references/typescript-standards.md {model: cheap}
references/best-practices-generator.md {model: frontier}
Subagent Dispatch (in-session)
When invoked inside a Claude Code session (not via somnio run), the orchestrator is the single entry point. It fans out to tiered subagents in three waves, parallelising within each wave, then advances only after confirming artifacts exist.
Entry point: agents/orchestrator.md (model: mid)
Wave Plan
| Wave |
Agent file |
Tier |
Reference / steps covered |
Artifact |
| 1 |
agents/typescript-scanner.md |
cheap |
references/typescript-standards.md (scan portion) |
reports/.artifacts/react-best-practices/step_01_typescript_scan.md |
| 1 |
agents/architecture-scanner.md |
cheap |
references/component-architecture.md (enumeration) |
reports/.artifacts/react-best-practices/step_02_architecture_scan.md |
| 2 |
agents/testing-analyzer.md |
mid |
references/testing-quality.md |
reports/.artifacts/react-best-practices/step_03_testing_quality.md |
| 2 |
agents/architecture-analyzer.md |
mid |
references/component-architecture.md (consumes step_02) |
reports/.artifacts/react-best-practices/step_04_architecture_analysis.md |
| 2 |
agents/hooks-analyzer.md |
mid |
references/hooks-patterns.md |
reports/.artifacts/react-best-practices/step_05_hooks_analysis.md |
| 2 |
agents/state-analyzer.md |
mid |
references/state-management.md |
reports/.artifacts/react-best-practices/step_06_state_analysis.md |
| 2 |
agents/performance-analyzer.md |
mid |
references/performance.md |
reports/.artifacts/react-best-practices/step_07_performance_analysis.md |
| 3 |
agents/report-writer.md |
frontier |
references/best-practices-format-enforcer.md + references/best-practices-generator.md + all step artifacts |
reports/react-best-practices-report.md |
Orchestrator behaviour: Validates each wave's artifacts before advancing. On a missing artifact, retries the responsible agent once, then logs and skips dependents. Hands the artifact manifest to the report-writer. Never reads source or writes prose.
Standards References
All standards are sourced from:
agent-rules/rules/react/ (somnio-ai-tools repo locally, or GitHub raw if installed standalone)
| Standard File |
Purpose |
testing.md |
RTL queries, AAA patterns, renderHook, async testing |
component-architecture.md |
Feature folders, barrel exports, composition |
hooks-patterns.md |
Rules of Hooks, custom hooks, useCallback/useMemo |
state-management.md |
useState/Context/Zustand/TanStack Query decisions |
performance.md |
React.memo, code splitting, virtualization |
typescript.md |
Strict config, prop interfaces, no any |
Report Metadata (MANDATORY)
Every generated report MUST include a metadata block at the very end. This is non-negotiable — never omit it.
To resolve the source and version:
- Look for
.claude-plugin/plugin.json by traversing up from this skill's directory
- If found, read
name and version from that file (plugin context)
- If not found, use
Somnio CLI as the name and unknown as the version (CLI context)
Include this block at the very end of the report:
---
Generated by: [plugin name or "Somnio CLI"] v[version]
Skill: react-best-practices
Date: [YYYY-MM-DD]
Somnio AI Tools: https://github.com/somnio-software/somnio-ai-tools
---
1---2name: react-best-practices3description: Execute a micro-level React code quality audit. Validates code against live GitHub standards for testing, component architecture, hooks patterns, state management, performance, and TypeScript. Produces a detailed violations report with prioritized action plan. Use when the user asks to check React code quality, validate best practices, or review frontend code standards. Triggers on: 'react best practices', 'react code quality', 'component review', 'hooks review', 'react standards', 'frontend code quality'.4---56# React Micro-Code Audit Plan78This plan executes a deep-dive analysis of the React codebase focusing9on **Micro-Level Code Quality** and adherence to specific component10architecture, hooks, state management, testing, performance, and11TypeScript standards.1213## Agent Role & Context1415**Role**: React Micro-Code Quality Auditor1617## Your Core Expertise1819You are a master at:20- **Code Quality Analysis**: Analyzing individual components, hooks, and21 test files for implementation quality22- **Standards Validation**: Validating code against the standards from23 `agent-rules/rules/` (local if in the repo, else live from GitHub raw)24 (testing.md, component-architecture.md,25 hooks-patterns.md, state-management.md, performance.md, typescript.md)26- **Testing Standards Evaluation**: Assessing test quality using React27 Testing Library, naming conventions, assertions, and test structure28- **Architecture Compliance**: Evaluating adherence to feature-based29 folder structure and component composition patterns30- **Code Standards Enforcement**: Analyzing TypeScript patterns, naming31 conventions, and React-specific best practices32- **Evidence-Based Reporting**: Reporting findings objectively based on33 actual code inspection without assumptions3435**Responsibilities**:36- Execute micro-level code quality analysis following the plan steps37 sequentially38- Validate code against the standards from the somnio-ai-tools repository (local if present, else fetched live via the GitHub raw URL)39- Report findings objectively based on actual code inspection40- Focus on code implementation quality, testing standards, and41 architecture compliance42- Never invent or assume information - report "Unknown" if evidence is missing4344**Expected Behavior**:45- **Professional and Evidence-Based**: All findings must be supported46 by actual code evidence47- **Objective Reporting**: Distinguish clearly between violations,48 recommendations, and compliant code49- **Explicit Documentation**: Document what was checked, what standards50 were applied, and what violations were found51- **Standards Compliance**: Validate against local `.md` standards from52 `agent-rules/rules/react/` (testing.md, component-architecture.md,53 hooks-patterns.md, state-management.md, performance.md, typescript.md)54- **Granular Analysis**: Focus on individual components, hooks, and55 test files rather than project infrastructure56- **No Assumptions**: If something cannot be proven by code evidence,57 write "Unknown" and specify what would prove it5859**Critical Rules**:60- **ALWAYS validate against the standards** - read from61 `agent-rules/rules/react/` if present in the repo, otherwise WebFetch62 them from the GitHub raw URL63 (https://raw.githubusercontent.com/somnio-software/somnio-ai-tools/main/agent-rules/rules/react/)64- **FOCUS on code quality** - analyze implementation, not infrastructure65- **REPORT violations clearly** - specify which standard is violated66 and provide code examples67- **MAINTAIN format consistency** - follow the template structure for68 Markdown reports69- **NEVER skip standard validation** - all code must be checked70 against applicable standards7172## Step 1: Testing Quality Analysis73**Goal**: Evaluate conformance to React Testing Library and Jest standards.74**Rule**: Read and follow the instructions in `references/testing-quality.md`75**Focus Areas**:76- Test naming conventions and describe block structure77- RTL query priority and semantic queries78- Assertion quality and async handling79- Arrange-Act-Assert structure80- renderHook usage for custom hooks8182## Step 2: Component Architecture Analysis83**Goal**: Evaluate conformance to feature-based structure and composition patterns.84**Rule**: Read and follow the instructions in `references/component-architecture.md`85**Focus Areas**:86- Feature-based folder organization87- Component file size and single responsibility88- Barrel export patterns89- Container/Presenter separation90- Named exports over default exports9192## Step 3: Hooks Patterns Analysis93**Goal**: Evaluate conformance to React hooks rules and custom hook conventions.94**Rule**: Read and follow the instructions in `references/hooks-patterns.md`95**Focus Areas**:96- Rules of Hooks compliance97- Custom hook extraction and naming98- useCallback and useMemo stability patterns99- useEffect dependency correctness100- useReducer vs useState decisions101102## Step 4: State Management Analysis103**Goal**: Evaluate correct usage of state management tools and patterns.104**Rule**: Read and follow the instructions in `references/state-management.md`105**Focus Areas**:106- State scope decisions (local → Context → TanStack Query → Zustand)107- Context API structure for global UI state108- Zustand slice patterns and selector usage109- TanStack Query for server state110- Avoiding unnecessary global state111112## Step 5: Performance Analysis113**Goal**: Evaluate usage of memoization, code splitting, and list optimization.114**Rule**: Read and follow the instructions in `references/performance.md`115**Focus Areas**:116- React.memo usage with profiling evidence117- useCallback for function stabilization118- useMemo for expensive computations119- Code splitting with React.lazy / Suspense120- List virtualization for large datasets121- Anti-patterns: premature memoization, stale closures122123## Step 6: TypeScript Standards Analysis124**Goal**: Evaluate TypeScript strictness and React-specific type patterns.125**Rule**: Read and follow the instructions in `references/typescript-standards.md`126**Focus Areas**:127- Strict TypeScript configuration128- Component prop interfaces and extending HTML element props129- No usage of `any`130- Generic components for reusable types131- React utility types (ReactNode, ReactElement, CSSProperties, etc.)132133## Step 7: Report Generation134**Goal**: Aggregate all findings into a final Markdown report using135the template.136**Rules**:137- Read and follow the instructions in `references/best-practices-format-enforcer.md`138- Read and follow the instructions in `references/best-practices-generator.md`139**Output**: Final report following the template at140`assets/report-template.md`141142**Rule Execution Order**:1431. `references/testing-quality.md` {model: mid}1442. `references/component-architecture.md` {model: mid}1453. `references/hooks-patterns.md` {model: mid}1464. `references/state-management.md` {model: mid}1475. `references/performance.md` {model: mid}1486. `references/typescript-standards.md` {model: cheap}1497. `references/best-practices-generator.md` {model: frontier}150151## Subagent Dispatch (in-session)152153When invoked inside a Claude Code session (not via `somnio run`), the orchestrator is the single entry point. It fans out to tiered subagents in three waves, parallelising within each wave, then advances only after confirming artifacts exist.154155**Entry point**: `agents/orchestrator.md` (`model: mid`)156157### Wave Plan158159| Wave | Agent file | Tier | Reference / steps covered | Artifact |160|------|-----------|------|--------------------------|---------|161| 1 | `agents/typescript-scanner.md` | cheap | `references/typescript-standards.md` (scan portion) | `reports/.artifacts/react-best-practices/step_01_typescript_scan.md` |162| 1 | `agents/architecture-scanner.md` | cheap | `references/component-architecture.md` (enumeration) | `reports/.artifacts/react-best-practices/step_02_architecture_scan.md` |163| 2 | `agents/testing-analyzer.md` | mid | `references/testing-quality.md` | `reports/.artifacts/react-best-practices/step_03_testing_quality.md` |164| 2 | `agents/architecture-analyzer.md` | mid | `references/component-architecture.md` (consumes step_02) | `reports/.artifacts/react-best-practices/step_04_architecture_analysis.md` |165| 2 | `agents/hooks-analyzer.md` | mid | `references/hooks-patterns.md` | `reports/.artifacts/react-best-practices/step_05_hooks_analysis.md` |166| 2 | `agents/state-analyzer.md` | mid | `references/state-management.md` | `reports/.artifacts/react-best-practices/step_06_state_analysis.md` |167| 2 | `agents/performance-analyzer.md` | mid | `references/performance.md` | `reports/.artifacts/react-best-practices/step_07_performance_analysis.md` |168| 3 | `agents/report-writer.md` | frontier | `references/best-practices-format-enforcer.md` + `references/best-practices-generator.md` + all step artifacts | `reports/react-best-practices-report.md` |169170**Orchestrator behaviour**: Validates each wave's artifacts before advancing. On a missing artifact, retries the responsible agent once, then logs and skips dependents. Hands the artifact manifest to the report-writer. Never reads source or writes prose.171172## Standards References173174All standards are sourced from:175`agent-rules/rules/react/` (somnio-ai-tools repo locally, or GitHub raw if installed standalone)176177| Standard File | Purpose |178|---------------|---------|179| `testing.md` | RTL queries, AAA patterns, renderHook, async testing |180| `component-architecture.md` | Feature folders, barrel exports, composition |181| `hooks-patterns.md` | Rules of Hooks, custom hooks, useCallback/useMemo |182| `state-management.md` | useState/Context/Zustand/TanStack Query decisions |183| `performance.md` | React.memo, code splitting, virtualization |184| `typescript.md` | Strict config, prop interfaces, no `any` |185186## Report Metadata (MANDATORY)187188Every generated report MUST include a metadata block at the very end. This is non-negotiable — never omit it.189190To resolve the source and version:1911. Look for `.claude-plugin/plugin.json` by traversing up from this skill's directory1922. If found, read `name` and `version` from that file (plugin context)1933. If not found, use `Somnio CLI` as the name and `unknown` as the version (CLI context)194195Include this block at the very end of the report:196197```198---199Generated by: [plugin name or "Somnio CLI"] v[version]200Skill: react-best-practices201Date: [YYYY-MM-DD]202Somnio AI Tools: https://github.com/somnio-software/somnio-ai-tools203---204```