customize-sdk-hooks
Use when implementing SDK code hooks for custom logic (not spec configuration or runtime overrides).
Skill by speakeasy-api
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/speakeasy-api-customize-sdk-hooks
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/customize-sdk-hooks
What's inside
- Skill name
customize-sdk-hooks- Description
- Use when implementing SDK code hooks for custom logic (not spec configuration or runtime overrides). Covers SDK lifecycle hooks: BeforeRequest, AfterSuccess, AfterError for custom headers, telemetry, HMAC signing, and request/response transformation. Triggers on "SDK hooks", "add hooks", "BeforeRequestHook", "custom logic in SDK", "telemetry hook", "SDK middleware", "intercept requests", "HMAC signing hook", "custom code in hooks directory".
- License
- Apache-2.0
- Instructions
- 368 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (1)
- SKILL.md
SKILL.md (first lines)
# Customize SDK Hooks
## When to Use
Use this skill when you need to **add custom code logic** to the generated SDK:
- Add custom headers (User-Agent, correlation IDs) to every SDK request via code
- Implement telemetry, logging, or observability at the SDK level
- Add custom authentication logic (HMAC signatures, token refresh) that runs in SDK code
- Transform responses or errors before they reach the caller
- Implement custom request/response middleware
- User says: "SDK hooks", "add custom logic", "intercept requests with code", "HMAC signing hook", "telemetry in SDK"
**NOT for**:
- OpenAPI spec modifications (see `manage-openapi-overlays`)
- Runtime SDK client config (see `configure-sdk-options`)
## Inputs
- **Hook type**: Which lifecycle event to intercept (init, before request, after success, after error)
- **SDK language**: The target language of the generated SDK (TypeScript, Go, Python, Java, C#, Ruby, PHP, etc.)
- **Custom logic**: The behavior to inject at the hook point
## Outputs
- Hook implementation file(s) in `src/hooks/` (or language equivalent)
- Updated `src/hooks/registration.ts` to register the new hook
- The hook is preserved across SDK regenerations
## Prerequisites
- A Speakeasy-generated SDK (any supported language)
- Understanding of the SDK's request/response lifecycle
- The `src/hooks/` directory exists in the generated SDK (created by default)
## Hook Types
| Hook | When Called | Common Use Cases |
|------|-----------|-----------------|
| `SDKInitHook` | SDK client initialization | Configure defaults, validate config, set base URL |
| `BeforeCreateRequestHook` | Before the HTTP request object is created | Modify input parameters, inject defaults |
| `BeforeRequestHook` | Before the HTTP request is sent | Add headers, logging, telemetry, sign requests |
| `AfterSuccessHook` | After a successful HTTP response | Transform response, emit warnings, log metrics |
| `AfterErrorHook` | After an HTTP error response | Error transformation, retry logic, error logging |
### Hook Interfaces (TypeScript)
```typescript
// SDKInitHook
interface SDKInitHook {
sdkInit(opts: SDKInitOptions): SDKInitOptions;
}
// BeforeCreateRequestHook
interface BeforeCreateRequestHook {
beforeCreateRequest(hookCtx: BeforeCreateRequestHookContext, input: any): any;
}
// BeforeRequestHook
interface BeforeRequestHook {
beforeRequest(
hookCtx: BeforeRequestHookContext,
request: Request
): Request;
}
// AfterSuccessHook
interface AfterSuccessHook {
afterSuccess(
hookCtx: AfterSuccessHookContext,
response: Response
): Response;
}
// AfterErrorHook
interface AfterErrorHook {
afterError(
hookCtx: AfterErrorHookContext,
response: Response | null,
error: unknown
): { response: Response | null; error: unknown };
}
```
## Directory Structure
```
src/
hooks/
types.ts # Generated - DO NOT EDIT (hook interfaces/types)
registration.ts # Custom - YOUR registrations (preserved on regen)
custom_useragent.ts # Custom - your hook implementations
telemetry.ts # Custom - your hook implementations
```
**Key rule**: `registration.ts` and any custom hook files you create are preserved
during SDK regeneration. The `types.ts` file is regenerated and should not be modified.
## Registration Pattern
All hooks are registered in `src/hooks/registration.ts`. This file is created once
by the generator and never overwritten. You add your hooks here:
```typescript
// src/hooks/registration.ts
import { Hooks } from "./types.js";
import { CustomUserAgentHook } from "./custom_useragent.js";
import { TelemetryHook } from "./telemetry.js";
/*
* This file is only ever generated once on the first generation and then is free
* to be modified. Any hooks you wish to add should be registered in the
* initHooks function. Feel free to define them in this file or in separate files
* in the hooks folder.
*/
export function initHooks(hooks: Hooks) {
hooks.registerBeforeRequestHook(new CustomUserAgentHook());
hooks.registerAfterSuccessHook(new TelemetryHook());From speakeasy-api/sdk-generation-skills, Apache-2.0.
More from speakeasy-api/sdk-generation-skills
- 0.487score
writing-openapi-specs
speakeasy-api
Reference guide for OpenAPI specification best practices, naming conventions, and expressing complex REST API patterns like polymorphism, enums, file uploads…
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
configure-sdk-options
speakeasy-api
Use when CONFIGURING an existing SDK - NOT for initial generation.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
diagnose-generation-failure
speakeasy-api
Use when SDK generation failed or seeing errors.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
extract-openapi-from-code
speakeasy-api
Use when extracting or generating an OpenAPI spec from existing API code.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
generate-mcp-server
speakeasy-api
Use when generating an MCP server from an OpenAPI spec with Speakeasy.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
generate-terraform-provider
speakeasy-api
Use when generating a Terraform provider from an OpenAPI spec with Speakeasy.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
improve-sdk-naming
speakeasy-api
Use when you want AI-powered suggestions for SDK naming improvements via the `speakeasy suggest` command (not manual overlay creation).
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
manage-openapi-overlays
speakeasy-api
Use when creating, applying, or validating overlay files including x-speakeasy extensions.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
orchestrate-multi-repo-sdks
speakeasy-api
Use when each language SDK lives in a separate repository.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
orchestrate-multi-target-sdks
speakeasy-api
Use when generating SDKs for multiple languages from a single OpenAPI spec, or multiple SDK variants from different sources.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
setup-sdk-testing
speakeasy-api
Use when setting up SDK testing, configuring contract tests, writing Arazzo test workflows, or running integration tests.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
start-new-sdk-project
speakeasy-api
Use when generating a new SDK from an OpenAPI spec.
SkillDFreshness: D★ 18Claude Code +9
Signals
- Stars
- 18
- Forks
- 6
- Open issues
- 0
- Last commit (this folder)
- Feb 3, 2026 (8 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Website
- www.speakeasy.com/docs
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from speakeasy-api
- 0.487score
configure-sdk-options
speakeasy-api
Use when CONFIGURING an existing SDK - NOT for initial generation.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
diagnose-generation-failure
speakeasy-api
Use when SDK generation failed or seeing errors.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
extract-openapi-from-code
speakeasy-api
Use when extracting or generating an OpenAPI spec from existing API code.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
generate-mcp-server
speakeasy-api
Use when generating an MCP server from an OpenAPI spec with Speakeasy.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
generate-terraform-provider
speakeasy-api
Use when generating a Terraform provider from an OpenAPI spec with Speakeasy.
SkillDFreshness: D★ 18Claude Code +9 - 0.487score
setup-sdk-testing
speakeasy-api
Use when setting up SDK testing, configuring contract tests, writing Arazzo test workflows, or running integration tests.
SkillDFreshness: D★ 18Claude Code +9
Cite this page
customize-sdk-hooks skill. Agent Mart. https://agentmart.dev/skills/speakeasy-api-customize-sdk-hooks (last updated 2026-10-24)