add-helper-method

Add async helper methods wrapping generated StockTrim client calls.

Updated Jul 18, 2025
One-click install
npx skills add https://github.com/dougborg/stocktrim-openapi-client --skill add-helper-method
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-helper-method
Source: https://github.com/dougborg/stocktrim-openapi-client/tree/main/.claude/skills/add-helper-method
Command: npx skills add https://github.com/dougborg/stocktrim-openapi-client --skill add-helper-method

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It eliminates the friction and repetition of calling raw generated OpenAPI client endpoints by providing a consistent, ergonomic helper API for domain operations, complete with reliable test scaffolding.

Core Features & Use Cases

  • Thin ergonomic wrappers: Adds an async helper method in stocktrim_public_api_client/helpers/<domain>.py that delegates to the corresponding generated generated/ client call.
  • Transport-layer mocking in tests: Ensures tests mock httpx.MockTransport so authentication and retry middleware execute as in production, not by mocking the helper directly.
  • StockTrim 404 handling convention: Converts the API’s collection-style “not found” behavior (404) into [] (or None where appropriate, e.g., single-entity “find by code”), matching documented quirks.
  • Quality gate compliance: Enforces checks via linting/formatting and unit tests without suppressing issues using # noqa or # type: ignore.

Quick Start

Ask your AI assistant to add a new helper for a specific domain operation in helpers/<domain>.py by wrapping the existing generated endpoint, then create a test that uses httpx.MockTransport to verify success and the 404-to-empty (or None) behavior.

Frequently Asked Questions about add-helper-method

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

FAQPage Schema
How do I add an async helper method for an OpenAPI generated client?

Adding typed helper methods involves wrapping generated async client calls in a dedicated helpers module, providing an ergonomic API that eliminates the friction of calling raw OpenAPI endpoints while maintaining type safety for domain operations.

How do I mock httpx transport layer in Python async client tests?

Mocking httpx MockTransport in tests ensures authentication and retry middleware execute as in production, rather than mocking the helper method directly, preserving realistic end-to-end behavior validation for async API calls.

Why does my OpenAPI client return a 404 for a collection endpoint instead of an empty list?

A 404 from a collection endpoint should be translated into an empty list or None for single-entity lookups, matching API quirks where missing collections return not-found rather than empty responses. Helper methods handle this conversion automatically.

Can I use type ignore or noqa comments to bypass quality gate checks in Python helpers?

No, helper methods must satisfy quality gate checks through proper typing and linting compliance without suppressing issues using noqa or type ignore comments, ensuring code quality standards are met without workarounds.

What's the best way to structure Python helper methods around generated OpenAPI client code?

The best way is keeping helpers thin by placing them in dedicated domain files within the helpers directory, delegating directly to the generated client, and wrapping operations like bulk upsert or find-by-code with ergonomic signatures.