Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

avoid-repeated-params避免重复参数

Agent Skill

avoid-repeated-params 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

196

周安装

8

GitHub Stars

2

下载量

63
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:avoid-repeated-params(避免重复参数)
来源仓库:https://github.com/marius-townhouse/effective-typescript-skills
仓库路径:skills/avoid-repeated-params
安装命令:
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill avoid-repeated-params
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/marius-townhouse/effective-typescript-skills --skill avoid-repeated-params

简介

avoid-repeated-params 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。

  • 它避免函数中相同类型的重复参数,推荐使用命名对象参数。
  • 多个同类型参数易导致顺序混淆,命名方式优于位置依赖。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Avoid Repeated Parameters of the Same Type

Overview

Multiple parameters of the same type invite mix-ups.

When a function takes (string, string, string), it's easy to pass arguments in the wrong order. Use named parameters (objects) to make calls self-documenting.

When to Use This Skill

  • Functions with 2+ parameters of the same type
  • Parameters that are easy to confuse
  • APIs that users will call frequently
  • Refactoring confusing function signatures

The Iron Rule

If parameter order is confusing, use an object.
Names prevent mix-ups better than positions.

Remember:

  • TypeScript can't detect swapped same-type arguments
  • Position-based APIs require documentation study
  • Object parameters are self-documenting
  • IDE autocomplete works better with named params

Detection: Easy to Confuse

function sendEmail(
  to: string,
  subject: string,
  body: string
) { /* ... */ }

// Which is which?
sendEmail(
  'Hello!',
  'bob@example.com',
  'Welcome to our service'
);
// Whoops! Subject and recipient are swapped

TypeScript sees (string, string, string) - all valid, no error.

Solution: Object Parameter

function sendEmail(params: {
  to: string;
  subject: string;
  body: string;
}) { /* ... */ }

// Now it's clear:
sendEmail({
  to: 'bob@example.com',
  subject: 'Hello!',
  body: 'Welcome to our service'
});

// Wrong order is obvious:
sendEmail({
  to: 'Hello!',  // Clearly wrong
  subject: 'bob@example.com',  // Obviously an email
  body: 'Welcome'
});

When Position-Based is OK

Different Types

// Clear: types are different
function setProperty(obj: object, key: string, value: unknown) { }

// Clear: number vs string
function pad(str: string, length: number) { }

Single Parameter

// Nothing to confuse
function greet(name: string) { }

Well-Known Conventions

// Math functions are universally position-based
function max(a: number, b: number) { }

// Array methods follow established patterns
function slice(arr: any[], start: number, end: number) { }

Destructuring for Clean Implementation

// Clean function signature and implementation
function sendEmail({
  to,
  subject,
  body
}: {
  to: string;
  subject: string;
  body: string;
}) {
  console.log(`Sending to ${to}: ${subject}`);
  // Use to, subject, body directly
}

Optional Parameters with Defaults

interface SendEmailOptions {
  to: string;
  subject: string;
  body: string;
  cc?: string[];
  priority?: 'high' | 'normal' | 'low';
}

function sendEmail({
  to,
  subject,
  body,
  cc = [],
  priority = 'normal'
}: SendEmailOptions) {
  // ...
}

// Call with just required params
sendEmail({ to: 'bob@example.com', subject: 'Hi', body: 'Hello!' });

// Or with optional params
sendEmail({
  to: 'bob@example.com',
  subject: 'Urgent',
  body: 'Please respond',
  priority: 'high'
});

Mixing Required and Optional

// Required first parameter, options object second
function createElement(
  tagName: string,
  options?: {
    className?: string;
    id?: string;
    children?: Element[];
  }
) { /* ... */ }

createElement('div');
createElement('div', { className: 'container', id: 'main' });

Real-World Example: Date Formatting

// Bad: which is format, which is locale?
function formatDate(date: Date, format: string, locale: string): string { }

formatDate(new Date(), 'en-US', 'YYYY-MM-DD');  // Wrong order!

// Good: named parameters
function formatDate(
  date: Date,
  options: { format: string; locale: string }
): string { }

formatDate(new Date(), { format: 'YYYY-MM-DD', locale: 'en-US' });

Rectangle Example

// Bad: easy to confuse width/height, x/y
function drawRect(x: number, y: number, width: number, height: number) { }

// Better: grouped semantically
function drawRect(
  position: { x: number; y: number },
  size: { width: number; height: number }
) { }

// Best: named everything
interface DrawRectOptions {
  x: number;
  y: number;
  width: number;
  height: number;
}
function drawRect(options: DrawRectOptions) { }

Pressure Resistance Protocol

1. "Too Verbose"

Pressure: "Object syntax is longer"

Response: One-time verbosity prevents ongoing confusion.

Action: Use named parameters for clarity; brevity isn't worth bugs.

2. "It's a Standard Pattern"

Pressure: "Other libraries use positional params"

Response: You're not other libraries. Make your API clear.

Action: Design for your users, not convention.

Red Flags - STOP and Reconsider

  • Functions with 2+ parameters of the same type
  • Documentation needed to explain parameter order
  • Tests that verify parameter order
  • Bugs from swapped arguments

Common Rationalizations (All Invalid)

ExcuseReality
"It's only two parameters"Two strings are still confusable
"IDE shows parameter names"Names shown, not enforced
"We have good documentation"People don't read docs

Quick Reference

// DON'T: Same-type positional parameters
function fn(a: string, b: string, c: string) { }
fn('x', 'y', 'z');  // What's what?

// DO: Named parameters
function fn(params: { a: string; b: string; c: string }) { }
fn({ a: 'x', b: 'y', c: 'z' });  // Clear!

// OK: Different types
function fn(name: string, count: number) { }

// OK: Single parameter
function fn(message: string) { }

The Bottom Line

Named parameters prevent argument mix-ups.

When functions take multiple parameters of the same type, use an object parameter. The small verbosity cost is repaid many times over in prevented bugs and improved readability.

Reference

Based on "Effective TypeScript" by Dan Vanderkam, Item 38: Avoid Repeated Parameters of the Same Type.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

36.42%
按下载量换算23

Claude

30.1%
按下载量换算19

Cursor

20.32%
按下载量换算13

Gemini CLI

9%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills