scaffold-library
Setup library project structure with src, build config, exports, and tests
Files1
View on GitHubSKILL.mdskills/core/scaffold-library/SKILL.md
GitHubContext
You will create a library "{{input.name}}" targeting {{input.runtime}}. Output format: {{input.format}}.
Instructions
Setup package.json
- name, version, description, license
- main (CJS), module (ESM), types
- exports field for dual package
- scripts: build, test, lint, prepublishOnly
- peerDependencies (not dependencies) for shared libs
Setup TypeScript config
tsconfig.jsonfor sourcetsconfig.build.jsonfor build output- Strict mode enabled
- Declaration files enabled
Setup build tool
- tsup or unbuild (simple, near-zero-config)
- Config for ESM + CJS output
- Source maps
- DTS generation
Create source structure
src/ ├── index.ts # Public API exports ├── types.ts # Shared types └── [modules]/ # Feature modulesSetup testing
- Vitest config
- Example test file
- Coverage config
Setup linting
- ESLint config (if not already present)
- Prettier config (if not already present)
Create README stub
- Installation
- Quick start
- API reference placeholder
Setup CI (if jonggrang.json ci.provider != none)
- Build + test on PR
- Publish on tag/release
Script
#!/bin/bash
# Initialize if no package.json
if [ ! -f "package.json" ]; then
npm init -y
fi
# Install dev dependencies
npm install -D typescript tsup vitest @types/node
Validation
-
npm run buildsucceeds -
npm run testpasses - Output files generated (dist/)
- Types generated (.d.ts)
- ESM import works
- CJS require works (if format includes cjs)
- Exports field correct in package.json