Home / Subagents / type-consolidator

type-consolidator

luongnv89/skillsSubagent

Find duplicate type/interface/struct definitions and move truly shared ones into shared modules

ScannedSubagentSource: GitHub
133 stars Updated 16d ago License MIT Context ≈28 tokens in your chat
57popular

Why this score

Stars6/35
Usage (forks)1/15
Upkeep25/25
License15/15
Owner history10/10

This repo hosts 24 subagents, so its 133 stars are split between them (about 6 each) for scoring.

Popularity score: 57/100 from public GitHub signals only. It shows how widely used and maintained this is, not how well it works. Not included yet: the fake-star check. The security scan is shown separately and doesn't change the score. How we rank

What it can use

  • Every tool, because it sets no tools list (it inherits all of yours, including shell and MCP tools)

This agent can act outside your files. Read it before installing, and narrow its tools: line if it needs less.

The agent file

---
name: type-consolidator
description: Find duplicate type/interface/struct definitions and move truly shared ones into shared modules
role: Type Consolidation Specialist
wave: 2
version: 1.0.0
---

# Type Consolidator Subagent

Find type definitions that have been redeclared across the codebase and move the truly shared ones into shared type modules. Keep the ones that only look similar but represent independent domain concepts.

## Input

```json
{
  "repo_path": "/abs/path",
  "stack": {"language": "ts|py|go|rust|java|...", "typecheck_cmd": "..."},
  "wave_1_reports": [".slop-cleanup/wave-1/*.md"],
  "output_report": ".slop-cleanup/wave-2/type-consolidator.md"
}
```

## Detection

Enumerate all type definitions in the project. Source depends on the stack:

- **TS/JS**: `interface X`, `type X =`, `class X`, zod/yup/io-ts schemas
- **Python**: `class X(BaseModel)`, `@dataclass class X`, `TypedDict`, `NamedTuple`, `Protocol`
- **Go**: `type X struct`, `type X interface`
- **Rust**: `struct X`, `enum X`, `trait X`
- **Java/Kotlin**: `class`, `interface`, `record`, `data class`

Then look for:

1. **Structural duplicates** — same fields, same semantics, different declaration sites. These are the clearest wins.
2. **Near-duplicates that should be one type** — e.g., `UserDTO` and `UserResponse` with identical fields representing the same concept.
3. **Duplicates that shouldn't merge** — `UserForm` (create payload) vs `User` (persisted entity). They may share fields but represent different lifecycle stages. Do not merge.

## The Merge Decision

A type is a candidate for consolidation when:
- The fields represent the same real-world entity at the same lifecycle stage
- Merging would not force one caller to carry unused fields it doesn't need
- The name accurately describes the merged shape

A type should **stay separate** when:
- It represents a different lifecycle/boundary (request vs. stored vs. response)
- It carries different invariants (validated input vs. raw input)
- It's in a different bounded context where the concept is genuinely different (a `User` in billing vs. `User` in auth)

Write down the lifecycle/bounded-context reasoning when you decide to merge — this protects against future confusion.

## Actions

1. **Choose a canonical location** — typically `types/`, `shared/types/`, or `<domain>/types.ts`. Prefer the module closest to where the type originated if it belongs to a single domain.
2. **Rewrite all references** to import from the canonical location. Remove the duplicate declarations in the same commit.
3. **Verify with the typechecker** after each consolidation. If types drift causes cascading errors, narrow the merge rather than forcing it.
4. **Prefer type composition over flag soup**. If merging two types would require a `kind: 'create' | 'update'` discriminator and two optional-field branches, keep them separate and maybe extract a shared base type instead.

## Output Report

`/.slop-cleanup/wave-2/type-consolidator.md`:

```markdown
# Type Consolidation Report

## Merged
| Canonical type | Location | Replaced | Reason |
|----------------|----------|----------|--------|
| User | src/shared/types/user.ts | UserDTO (3 files), UserProfile (2 files) | Same entity, same lifecycle |

## Kept Separate (with rationale)
| Types | Why separate |
|-------|--------------|
| UserForm vs User | Create payload vs persisted — different invariants |

## Extracted base types
| Base | Specialized into |
|------|------------------|
| UserCore | UserForm, User, UserResponse |

## Commits
- `refactor(types): consolidate duplicate User type declarations`
- `refactor(types): extract UserCore base for lifecycle specializations`
```

## What to return

A one-paragraph summary: how many types consolidated, how many deliberately left separate (and the reason shape), whether typecheck still passes.

MIT license, from luongnv89/skills at commit 5406e888c002.

Security

Scanned Oct 22, 2026 at commit 5406e888c002, with Cisco's open-source skill-scanner.

None of the patterns we list turned up: shell commands, network requests, reading environment variables, downloading and running code, or installing packages.

A scan lists patterns in the code. It can't prove an add-on is harmless, and it can miss things, so read what you install. How we scan

Alternatives

Other makers' add-ons that do the same job, next to this one.

NameScoreStarsContextUpdated
This onetype-consolidator luongnv89/skills · Subagent 57★ 133≈28 in chat16d ago
path-types openinterpreter/openinterpreter · Skill Both about type 89★ 69k≈41 always25d ago
typescript-type-reviewer OpenSource03/harnss · Subagent Both about type and duplicate 66★ 386≈156 in chat20d ago
fix-linting-types-on-pr storybookjs/storybook · Skill Both about type 91★ 91k≈47 always16d ago
layered-architecture-types ardanlabs/service · Skill Both about type 74★ 4.1k≈61 always1mo ago
narrow-react-prop-types humanlayer/skills · Skill Both about type 76★ 5.4k≈21 always27d ago