ts-library
Install this skill
npx skills add onmax/nuxt-skillsWorks across Claude Code, Cursor, Codex, Copilot & Antigravity
This skill provides a structured framework for building maintainable, high-performance TypeScript libraries. It synthesizes architectural standards observed in modern ecosystems like Vite, Vitest, and Zod. Instead of manually configuring complex build chains, you get a standardized approach to dual-format packaging (CJS and ESM) and precise TypeScript configuration. The skill enforces ESM-first principles while ensuring legacy compatibility, tree-shakable output, and type-safe API patterns. It prioritizes build speed and developer ergonomics by advocating for tools like tsdown and unbuild over manual Babel or Rollup configurations. By focusing on modern resolution strategies and standardized export conditions, this skill helps authors ship packages that work reliably across diverse runtime environments, from Node.js to edge computing, without common pitfalls like missing types or broken import conditions.
When to Use This Skill
- β’Developing a utility library intended for both browser and Node.js environments
- β’Refactoring an existing project to support modern module systems
- β’Setting up a release pipeline for a new open-source TypeScript package
- β’Designing type-safe builder patterns for public-facing SDKs
How to Invoke This Skill
Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:
- βHow should I structure my TypeScript library for dual-format output?
- βConfigure my library to support both ESM and CJS correctly
- βWhat is the best build tool for a modern TypeScript package?
- βHelp me set up tree-shaking for my TS project
- βHow to handle exports in package.json for a TypeScript library?
Pro Tips
- π‘Combine this skill with 'documentation-generation' to ensure your well-designed APIs are clearly documented for consumers.
- π‘For complex API design challenges, iterate with the skill, asking for examples for different patterns (e.g., 'show me a factory pattern example for a plugin API').
- π‘When troubleshooting build issues, use the skill to compare your `tsconfig` and build tool configurations against recommended best practices from popular libraries.
What this skill does
- β’Configuring package.json for dual ESM and CJS compatibility
- β’Optimizing tsconfig.json for modern bundler resolution
- β’Selecting appropriate build pipelines using tsdown or unbuild
- β’Implementing tree-shakable API architectures
- β’Automating library test suites with Vitest
When not to use it
- βDeveloping specialized Nuxt modules (use the nuxt-modules skill instead)
- βSmall, single-file scripts that do not require packaging or distribution
Example workflow
- Initialize project structure following ESM-first principles
- Configure tsconfig.json with Bundler module resolution
- Define package.json exports to handle CJS and ESM consumers
- Select and configure a build tool like tsdown or unbuild
- Write and run unit tests using Vitest
- Implement automated release workflows for npm publishing
Prerequisites
- βFamiliarity with standard TypeScript syntax
- βBasic understanding of npm/yarn/pnpm package management
Pitfalls & limitations
- !Ignoring the impact of sideEffects: false on code tree-shaking
- !Using outdated module resolutions that break modern bundlers
- !Forgetting to include declaration files in package exports
FAQ
How it compares
This skill replaces fragmented, outdated blog post advice with validated, consistent patterns derived from current industry-leading libraries.
π Full skill instructions β original source: onmax/nuxt-skills
Patterns for authoring high-quality TypeScript libraries, extracted from studying unocss, shiki, unplugin, vite, vitest, vueuse, zod, trpc, drizzle-orm, and more.
## When to Use
- Starting a new TypeScript library (single or monorepo)
- Setting up package.json exports for dual CJS/ESM
- Configuring tsconfig for library development
- Choosing build tools (tsdown, unbuild)
- Designing type-safe APIs (builder, factory, plugin patterns)
- Writing advanced TypeScript types
- Setting up vitest for library testing
- Configuring release workflow and CI
**For Nuxt module development:** use
nuxt-modules skill## Quick Reference
| Working on... | Load file |
| --------------------- | ------------------------------------------------------------------ |
| New project setup | [references/project-setup.md](references/project-setup.md) |
| Package exports | [references/package-exports.md](references/package-exports.md) |
| tsconfig options | [references/typescript-config.md](references/typescript-config.md) |
| Build configuration | [references/build-tooling.md](references/build-tooling.md) |
| API design patterns | [references/api-design.md](references/api-design.md) |
| Type inference tricks | [references/type-patterns.md](references/type-patterns.md) |
| Testing setup | [references/testing.md](references/testing.md) |
| Release workflow | [references/release.md](references/release.md) |
| CI/CD setup | [references/ci-workflows.md](references/ci-workflows.md) |
## Key Principles
- ESM-first:
"type": "module" with .mjs outputs- Dual format: always support both CJS and ESM consumers
-
moduleResolution: "Bundler" for modern TypeScript- tsdown for most builds, unbuild for complex cases
- Smart defaults: detect environment, don't force config
- Tree-shakeable: lazy getters, proper
sideEffects: false_Token efficiency: Main skill ~300 tokens, each reference ~800-1200 tokens_
How to Use This Skill Unit
Option A: Project-Specific (Recommended)
- Click "Download" above
- In your project, create the directory:
.agent/skills/ts-library/ - Save the file as
SKILL.md - The agent will automatically discover the skill based on its description.
Option B: Global Installation (All Agents)
Save the file to these locations to make it available across all projects:
- Claude Code:
~/.claude/skills/onmax/nuxt-skills/ts-library/SKILL.md - Cursor:
~/.cursor/skills/onmax/nuxt-skills/ts-library/SKILL.md - Antigravity:
~/.gemini/antigravity/skills/onmax/nuxt-skills/ts-library/SKILL.md
π Install with CLI:npx skills add onmax/nuxt-skills

