ts-performance-rules
TypeScript and JavaScript performance and code-quality rules, usable in any framework. Use when writing, reviewing, or refactoring hot paths, data-structure choices, async flows, or bundle-size-sensitive code. Triggers include "optimize this function", "too slow", "reduce allocations", "bundle size", "lazy load", "speed up imports", or general code review of utilities and services.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 29
- Forks
- 9
01 前言 Front Matter
- name
- ts-performance-rules
- license
- MIT
- description
- TypeScript and JavaScript performance and code-quality rules, usable in any framework. Use when writing, reviewing, or refactoring hot paths, data-structure choices, async flows, or bundle-size-sensitive code. Triggers include "optimize this function", "too slow", "reduce allocations", "bundle size", "lazy load", "speed up imports", or general code review of utilities and services.
02 资源文件 24
- 参考文档rules/async-cheap-condition-before-await.md1.2 KB
- 参考文档rules/async-defer-await.md2.2 KB
- 参考文档rules/async-dependencies.md1.3 KB
- 参考文档rules/async-parallel.md650 B
- 参考文档rules/bundle-analyzable-paths.md2.3 KB
- 参考文档rules/bundle-barrel-imports.md2.7 KB
- 参考文档rules/bundle-conditional.md966 B
- 参考文档rules/bundle-defer-third-party.md924 B
- 参考文档rules/bundle-dynamic-imports.md795 B
- 参考文档rules/bundle-preload.md1.1 KB
- 参考文档rules/js-batch-dom-css.md3.2 KB
- 参考文档rules/js-cache-function-results.md1.9 KB
- 参考文档rules/js-cache-property-access.md536 B
- 参考文档rules/js-cache-storage.md1.6 KB
- 参考文档rules/js-combine-iterations.md768 B
- 参考文档rules/js-early-exit.md1.1 KB
- 参考文档rules/js-flatmap-filter.md1.4 KB
- 参考文档rules/js-hoist-regexp.md1.0 KB
- 参考文档rules/js-index-maps.md850 B
- 参考文档rules/js-length-check-first.md1.7 KB
- 参考文档rules/js-min-max-loop.md2.2 KB
- 参考文档rules/js-request-idle-callback.md2.6 KB
- 参考文档rules/js-set-map-lookups.md532 B
- 参考文档rules/js-tosorted-immutable.md1.7 KB
03 SKILL.md 正文
TypeScript performance rules
A rule catalog for TypeScript/JavaScript code in this repository. Rules are framework-neutral: they apply to the CLI, the agent engines, the gateway, and the web apps. Each rule file states its impact band, an incorrect/correct pair, and the reasoning.
Derived from Vercel's react-best-practices rule catalog (MIT); the React-component-specific rules are intentionally not part of this skill.
Rule index
Plain JavaScript efficiency (js-*.md)
| Rule | Applies when |
|---|---|
js-early-exit |
Loops keep scanning after the answer is known |
js-length-check-first |
Cheap guards can precede expensive calls |
js-set-map-lookups |
Arrays are scanned inside loops for membership |
js-index-maps |
Repeated lookups rebuild the same index |
js-flatmap-filter |
filter().map() (or the reverse) makes two passes |
js-combine-iterations |
Multiple loops over the same array can share one pass |
js-hoist-regexp |
Regex literals or constructions sit inside hot loops |
js-min-max-loop |
Math.min(...bigArray) style spreads blow the stack or re-scan |
js-cache-function-results |
Pure functions recompute the same inputs |
js-cache-property-access |
Deep property chains are read repeatedly in loops |
js-cache-storage |
localStorage/sessionStorage reads sit in hot paths |
js-batch-dom-css |
DOM style reads/writes alternate and force layout thrash |
js-request-idle-callback |
Non-urgent work blocks interaction |
js-tosorted-immutable |
.sort() mutates arrays that callers own |
Async structure (async-*.md)
| Rule | Applies when |
|---|---|
async-cheap-condition-before-await |
A cheap guard sits after an expensive await |
async-defer-await |
Independent awaits run serially for no reason |
async-parallel |
Independent promises could run through Promise.all |
async-dependencies |
A chain of awaits hides which steps truly depend on each other |
Bundle size (bundle-*.md)
| Rule | Applies when |
|---|---|
bundle-barrel-imports |
Imports pull whole barrel files for one symbol |
bundle-conditional |
Large dependencies load for features that are rarely enabled |
bundle-defer-third-party |
Third-party SDKs load eagerly at startup |
bundle-dynamic-imports |
Rare code paths could be import() splits |
bundle-preload |
Known-next navigations could preload their chunks |
bundle-analyzable-paths |
Dynamic import paths are built in ways bundlers cannot trace |
How to apply
- Pick rules by the code's actual shape, not by keyword match alone; the impact band in each rule's frontmatter says how much it typically matters.
- Apply the smallest change that satisfies the rule; do not restructure working code beyond the rule's scope.
- For repository-specific constraints, the nearest
AGENTS.mdand the package's own tests win over these general rules.
04 同仓库更多 Skills
pythinker-webbridge
Pythinker Browser Extension lets AI control the user's real browser — navigate, click, type, read, screenshot, and interact with any website using the user's actual login sessions. Use this skill whenever the user wants to interact with websites, automate browser tasks, scrape web content, or perform any action requiring a real browser. Also use when the user mentions "browser", "webpage", "open URL", "screenshot", or asks to read/interact with any website. Use even for simple-sounding browser requests — the daemon handles all complexity.
golden-skill
Golden fixture skill
tools
暂无简介
review
Analyze the available skill set and recommend candidate groups that could be consolidated into sub-skill bundles. Read-only — proposes a plan, does not move files.
consolidate
Apply an approved sub-skill grouping by moving user-specified skills into a parent bundle, with timestamped backups of every modified directory.
sub-skill
Discover and reorganize the skill inventory into hierarchical sub-skill bundles. Use when the user asks to review, group, or consolidate skills into a parent bundle.