ts-sdk-author
できること
このスキルは、ほかの開発者がnpmからインストールするTypeScriptライブラリの構築を案内します。既存のコードベースからSDKを作るチーム向けです。
使う場面
- ✓アプリからコアライブラリを切り出し、独立したTypeScriptパッケージにしたいとき。
- ✓TypeScriptライブラリの公開APIを設計する必要があるとき。
- ✓betaやcanaryを含め、npmパッケージの公開の準備をするとき。
スキルのリンク
https://github.com/mindfold-ai/Trellis/blob/main/.agents/skills/ts-sdk-author/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“社内のAPIクライアントを、npmに公開できるTypeScript SDKパッケージに変えてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントはワークスペースの構成を整え、公開インターフェースとモジュールの境界を設計し、ビルドツールを選び、環境ごとにパッケージのexportsを設定します。公開前に検証ツールでパッケージを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
TypeScript SDK Author
End-to-end workflow for shipping a TypeScript SDK as a standalone npm package from inside a pnpm monorepo: workspace layout, public API design, build configuration, distribution shape, monorepo pipeline, verification, and the full release lifecycle including beta / rc / canary channels.
The seven references hold the depth. This file is the unified workflow plus a quick-reference for the patterns you reach for daily.
When to Use This Skill
- Extracting a core library (e.g.
packages/core,packages/sdk) out of an existing CLI or app inside a pnpm workspace - Designing the public API surface of a TypeScript library that strangers will consume — branded types, generic clients, plugin extension points
- Choosing a build tool — tsdown vs tsup vs tsc-only vs unbuild
- Authoring the
package.jsonexportsfield with dual ESM+CJS, isomorphic runtime conditions, and subpath plugin entries - Configuring Turborepo so the SDK rebuilds only when its inputs change and
downstream apps consume the SDK's build output (or raw
srcvia a custom condition) - Wiring
publint --strictandattw --packintoprepublishOnlyor CI - Managing pre-release channels —
canaryper commit,nextfor the upcoming major,beta/rcfor stabilization,latestfor stable — and the transitions between them (beta.N→rc.0→1.0.0→1.1.0-beta.0) - Setting up changesets with GitHub Actions
changesets/action@v1plus npm provenance
Execution Workflow
A single TS SDK build flows through these seven phases. Skip any phase and something will break later — the dependencies between phases are real.
Phase 1 — Workspace & Package Skeleton
Lay down the monorepo and create the empty SDK package.
Core moves:
- Adopt
apps/+packages/+ optionaltools/at the workspace root - Place the SDK in
packages/<sdk-name>/(orpackages/core/) - Give it a scoped name (
@<org>/<sdk-name>) - Wire workspace-internal deps with the
workspace:*protocol - Decide BEFORE anything else: this package will eventually be published, so design the boundary and naming with that in mind
my-repo/
├── pnpm-workspace.yaml
├── package.json # root: only devDeps + workspace scripts
├── apps/
│ └── example-app/ # consumer of the SDK
└── packages/
├── sdk/ # ← the SDK
└── shared-tsconfig/ # internal-only, never published
# pnpm-workspace.yaml
packages:
- "apps/*"
- "packages/*"
Read next: references/workspace-and-layout.md — §2 layout, §3 SDK naming
patterns, §4 internal package creation, §5 package.json skeleton, §7 multi
-repo → monorepo migration.
Phase 2 — Public API Surface
Before writing any code, decide what the SDK's public face looks like.
Two parallel concerns:
A. Module boundaries. The src/ tree splits cleanly into api/ (what
gets re-exported and is part of the contract) and internal/ (do not import
from outside the package). The package.json exports field is your
cheapest enforcement mechanism — anything not listed there cannot be
imported by consumers.
packages/sdk/src/
├── index.ts # barrel — re-exports from api/
├── api/
│ ├── client.ts
│ └── types.ts
└── internal/
├── transport.ts # NOT exported
└── state.ts # NOT exported
B. Type design. SDK types are consumed by strangers, must not leak internals, must be evolvable. Use:
- Branded types for opaque IDs:
type UserId = Brand<string, "UserId"> - Generic clients with sensible defaults so adding type params later is
non-breaking:
createClient<Schema = DefaultSchema>(...) - Discriminated unions for result types:
Result<T, E>with{ ok: true; value: T } | { ok: false; error: E } - Builder pattern for type-safe configuration when option combinations matter
- Interfaces (not type aliases) when users may need to extend the type via declaration merging
Read next:
references/module-boundaries-and-plugins.md— §2src/boundary, §3 runtime layering, §4 provider/adapter, §5 plugin extension, §6 boundary enforcement, §7 patterns vs anti-patternsreferences/type-design-for-public-api.md— §1 branded types, §2 generic surfaces, §3 conditional/mapped types, §4 type guards, §5 builder, §6 utility types ship/internal, §7 tsconfig for libraries, §8 API evolution
Phase 3 — Build Configuration
You need (a) a tsconfig.json tuned for library outp
よくある質問
どのビルドツールを比較しますか?
tsdown、tsup、通常のTypeScriptコンパイラの設定、unbuildを比較します。
プレリリース版も扱いますか?
はい。canary、beta、リリース候補のチャンネルと、それらの間の移行方法を扱います。
モノレポが必要ですか?
このスキルはpnpmのモノレポ構成を前提に書かれています。
詳細
作者による元の説明
Design, build, verify, and publish production-grade TypeScript SDKs as npm packages inside a pnpm monorepo. Covers workspace layout, public API and module boundaries, plugin extension points, branded types and library-tuned tsconfig, tsdown bundling (vs tsup/tsc-only/unbuild), package.json exports with dual ESM+CJS and isomorphic conditions (browser/workers/RN/deno), Turborepo pipelines, publint and @arethetypeswrong/cli verification, changesets pre-release mode, npm dist-tags (latest/next/beta/rc/canary), and the alpha→beta→rc→stable release lifecycle. Triggers on: build a TS SDK, extract cor
repo: mindfold-ai/Trellis
人気
- GitHubのスター
- 15k
- ランキング
- #11036
- ライセンス
- AGPL-3.0
- 更新日
- 2026/9/29
コメント
- …
このリポジトリの他のスキル
first-principles-thinking
15k計画や設計を基本的な真理に分解し、そこから積み上げて検討することで、慣習や習慣に頼らずに、それが本当に最良の方法かを確かめるよう、エージェントを手助けします。
python-design
15k明確なモジュール、単純なインターフェース、隠れた複雑さの少ないPythonのコマンドラインスクリプトを、エージェントが書きレビューするのを手助けします。
trellis-before-dev
15k書き始める前に、プロジェクトのコーディングのガイドラインとタスクのメモを読み、エージェントがチームの慣例に従うよう手助けします。
trellis-brainstorm
15k新しい機能や不明確なタスクを、一度に一つの有益な質問をし、コードを確認し、狭いスコープに合意することで、明確にする手助けをします。
似ているスキル
api-connector-builder
280kエージェントが既存のパターンに従って、新しいAPI連携を構築します。新しい方式を作らずに、もう一つ連携を追加したいときに使います。
api-design
280kエージェントがベストプラクティスに沿ってREST APIを設計できるようにします。APIの通信方法、エラーの表示方法、データの整理方法を決めるのに役立ちます。
backend-patterns
280kエージェントのサーバーサイドのアーキテクチャパターンとデータベースの最適化を支援します。サーバー上で動くコードを作成またはレビューするときに役立ちます。