From harness-claude
Implements React Provider Pattern with Context API to share data like theme, locale, or user across component trees without prop drilling. Use when multiple nested components need same data or prop drilling burdens maintenance.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Make data available to any component in the tree without prop drilling
Implements React Context pattern to share infrequent state like themes, users, or flags across component trees without prop drilling. Includes typed providers, safe hooks, and performance tips.
Guides React Context patterns for state management to share state across component trees without prop drilling. Includes TypeScript examples for auth providers.
Implements React component patterns: compound components with context, render props, HOCs, custom hooks, provider with reducer, controlled/uncontrolled, prop getters, state reducer.
Share bugs, ideas, or general feedback.
Make data available to any component in the tree without prop drilling
createContext, providing a typed default value.Context.Provider.useXxx() hook that calls useContext and throws if used outside the Provider.interface ThemeContextValue { theme: 'light' | 'dark'; toggle: () => void }
const ThemeContext = createContext<ThemeContextValue | null>(null);
export function ThemeProvider({ children }: { children: React.ReactNode }) {
const [theme, setTheme] = useState<'light' | 'dark'>('light');
return (
<ThemeContext.Provider value={{ theme, toggle: () => setTheme((t) => t === 'light' ? 'dark' : 'light') }}>
{children}
</ThemeContext.Provider>
);
}
export function useTheme(): ThemeContextValue {
const ctx = useContext(ThemeContext);
if (!ctx) throw new Error('useTheme must be used within ThemeProvider');
return ctx;
}
The Provider Pattern is React's built-in dependency injection mechanism. It solves prop drilling — the antipattern of threading props through intermediate components that do not use them.
Performance consideration: Every component that calls useContext re-renders when the context value changes. For high-frequency updates, split contexts by concern (do not put both user and notifications in the same context) or use a state management library with selector support.
Context vs state management:
Null safety pattern: Passing null as default to createContext and throwing in the hook (if (!ctx) throw new Error(...)) gives better error messages than silent undefined access failures.
https://patterns.dev/react/provider-pattern