logic-sandwich

Refactor top-level orchestrators into state gathering, pure intent computation, and effectful application.

Updated Apr 24, 2025
One-click install
npx skills add https://github.com/danielbush/oneput --skill logic-sandwich
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logic-sandwich
Source: https://github.com/danielbush/oneput/tree/main/.agents/skills/logic-sandwich
Command: npx skills add https://github.com/danielbush/oneput --skill logic-sandwich

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Refactors top-level orchestrator or mediator methods to keep modules readable by splitting state gathering, decision logic, and side-effect application.

Core Features & Use Cases

  • Three-layer pattern: gather state, compute a pure intent, apply effects.
  • Extract decision logic into pure helpers; preserves behavior.
  • Ideal for deep-modules codebases where top-level modules must stay high-level and orchestrator-focused.

Quick Start

Identify an orchestration method, extract a pure decision helper like decideInputIntent, and delegate side effects to a lightweight orchestrator.

Frequently Asked Questions about logic-sandwich

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor orchestrator methods to keep top-level modules readable?

To refactor orchestrator methods, split state gathering, pure intent computation, and side-effect application into a three-layer pattern. This approach maintains top-level module readability by delegating side effects to a dedicated orchestrator.

What is the three-layer pattern for orchestrator refactoring?

The three-layer pattern for orchestrator refactoring separates code into state gathering, pure intent computation, and effectful application. This technique preserves behavior while keeping orchestrators clean and decision logic testable.

How do I extract pure decision logic from a mediator method?

Extract pure decision logic from a mediator method by pulling it into a pure helper function like decideInputIntent. This isolates decision logic for testing while delegating side effects to a lightweight orchestrator.

When do I need to separate state gathering and side effects in my codebase?

You need to separate state gathering and side effects when working with deep-modules codebases where top-level modules must stay orchestrator-focused. This separation enforces testable boundaries and clear naming for complex orchestration methods.

Does this refactoring approach work for deep-modules codebases?

Yes, this refactoring approach works ideally for deep-modules codebases. It enforces using a pure helper for decision logic and keeps side effects in a dedicated orchestrator, ensuring top-level modules remain readable.