skills/code-quality/cleanup-types/SKILL.md
Find duplicated or fragmented type/interface definitions across files and consolidate to a shared types module. TypeScript-first; also handles Python dataclasses/TypedDicts and Go structs. Use when the user asks to consolidate types, find duplicate interfaces, or organize type definitions.
npx skillsauth add raintree-technology/claude-starter cleanup-typesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Find type definitions that should be shared but are duplicated across files. Consolidate into a single source of truth. Conservative by default — type consolidation looks safe but can hide intentional divergence.
types/, models/, schema/, or a dedicated package (e.g., packages/types/, packages/db/src/schema/ in monorepos).No off-the-shelf tool reliably finds semantically equivalent types across languages. Use AST scanning + grep + structural comparison.
# Find every `interface Foo` and `type Foo =` declaration
# Group by name, then by structural shape
grep -rn --include="*.ts" --include="*.tsx" -E "^export (interface|type) [A-Z]" . > /tmp/ts-types.txt
For each name that appears in 2+ files, compare the shapes. Use tsc --listFiles --noEmit output combined with the TypeScript compiler API if available, OR fall back to textual comparison after normalizing whitespace.
# Find dataclass / TypedDict / Pydantic models
grep -rn --include="*.py" -E "^(class \w+\(.*?(BaseModel|TypedDict)\)|@dataclass)" . > /tmp/py-types.txt
grep -rn --include="*.go" -E "^type \w+ struct" . > /tmp/go-types.txt
grep -rn --include="*.rs" -E "^pub (struct|enum) \w+" . > /tmp/rust-types.txt
Cross-reference: for each type name, check if multiple files define it. For each pair, compare field-by-field.
Write .claude/cleanup-reports/cleanup-types-{YYYY-MM-DD}.md:
# Type Consolidation Assessment — YYYY-MM-DD
## Summary
- Type names with 2+ definitions: N
- HIGH (structurally identical): X
- MEDIUM (overlapping fields, may diverge intentionally): Y
- LOW (same name, different meaning): Z
## Findings
### `User` interface — HIGH
- Definitions:
- `apps/app/features/auth/types.ts:8` — `{ id: string; email: string; createdAt: Date }`
- `apps/admin/features/users/types.ts:12` — `{ id: string; email: string; createdAt: Date }`
- Identical shape. Consolidate to `packages/db/src/schema/user.ts` (already has the runtime model).
### `Account` interface — MEDIUM
- `domains/account/types.ts` — has 8 fields including `permissions: string[]`
- `features/billing/types.ts` — has 5 of those 8 fields, no `permissions`.
- Likely the billing one is a deliberate slice. Recommend: keep both, but rename billing's to `BillingAccount` for clarity. Don't auto-apply.
### `Config` type — LOW (different concepts)
- `lib/api-config.ts` — API client config
- `lib/feature-config.ts` — feature flag config
- Same name, unrelated. Recommendation: rename one for clarity, but no consolidation.
## Critical Assessment
[2-3 paragraphs: are types fragmented because there's no shared package, or because the architecture intentionally separates concerns?]
Auto-consolidate HIGH only. Type consolidation often crosses package boundaries and reshapes import graphs — be conservative.
HIGH (auto-apply):
MEDIUM (report only):
LOW (note only):
import type { Foo } from '...'.chore(cleanup): cleanup-types — consolidated N duplicate type definitions.# Typecheck is the critical signal
npm run typecheck 2>&1 || npx tsc --noEmit
mypy . 2>&1 || true
go build ./... 2>&1
cargo check 2>&1
# Then standard test/lint
npm test && (npx @biomejs/biome check . || npx eslint .)
Type consolidation that breaks downstream usage (e.g., a consumer relied on a field being optional in one definition but required in the other) shows up here. Revert on any new error.
Foo from a public-API package with a Foo from a private app package — that breaks the API contract.*.d.ts ambient declaration files unless the source is also a .d.ts.development
Whop platform expert for digital products, memberships, and community monetization. Covers memberships API, payments, courses, forums, webhooks, OAuth apps, and checkout integration. Build SaaS, course platforms, and gated communities. Triggers on Whop, memberships, digital products, course platform, community monetization, Whop API, license keys.
development
Token-Oriented Object Notation (TOON) format expert for 30-60% token savings on structured data. Auto-applies to arrays with 5+ items, tables, logs, API responses, database results. Supports tabular, inline, and expanded formats with comma/tab/pipe delimiters. Triggers on large JSON, data optimization, token reduction, structured data, arrays, tables, logs, metrics, TOON.
development
Plaid banking API expert for financial data integration. Covers Plaid Link, Auth (account/routing numbers), Transactions, Identity verification, Balance checking, and webhooks. Build fintech apps with bank connections, ACH transfers, and transaction history. Triggers on Plaid, banking API, Plaid Link, bank connection, ACH, financial data, transaction history.
development
Helius Solana RPC and API expert. High-performance infrastructure for Solana including RPC nodes, DAS API for NFTs/tokens, LaserStream real-time streaming, webhooks, Priority Fee API, Enhanced Transactions, and ZK Compression. Triggers on Helius, Solana RPC, DAS API, Digital Asset Standard, NFT metadata, Solana webhooks, priority fees, LaserStream, ZK compression.