Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

ts-reuse-reviewts 重用审查

Agent Skill

ts-reuse-review 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

245

周安装

10

GitHub Stars

4

下载量

79
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:ts-reuse-review(ts 重用审查)
来源仓库:https://github.com/trancong12102/agentskills
仓库路径:skills/ts-reuse-review
安装命令:
npx skills add https://github.com/trancong12102/agentskills --skill ts-reuse-review
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/trancong12102/agentskills --skill ts-reuse-review

简介

ts-reuse-review 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 适用于代码复用审查、模式识别和技术方案调研等研究检索类任务。
  • 通过 GitHub 仓库安装,使用 npx skills add 命令添加指定技能。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

TS Reuse Review

Scans a TypeScript/JavaScript diff for code that reinvents existing utilities. Reports a prioritized list of reuse opportunities — external libs (es-toolkit, date-fns, zod), ES2020+ native APIs, installed project libs (effect, remeda, ts-pattern, etc.), and already-existing internal helpers. Never applies edits.

Prerequisites

  • ripgrep — used for internal helper search. Install: brew install ripgrep or cargo install ripgrep.
  • ast-grep — structural pattern matching. Install: npm i -g @ast-grep/cli or brew install ast-grep.

If ast-grep is missing, fall back to ripgrep-only detection and flag the degraded mode in the report header. Do not abort.

Workflow

Do not read script source code. Run scripts directly and use --help for usage. Scripts live under scripts/ relative to this skill's directory.

Step 1: Determine review scope

If the scope is not already clear from the invocation, use AskUserQuestion:

  • Uncommitted changes (default) — staged, unstaged, and untracked TS/JS files
  • Branch diff — current branch vs a base branch
  • Specific commit — one changeset by SHA

Extract the list of changed .ts, .tsx, .js, .jsx, .mjs, .cjs files. Skip *.d.ts, generated files under **/dist/**, **/build/**, **/.next/**, **/node_modules/**, and test fixtures under **/fixtures/**.

Step 2: Detect installed project libraries

Run scripts/detect-libs.sh to scan package.json (plus workspace packages/*/package.json if monorepo) for relevant libs. It returns a JSON-ish list of installed libs grouped by domain:

  • general utils: es-toolkit, lodash-es, ramda, remeda, radash
  • date: date-fns, dayjs, luxon
  • schema: zod, valibot, yup, superstruct, arktype
  • async/effects: effect, neverthrow, rxjs, ts-pattern
  • http/query: ky, ofetch, axios, @tanstack/react-query, swr
  • collections: immer, immutable

The output decides the "prefer" tier for Step 5. Fixed targets (es-toolkit, date-fns, zod) stay in the catalog even when not installed — the report suggests installing them.

Step 3: Extract changed code regions

For each changed file, get the new-side hunks via git diff and keep only added or modified lines. Discard pure deletions and context. Store as {file, startLine, endLine, content} for pattern scanning.

Step 4: Run pattern scan

Run scripts/run-patterns.sh <file1> [<file2>...] on each changed file. The wrapper runs all rules in scripts/patterns/ with the correct language per extension (TypeScript for.ts/.js/.mjs/.cjs, Tsx for.tsx/.jsx — ast-grep has separate parsers). Only keep matches whose line range overlaps the changed region.

The catalog is ~80 rules grouped into 14 categories (collection shape, timing/async, equality/clone, date, schema, effect-specific, web runtime, node APIs, native supersedes, correctness bugs, React hooks, event/pub-sub, i18n, stringly). Load references/rule-categories.md when you need to understand which rules fire for a diff or are adding new rules.

If ast-grep is unavailable, fall back to the ripgrep heuristic patterns embedded in each rule's fallback_regex metadata field and mark matches as confidence: low.

Step 5: Cross-reference against catalogs

Load the references relevant to the hits from Step 4 — do not load every file:

Always load (catalog core):

  • references/external-libs.md — fixed external catalog (es-toolkit + date-fns + zod).
  • references/native-apis.md — ES2020+ through ES2025 natives (immutable array variants, Object.hasOwn, Promise.withResolvers, URL.canParse, Set operations, Iterator helpers).
  • references/project-libs.md — dynamic handling of installed libs from Step 2.

Load on match (progressive disclosure):

  • references/react-patterns.md — diff touches .tsx / .jsx files.
  • references/effect-patterns.mdeffect in installed deps.
  • references/node-vs-web.mdwrangler.toml, vercel.json edge config, deno.json, or a file under workers/ / edge/ / functions/ is in the diff.
  • references/testing-patterns.md — diff includes test files AND vitest or jest is installed.
  • references/zod-patterns.md — any zod-family rule fires (email-regex, regex-uuid, regex-ipv4, regex-iso-datetime, zod-discriminated-union, url-validate-try, manual-schema-guard) and zod/valibot/yup/arktype is installed.
  • references/query-patterns.mdreact-fetch-useeffect rule fires OR any of @tanstack/react-query / swr / @reduxjs/toolkit/query is installed.
  • references/form-patterns.mdreact-hook-form / formik / @tanstack/react-form / @conform-to/react installed AND diff contains a React form component.
  • references/immer-immutability.mdnested-spread-update rule fires OR immer / use-immer / mutative installed.

This progressive-disclosure approach keeps the skill under the per-invocation context budget even as the catalog grows.

For each pattern match:

  1. If the primary replacement lives in a native API, recommend the native (highest priority — zero deps).
  2. Else if an installed project lib (from Step 2) has a canonical match, recommend that lib's import. Example: effect installed → prefer Effect.retry over es-toolkit retry.
  3. Else if a fixed external lib matches (es-toolkit/date-fns/zod), recommend the import and — if the lib is not installed — suggest bun add es-toolkit (or npm/pnpm equivalent detected from the lockfile).
  4. Drop the match if none apply.

Step 6: Internal helper dedup check

Before emitting any external replacement, run scripts/scan-internal-utils.sh <fn-name-candidates> to grep workspace util directories (src/**/utils/**, src/**/lib/**, packages/*/src/**, shared/**, common/**) for existing helpers with matching names or call signatures.

If a matching internal helper exists, replace the external recommendation with use existing: <path>:<line>. This prevents suggesting a new import when the project already has the util.

Step 7: Emit report

Output format — load references/output-format.md for the full template. Summary:

ts-reuse-review findings:

<P?>  <file>:<line>
      pattern: <short description>
      replace: <suggested replacement>
      confidence: high|medium|low
      why: <trigger source — catalog entry, installed lib, native API, internal helper>

summary: <N> findings (<breakdown by priority>)

Priority levels:

  • P1 — clear reinvention, replacement is a one-line import swap, reduces ≥5 lines.
  • P2 — reinvention but replacement changes the shape slightly (named args vs positional, different null handling).
  • P3 — stylistic preference (native vs lib, one lib vs another already installed).
  • Drop matches below P3 threshold to keep signal high.

End the report. Do not apply edits. Do not open files for modification.

Rules

  • Report only — Never invoke Edit, Write, or NotebookEdit. Output is text findings; the user or a downstream skill decides whether to apply changes. This makes the skill safe to run in parallel with other reviewers.
  • Scope to changed regions — Matches outside added/modified hunks are noise. Do not flag pre-existing code the user did not touch in this diff.
  • Prefer native > installed-lib > fixed-catalog — Order preserves dependency minimalism. A native API suggestion beats an es-toolkit suggestion even when es-toolkit is installed.
  • Check internal helpers before suggesting externals — A workspace that already has utils/chunk.ts should not be told to import chunk from es-toolkit. Reuse trumps install.
  • Suggest install only when the fixed-catalog lib is missing and no native/internal alternative exists — Avoid noisy "install es-toolkit" spam when a one-liner native works.
  • Do not flag trivial wrappers — A 3-line helper around a native call is not a reuse violation unless it duplicates an installed lib's behavior. Minimum threshold: reinvention ≥5 lines OR exact signature match to a catalog entry.
  • Merge duplicate findings per file — If the same reinvention appears on multiple lines of one file, collapse to one finding listing all line numbers.
  • Confidence calibrationhigh when ast-grep structural match + catalog signature match; medium when regex-only match or catalog signature match only; low when fallback regex heuristic or ambiguous shape.
  • Language scope — TS/JS only — Skip .py, .rs, .go, .md, .json, .yml. Extension enforcement happens in Step 1.
  • Never mutate workspace state — No writes to package.json, no bun install execution. Install suggestions are text-only.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.42%
按下载量换算27

Claude

29.9%
按下载量换算24

Cursor

22.3%
按下载量换算18

Gemini CLI

11.19%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills