ts-sdk-author
Fungsinya
Skill ini memandu pembuatan pustaka TypeScript yang bisa dipasang developer lain dari npm. Untuk tim yang membuat SDK dari codebase yang sudah ada.
Kapan dipakai
- βSaat Anda ingin memisahkan pustaka inti dari aplikasi menjadi paket TypeScript sendiri.
- βSaat Anda perlu merancang API publik sebuah pustaka TypeScript.
- βSaat Anda menyiapkan paket npm untuk rilis, termasuk versi beta atau canary.
Link skill
https://github.com/mindfold-ai/Trellis/blob/main/.agents/skills/ts-sdk-author/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βUbah klien API internal kami menjadi paket TypeScript SDK yang bisa kami terbitkan ke npm.β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent menyiapkan tata letak workspace, merancang antarmuka publik dan batas modul, memilih alat build, mengatur ekspor paket untuk berbagai lingkungan, dan memeriksa paket dengan alat verifikasi sebelum rilis.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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
Pertanyaan umum
Alat build apa yang dibandingkan?
Skill membandingkan tsdown dengan tsup, pengaturan compiler TypeScript biasa, dan unbuild.
Apakah mencakup versi pra-rilis?
Ya. Skill mencakup kanal canary, beta, dan release candidate, serta cara berpindah di antaranya.
Apakah perlu monorepo?
Skill ditulis untuk pengaturan monorepo pnpm.
Detail
Deskripsi asli dari pembuat
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
Popularitas
- Bintang GitHub
- 15k
- Peringkat
- #11036
- Lisensi
- AGPL-3.0
- Diperbarui
- 29/9/2026
Komentar
- β¦
Skill lain dari repositori ini
first-principles-thinking
15kMembantu agent Anda menguji rencana atau desain dengan memecahnya menjadi kebenaran dasar dan bernalar dari situ, bukan mengandalkan kebiasaan atau konvensi.
python-design
15kMembantu agent Anda menulis dan meninjau skrip baris perintah Python dengan modul yang jelas, antarmuka sederhana, dan komplikasi tersembunyi yang lebih sedikit.
trellis-before-dev
15kMembantu agent Anda membaca panduan coding proyek dan catatan tugas sebelum mulai menulis kode, sehingga mengikuti konvensi tim.
trellis-brainstorm
15kMembantu agent Anda memperjelas fitur baru atau tugas yang belum jelas dengan mengajukan satu pertanyaan bermanfaat setiap kali, memeriksa kode, dan menyepakati ruang lingkup yang sempit.
Skill serupa
api-connector-builder
280kMembuat agent Anda membangun koneksi API baru mengikuti pola yang sudah ada. Gunakan saat ingin menambah integrasi lagi tanpa membuat cara baru.
api-design
280kMembantu agent Anda merancang REST API sesuai praktik terbaik. Berguna untuk mengatur cara API berkomunikasi, menampilkan error, dan mengorganisasi data.
backend-patterns
280kMembantu agent Anda dengan pola arsitektur sisi server dan optimasi database. Berguna untuk membangun atau meninjau kode yang berjalan di server.