# API Sdk TS

> Builds TypeScript SDKs: tsup bundling with ESM/CJS and d.ts, tsc type checking, typedoc API docs, and npm publishing flow. Use when working with ts build, ts docs or when the user mentions ts build, ts docs.

- Skill: `opknock/api-sdk-ts` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-sdk-ts`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-sdk-ts/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-sdk-ts

---


Builds TypeScript SDKs: tsup bundling with ESM/CJS and d.ts, tsc type checking, typedoc API docs, and npm publishing flow.

## Agentic Workflow: Read -> Reason -> Act (api-sdk-ts)

You are **Api Sdk Ts** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — backend context for `api-sdk-ts`
- Domain: Builds TypeScript SDKs: tsup bundling with ESM/CJS and d.ts, tsc type checking, typedoc API docs, and npm publishing flow.
- **ts-build**: Bundle a TypeScript SDK with tsup — `npm install -D tsup typescript typedoc`
- **ts-docs**: Generate API documentation with typedoc — `npx typedoc src/index.ts --out docs`
- Check `knowledge` and `prerequisites: openapi-generator, node.js, python`

### 2. Reason — think for `api-sdk-ts`
- For `ts-build`: Bundle a TypeScript SDK with tsup — decide which checks to run
- For `ts-docs`: Generate API documentation with typedoc — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-sdk-ts` tools
- Tools: `Glob`, `Grep`, `Read`, `Bash`, `Npx` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-sdk-ts:835c237a`

# API SDK v2 - TypeScript

TypeScript SDK building.

## What This Skill Does
- Bundles ESM/CJS with d.ts output
- Type-checks and generates docs
- Publishes clean npm packages

## When to Use
- Building TS SDKs for distribution
- Maintaining type-safe clients
- Publishing to npm

## Real Commands

```bash
npm install -D tsup typescript typedoc
npx tsup src/index.ts --format cjs,esm --dts
npx tsc --noEmit
npx typedoc src/index.ts --out docs
```

## tsup Config

```ts
import { defineConfig } from 'tsup';
export default defineConfig({
  entry: ['src/index.ts'],
  format: ['cjs', 'esm'],
  dts: true,
  clean: true,
  sourcemap: true
});
```

## Testing
- Run tsc --noEmit before release
- Verify dual-format require/import both work
- Check npm pack contents

## Best Practices
- Export types from index
- Set files in package.json
- Add exports map for ESM/CJS resolution

## Capabilities

### ts-build
Bundle a TypeScript SDK with tsup

**Parameters:**
- `entry` (string): Entry point file
- `formats` (string): cjs, esm, iife
- `outDir` (string): Output directory

**Commands:**
- `npm install -D tsup typescript typedoc`
- `npx tsup src/index.ts --format cjs,esm --dts`
- `npx tsc --noEmit`
- `npx tsup src/index.ts --format cjs,esm --dts --clean`
- `npm run build`

**Examples:**
- tsup --format cjs,esm emits dual-format bundles
- --dts generates type declarations
- tsc --noEmit type-checks the source

### ts-docs
Generate API documentation with typedoc

**Commands:**
- `npx typedoc src/index.ts --out docs`
- `npx typedoc --entryPointStrategy expand src --out docs`
- `npm pack --dry-run`
- `npm publish`

**Examples:**
- -cli --help
- -api --help

## References
- [tsup Docs](https://tsup.egoist.dev/)
- [TypeDoc Docs](https://typedoc.org/)

