From harness-claude
Implements JavaScript Revealing Module Pattern: define all logic privately in closure, return object revealing public API. For private-public separation and IIFE refactoring.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Define all logic privately and selectively reveal only the public API
Encapsulates private state and exposes public API in JavaScript using closures or ES modules. Use for private variables, clean APIs, and pre-ESM environments.
Teaches ES6+ features like arrow functions, destructuring, async/await, promises, and functional patterns for refactoring legacy JavaScript and optimizing web apps.
Guides modern JavaScript (ES6+) patterns for refactoring legacy code, functional programming, async operations, performance optimization, and maintainable code.
Share bugs, ideas, or general feedback.
Define all logic privately and selectively reveal only the public API
const counterModule = (() => {
let _count = 0;
function increment() {
_count++;
}
function decrement() {
_count--;
}
function getCount() {
return _count;
}
function reset() {
_count = 0;
}
// Reveal only the public API
return { increment, decrement, getCount };
// Note: reset() is private — not revealed
})();
counterModule.increment();
counterModule.increment();
console.log(counterModule.getCount()); // 2
The Revealing Module is a refinement of the Module pattern. The key insight: all code (including private functions) is defined in the same flat scope, which makes it easy to see the full implementation. The final return statement is the sole arbiter of what is public.
Trade-offs:
When NOT to use:
https://patterns.dev/javascript/revealing-module-pattern