Add Utils Function
Workflow
- •Identify the target package based on function scope, defaulting to
packages/utilsfor general-purpose helpers. If unsure, use theselect-packageskill.- •Environment-agnostic, broadly useful helpers ->
packages/utils - •Browser-only APIs or DOM usage ->
packages/web-utils - •Node-only APIs (fs, process, path, http) ->
packages/node-utils - •Canvas 2D rendering or canvas math helpers ->
packages/canvas-utils - •AI/ML-related helpers (prompting, model utilities) ->
packages/ai-utils
- •Environment-agnostic, broadly useful helpers ->
- •Search existing modules to avoid duplication (
rg <keyword> packages). - •Choose the most appropriate module file (e.g.,
array.ts,validators.ts) or create a new focused file. If creating a new file, use thecreate-module-fileskill. - •Implement the function with explicit types and no
any. - •Add bilingual JSDoc (Chinese + English), parameter/return docs, and at least two examples. Use the
bilingual-jsdocskill if needed. - •Export the function from the package
src/index.ts. Use theupdate-index-exportsskill if needed. - •Add unit tests in the package
__tests__directory. Use theadd-testsskill if needed. - •Suggest verification commands:
- •
TEST_API=<package> npm run test - •
npm run build
- •