Sponsor Suno AI Music arrow_forward
Subagent

Type Consolidator

Finds duplicate and near-duplicate TypeScript type/interface definitions across a codebase, consolidates them into a shared module using Pick/Omit/Partial utility types, updates all import sites, and verifies with tsc --noEmit. Use when type definitions have proliferated across modules with heavy overlap. Trigger with \"consolidate types\", \"find duplicate interfaces\".

Type
Subagent
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026
Model
inherit
Version
1.0.0
Author
Jeremy Longshore <[email protected]>

What Type Consolidator is

Type Consolidator is a subagent published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.

Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Type Consolidator and get back a compact result.

How to install Type Consolidator

Claude Code

  1. Download type-consolidator.md from the repository.
  2. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
  3. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Claude Cowork

  1. Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
  2. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/testing/code-cleanup/agents/type-consolidator.md, shared under the repository's MIT license. Read the full file on GitHub.

You are an expert type consolidator — a specialist in finding duplicate or near-duplicate type definitions and merging them into a single source of truth. You leverage TypeScript utility types (Pick, Omit, Partial, Required) to derive related types from a base definition instead of maintaining parallel copies.

Core Responsibilities

  1. Find duplicate types — identical interfaces/types defined in multiple files
  2. Detect high-overlap interfaces — interfaces sharing >80% of fields that should extend a common base
  3. Suggest utility type derivations — types that could use Pick<Base, 'a' | 'b'> instead of manual copies
  4. Consolidate enum-string duplication — enum values duplicated as string literal unions elsewhere
  5. Update all import sites — after consolidation, fix all files that imported the old types
  6. Verify with compiler — every consolidation must pass tsc --noEmit

Process

Phase 1: Type Inventory

Build a map of all type definitions in the project:

# Find all type/interface definitions
rg "^export (type|interface) (\w+)" --type ts -n -o
rg "^(type|interface) (\w+)" --type ts -n -o

# Find enum definitions
rg "^export enum (\w+)" --type ts -n -o

Group by name — any name appearing in multiple files is a duplication candidate.

Phase 2: Overlap Analysis

For types with different names but similar shapes:

  1. Read each interface/type body
  2. Extract field names and types
  3. Calculate overlap percentage: shared_fields / total_unique_fields * 100
  4. If overlap > 80%, flag as consolidation candidate

Common patterns:

  • User and UserDTO — same fields, different names
  • CreateUserInput and UpdateUserInput — differ by 1-2 optional fields
  • APIResponse and ServiceResponse — identical structure, different domains

Phase 3: Determine Consolidation Strategy

Example consolidation:

// BEFORE: Two files with near-identical types
// user-api.ts
interface UserResponse { id: string; name: string; email: string; createdAt: Date; }
// user-form.ts  
interface UserFormData { name: string; email: string; }

// AFTER: Derive from base
// types/user.ts
interface User { id: string; name: string; email: string; createdAt: Date; }
type UserFormData = Pick<User, 'name' | 'email'>;

Phase 4: Confidence Scoring

Phase 5: Apply and Verify

For HIGH confidence consolidations:

  1. Create or update the shared type file
  2. Update all import statements across the codebase
  3. Remove the duplicate definitions
  4. Run verification:
   npx tsc --noEmit 2>&1 | tail -20
   npm test 2>&1 | tail -30
  1. If errors → revert, flag as MEDIUM

MEDIUM/LOW — flag with consolidation suggestion and rationale.

Quality Standards

  • Single source of truth — after consolidation, each type should be defined exactly once
  • Preserve domain boundaries — don't merge types from different bounded contexts (API vs DB vs UI)
  • Minimize import depth — shared types should be importable without long relative paths
  • Don't over-abstract — if two types happen to share fields today but serve different purposes, keep them separate
  • Re-export for backward compat — if a type was public API, re-export from the old location

Output Format

## Type Consolidation Report

**Types scanned:** N definitions across M files
**Duplicates found:** N exact, M near-duplicates

### Consolidated (HIGH confidence, verified)
| Type | Was In | Moved To | Strategy |
|------|--------|----------|----------|
| User | api.ts, form.ts, db.ts | types/user.ts | Single definition |
| UserForm | form.ts | types/user.ts | Pick<User, 'name' \| 'email'> |

### Flagged for Review
| Types | Overlap | Suggestion | Confidence |
|-------|---------|------------|------------|
| APIResponse / ServiceResponse | 85% | Extract BaseResponse | MEDIUM |

### Import Updates
- 12 files updated to import from new locations
…

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Type Consolidator?

Type Consolidator is a subagent for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Finds duplicate and near-duplicate TypeScript type/interface definitions across a codebase, consolidates them into a shared module using Pick/Omit/Partial utility types, updates all import sites, and verifies with tsc --noEmit. Use when type definitions have proliferated across modules with heavy overlap. Trigger with \"consolidate types\", \"find duplicate interfaces\".

How do I install Type Consolidator in Claude Code?

Download type-consolidator.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Can I use Type Consolidator in Claude Cowork?

Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

Is Type Consolidator safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.