Agent SkillsUsefulSoftwareCo/executor › wrdn-effect-value-inferred-types

wrdn-effect-value-inferred-types

GitHub

自动将手动定义的TypeScript对象类型替换为由运行时工厂函数推断的类型。通过查找重复的类型定义,将其重构为ReturnType<typeof factory>,防止类型与实现脱节,同时保留稳定的导出名称供消费者使用。

.agents/skills/wrdn-effect-value-inferred-types/SKILL.md UsefulSoftwareCo/executor

触发场景

代码审查发现接口或类型别名镜像了返回对象的形状 存在手动维护且易漂移的对象类型定义

安装

npx skills add UsefulSoftwareCo/executor --skill wrdn-effect-value-inferred-types -g -y
更多选项

非标准路径

npx skills add https://github.com/UsefulSoftwareCo/executor/tree/main/.agents/skills/wrdn-effect-value-inferred-types -g -y

不安装直接使用

npx skills use UsefulSoftwareCo/executor@wrdn-effect-value-inferred-types

指定 Agent (Claude Code)

npx skills add UsefulSoftwareCo/executor --skill wrdn-effect-value-inferred-types -a claude-code -g -y

安装 repo 全部 skill

npx skills add UsefulSoftwareCo/executor --all -g -y

预览 repo 内 skill

npx skills add UsefulSoftwareCo/executor --list

SKILL.md

Frontmatter
{
    "name": "wrdn-effect-value-inferred-types",
    "description": "Replace duplicated object API types with types inferred from the runtime value or factory that owns the shape. Use when lint or review flags an interface\/type alias that mirrors a returned object such as a plugin extension, client surface, route map, or handler table.",
    "allowed-tools": "Read Grep Glob Bash"
}

You fix one pattern: a TypeScript object type manually mirrors a runtime object that already owns the shape.

Prefer value-first APIs. Build the object in a named factory, then export type X = ReturnType<typeof makeX>. Consumers keep importing the stable type name, but the type cannot drift from the implementation.

Trace before changing

  1. Find the source value. Look for an object returned from a named factory, extension: (...) => ({ ... }), a client object, route map, or handler table.
  2. Find the duplicate type. A nearby interface X or type X = { ... } repeats the object methods/properties.
  3. Check whether the value is the source of truth. If the interface is a contract with multiple implementations, keep the interface.
  4. Preserve the exported type name. Replace its definition with ReturnType<typeof makeX> and update callers only if needed.
  5. Use satisfies only at boundaries. Do not make the implementation satisfy a duplicate shape that could drift.

Fix shape

const makePluginExtension = (ctx: PluginCtx<Store>) => {
  const addSource = ...
  const removeSource = ...

  return {
    addSource,
    removeSource,
  };
};

export type PluginExtension = ReturnType<typeof makePluginExtension>;

For factories that need options:

const makePluginExtension =
  (options: PluginOptions) =>
  (ctx: PluginCtx<Store>) => ({
    addSource: ...,
  });

export type PluginExtension = ReturnType<ReturnType<typeof makePluginExtension>>;

Bad

export interface McpPluginExtension {
  readonly addSource: (config: McpSourceConfig) => Effect.Effect<AddResult, Failure>;
  readonly removeSource: (namespace: string, scope: string) => Effect.Effect<void, Failure>;
}

extension: (ctx) => {
  return {
    addSource,
    removeSource,
  } satisfies McpPluginExtension;
};

Good

const makeMcpPluginExtension = (ctx: PluginCtx<McpStore>) => {
  return {
    addSource,
    removeSource,
  };
};

export type McpPluginExtension = ReturnType<typeof makeMcpPluginExtension>;

extension: makeMcpPluginExtension;

What not to report

  • Service/dependency interfaces with multiple implementations.
  • Public config input types that are intentionally a stable authored API.
  • Branded IDs, discriminated unions, or small aliases that do not mirror one object value.
  • Test fakes typed against an existing exported contract.
  • Schema-owned data shapes; use wrdn-effect-schema-inferred-types for those.

Output requirements

When reviewing, report:

  • File and line of the duplicate object type or satisfies usage.
  • Value/factory that owns the shape.
  • Why the manual type can drift.
  • Fix: the exact ReturnType alias to introduce.

When editing, name the factory after the exported type, e.g. makeMcpPluginExtension for McpPluginExtension.

版本历史

  • fd4fb02 当前 2026-07-05 10:55

同 Skill 集合

.agents/skills/stack/SKILL.md
.agents/skills/wrdn-effect-atom-optimistic/SKILL.md
.agents/skills/wrdn-effect-atom-reactivity-keys/SKILL.md
.agents/skills/wrdn-effect-promise-exit/SKILL.md
.agents/skills/wrdn-effect-raw-fetch-boundary/SKILL.md
.agents/skills/wrdn-effect-schema-boundaries/SKILL.md
.agents/skills/wrdn-effect-schema-inferred-types/SKILL.md
.agents/skills/wrdn-effect-typed-errors/SKILL.md
.agents/skills/wrdn-effect-vitest-tests/SKILL.md
.agents/skills/wrdn-package-boundaries/SKILL.md
.agents/skills/wrdn-typescript-type-safety/SKILL.md
.claude/skills/emulate/SKILL.md
.claude/skills/prod-telemetry/SKILL.md
.claude/skills/self-contained-modals/SKILL.md
.skills/cli-release/SKILL.md
.skills/effect-atom-optimistic-updates/SKILL.md
.skills/effect-http-testing/SKILL.md
.skills/effect-use-pattern/SKILL.md
.skills/graphite/SKILL.md
.skills/warden-security-review/SKILL.md

元信息

文件数
0
版本
8bc037d
Hash
6e843fa4
收录时间
2026-07-05 10:55

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-18 01:55
浙ICP备14020137号-1 $访客地图$