mock-friendly-api-layering

Prevent internal routing parameters from leaking into public API wrappers.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/shimo4228/claude-code-learned-skills --skill mock-friendly-api-layering
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mock-friendly-api-layering
Source: https://github.com/shimo4228/claude-code-learned-skills/tree/main/skills/mock-friendly-api-layering
Command: npx skills add https://github.com/shimo4228/claude-code-learned-skills --skill mock-friendly-api-layering

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Public wrapper functions often forward internal routing parameters (url, timeout) to a shared low-level helper, causing mock assertions to fail due to unexpected kwargs.

Core Features & Use Cases

  • Keeps internal routing parameters at the lowest level, ensuring mocks only see business parameters.
  • Applies to HTTP, IPC, or any layered API wrappers where public APIs delegate to a transport function.
  • Improves test reliability by isolating transport concerns from business logic.

Quick Start

Refactor public functions to drop transport parameters and let the internal helper own routing values.

Frequently Asked Questions about mock-friendly-api-layering

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

FAQPage Schema
Why do my mock tests fail when API wrappers forward url and timeout parameters?

Mock tests fail because internal routing parameters like url and timeout leak into public API wrappers and trigger unexpected kwargs in mock assertions. Refactoring public functions to drop transport parameters lets the internal helper own routing values, isolating transport concerns from business logic.

How do I prevent internal routing parameters from leaking into public API functions?

To prevent internal routing parameter leakage, refactor public functions to accept only business parameters while a shared internal _invoke-like helper owns routing values such as url or timeout. This keeps transport concerns at the lowest level and ensures mocks only see business parameters.

What is API layering in mock-heavy codebases?

API layering in mock-heavy codebases separates public API wrappers from low-level transport helpers. It enforces a boundary where public functions handle business parameters and delegate routing values like url and timeout to an internal function, improving test reliability by isolating transport concerns.

Does API layering work for IPC wrappers or only HTTP transport functions?

API layering applies to HTTP, IPC, or any layered API wrappers where public APIs delegate to a transport function. The approach enforces that public functions accept only business parameters while the internal helper owns routing params, regardless of the underlying transport protocol.

How do I enforce the boundary between public API parameters and internal routing values?

You enforce the boundary by applying lint rules and tests that prevent public functions from accepting transport parameters. Refactoring public wrappers to drop routing values and letting the internal _invoke-like helper own them ensures mocks only encounter business parameters.