Js facade pattern

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

Js facade pattern is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Provide a simplified interface to a complex subsystem

How to use this skill

Skill file

JS Facade Pattern

Provide a simplified interface to a complex subsystem

When to Use

Instructions

  1. Identify a group of related subsystem calls that clients frequently combine.
  2. Create a facade module that exposes high-level functions composing those subsystem calls.
  3. The facade delegates to subsystem objects — it does not replace them.
  4. Keep the subsystem accessible for advanced callers who need fine-grained control.
// Facade for a complex video conversion subsystem
class VideoConverter {
  convert(filename, format) {
    const file = new VideoFile(filename);
    const codec = CodecFactory.extract(file);
    const compressor = new BitrateCompressor();
    const mixer = new AudioMixer();

    const result = codec.transcode(file, format);
    compressor.compress(result);
    mixer.normalize(result);
    return result;
  }
}

// Client uses one call instead of four subsystem interactions
const converter = new VideoConverter();
converter.convert('video.ogg', 'mp4');

Details

The Facade pattern is a structural pattern that provides a unified interface to a set of interfaces in a subsystem. In JavaScript, this is often a module that re-exports a curated subset of a library's API or orchestrates multiple service calls behind a single function.

Trade-offs:

When NOT to use:

Source

https://patterns.dev/javascript/facade-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.