Js provider pattern

From Intense-Visions/harness-engineering · View interactive version

Js provider pattern is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Make shared data available to multiple consumers without prop-drilling

How to use this skill

Skill file

JS Provider Pattern

Make shared data available to multiple consumers without prop-drilling

When to Use

Instructions

  1. Create a context object or module-level store that holds the shared data.
  2. Expose a provide(value) function to register the data and a consume() / inject() function to retrieve it.
  3. Scope the provider — a module-level variable is global; a closure-based provider can be scoped to a subtree or request.
  4. Document what the provider exposes — callers should not need to inspect internals to use it.
// Simple module-level provider
let _theme = 'light';

export function provideTheme(theme) {
  _theme = theme;
}

export function useTheme() {
  return _theme;
}
  1. In framework code (React/Vue), use the framework's native context API — do not re-implement it.
  2. Keep providers focused — one provider per concern (theme, auth, i18n), not one mega-provider.

Details

The Provider pattern is the plain-JavaScript equivalent of what React Context and Vue's provide/inject formalize. The core idea: establish a value at one level and make it available to any consumer below that level without explicit passing.

Trade-offs:

When NOT to use:

Source

https://patterns.dev/javascript/provider-pattern

Process

  1. Read the instructions and examples in this document.
  2. Apply the patterns to your implementation, adapting to your specific context.
  3. Verify your implementation against the details and edge cases listed above.

Harness Integration

Success Criteria

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.