Replaces unsafe `any` usage with `unknown`, interfaces, DTOs, type guards, generics, and validated finite value sets to improve TypeScript safety.
Ships in ngautopilot-typescript. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use this skill to remove unsafe any usage and preserve TypeScript's ability to detect mistakes. The goal is to make data contracts explicit without overcomplicating the code.
Use this skill when:
any.any.Use explicit domain types when the shape is known:
interface UserDto {
id: string;
name: string;
enabled: boolean;
}
function mapUser(dto: UserDto): UserViewModel {
return {
id: dto.id,
displayName: dto.name,
isActive: dto.enabled,
};
}
Use unknown for untrusted input, then narrow it:
function isUserDto(value: unknown): value is UserDto {
return (
typeof value === "object" &&
value !== null &&
"id" in value &&
"name" in value &&
"enabled" in value
);
}
Use generics when the function should preserve a caller-provided type:
function firstItem<T>(items: readonly T[]): T | undefined {
return items[0];
}
Use narrow temporary types at integration boundaries:
type UnknownRecord = Record<string, unknown>;
Prefer a literal union when only a type is needed. Use an as const object for named runtime constants or an as const array when iteration or validation needs the values, deriving the union from that same source. Check the detected compiler: const assertions require TypeScript 3.4+.
Read finite values and enum compatibility when choosing between these forms, writing a membership guard, or replacing an existing enum. Ordinary enums emit JavaScript; objects and arrays also remain at runtime. Only the type declarations are erased.
Avoid using any as a shortcut:
function mapUser(dto: any): any {
return {
id: dto.id,
displayName: dto.name,
};
}
Avoid unsafe assertions that skip validation:
const user = response as UserDto;
Avoid replacing any with broad types that still hide the contract:
const payload: object = response;
Use temporary any only when there is a clear boundary, migration reason, and follow-up path. Keep it local, documented by naming or surrounding context, and do not leak it through public APIs.
Do not replace enums required by public APIs, generated clients, third-party libraries, reverse mappings, or stored values without an explicit compatibility plan. Avoid implicit numeric enum values in new serialized contracts; reordering can change their meaning. Do not introduce const enum as a blanket workaround: emission depends on compiler settings, and published ambient const enums have consumer compatibility risks.
any.unknown until validated or mapped.any.any usage is isolated and does not spread through the codebase.any usage and identify the data boundary.any with the narrowest practical type.unknown plus narrowing for untrusted input.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/ngautopilot-typescript:typescript--strict-types--avoid-anyfrom ngautopilot-typescript
npx claudepluginhub janpereira-dev/ngautopilot --plugin ngautopilot-typescript6 skills in this plugin
/typescript--dto-mappers--browser-dto-mappers-v14Browser DTO Mappers v14+Reviews DTO mapping in browser-oriented TypeScript code, focusing on mapping contracts, view models, serialization boundaries, and safe transformations near UI code.
/typescript--dto-mappers--node-dto-mappers-v18Node DTO Mappers v18+Reviews DTO mapping in Node.js TypeScript code, focusing on transport contracts, normalization, validation boundaries, and safe mapping in backend services and scripts.
/typescript--fundamentals