use-modern-javascript-typescript
0
总安装量
1
周安装量
安装命令
npx skills add https://github.com/lednhatkhanh/skills --skill use-modern-javascript-typescript
Agent 安装分布
amp
1
cline
1
opencode
1
cursor
1
kimi-cli
1
codex
1
Skill 文档
Use Modern JavaScript + TypeScript
Apply this skill to produce predictable, type-safe, and maintainable JS/TS code with function-first design and strict defaults.
Quick Start
- Confirm runtime, module system, and TypeScript version before coding.
- Enable strictness (
strict+alwaysStrict) and enforce erasable TS syntax. - Prefer function declarations for named logic and composition over classes.
- Prefer
typeoverinterfaceunless interface-specific behavior is required. - Use modern operators (
?.,??) and immutable patterns by default. - Load only the reference files needed for the task.
Reference Routing
- Load references/style-safety-and-correctness.md for coding rules, strictness, erasable TS constraints, and type-system conventions.
- Load references/performance-and-lazy-evaluation.md for lazy evaluation, concurrency choices, and optimization strategy.
- Load references/pitfalls-and-anti-patterns.md for common failure modes and exact replacements.
- Load references/source-basis.md for canonical source provenance.
Workflow
- Scope the change.
- Identify runtime assumptions (
node, browser, bundler, ESM/CJS) and compatibility constraints. - Identify API surface and behavior contracts before editing internals.
- Set language guardrails.
- Enforce strict mode semantics.
- Enforce erasable TS syntax only.
- Enforce function-first design and type consistency.
- Implement for correctness first.
- Write explicit nullability handling.
- Keep data immutable unless mutation is required and localized.
- Prefer exhaustive control flow for tagged unions and status states.
- Optimize after correctness.
- Defer expensive work until needed.
- Choose lazy or concurrent execution only when semantics remain correct.
- Measure before and after when touching hot paths.
- Validate quality gates.
# project-specific command names vary; run equivalents for:
pnpm -s tsc --noEmit
pnpm -s lint
pnpm -s test
Run additional checks when relevant:
pnpm -s test -- --runInBand # deterministic async debugging
pnpm -s test -- --coverage # branch/edge-case confidence
pnpm -s vitest bench # benchmark hot paths (or equivalent)
Non-Negotiable Rules
- Use function declarations for named functions; avoid function expressions for named logic.
- Prefer functions and composition over classes.
- Prefer
typeoverinterfacewhen either works. - Keep TypeScript erasable-only; avoid TS-only runtime emit constructs.
- Use
unknowninstead ofanyunless unavoidable and justified. - Use
?.and??over fragile chained guards and||defaults. - Avoid mutating shared arrays/objects; prefer non-mutating alternatives.
- Do not use
forEachfor async control flow. - Do not silently swallow errors or rejected promises.
Output Expectations
When applying this skill in a coding task:
- State the runtime + module assumptions.
- Call out strictness and erasable-syntax decisions.
- Highlight correctness decisions around nullability, async flow, and mutation.
- Mention performance decisions only when evidence or profiling supports them.
- List what was validated (
typecheck,lint,test, and any perf checks).