Code review skill that checks TypeScript type safety, exported for use by cross-cutting review plugin
Detects TypeScript type safety violations including `any` abuse, unsafe type assertions, missing runtime validation, and security issues. Used during code review to enforce compile-time safety and prevent runtime errors.
/plugin marketplace add djankies/claude-configs/plugin install typescript@claude-configsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Purpose: Comprehensive type safety review for TypeScript code, detecting violations that compromise compile-time safety and runtime reliability.
When to use: During code review process, invoked by review plugin to validate TypeScript type safety across the codebase.
Exported for: Cross-cutting review plugin that orchestrates multi-concern reviews.
When reviewing TypeScript code, systematically check for these type safety violations:
any Type AbuseCheck for:
any: <T = any>any: function process(data: any)any: ): any {any: any[], Record<string, any>any: as anyCorrect alternatives:
unknown with type guards instead of anySeverity: HIGH - Defeats TypeScript's purpose entirely
Check for:
JSON.parse(response) as Tvalue as SpecificTypevalue as unknown as TAcceptable assertions:
as const for literal typesas unknown as T only AFTER runtime validationSeverity: HIGH - Bypasses type safety, causes runtime errors
Check for:
catch (error) { error.message }in operatorRequired patterns:
error instanceof ErrornoUncheckedIndexedAccess'key' in obj before accessnever typeSeverity: MEDIUM - Leads to runtime errors in edge cases
Check for:
Required:
Severity: HIGH - Security and reliability issue
Check for:
substr() - use slice() insteadescape() - use encodeURIComponent() insteadunescape() - use decodeURIComponent() insteadSeverity: LOW - Future compatibility issue
Check for:
Required:
Severity: CRITICAL - Production security breach risk
Check for:
<T> when <T extends SomeType> is appropriateanyCorrect patterns:
<T extends { id: string }><T extends U>Severity: MEDIUM - Reduces type safety guarantees
Check for:
strict: false in tsconfig.jsonnoUncheckedIndexedAccess: trueskipLibCheck: false (performance issue)Required settings:
strict: true (enables all strict checks)noUncheckedIndexedAccess: true (prevents array out-of-bounds)skipLibCheck: true (improves build performance)moduleResolution: "NodeNext" for Node.js projectsSeverity: MEDIUM - Affects entire project safety
Automated Checks
tsc --noEmitany usage: grep -r ": any" src/grep -r " as " src/Manual Review
Report Findings
any Type on API Responseasync function fetchUser(id: string): Promise<any> {
const response = await fetch(`/api/users/${id}`);
return response.json();
}
Fix:
import { z } from 'zod';
const UserSchema = z.object({
id: z.string(),
name: z.string(),
email: z.string().email(),
});
type User = z.infer<typeof UserSchema>;
async function fetchUser(id: string): Promise<User> {
const response = await fetch(`/api/users/${id}`);
const data = await response.json();
return UserSchema.parse(data);
}
function parseConfig(json: string) {
return JSON.parse(json) as Config;
}
Fix:
import { z } from 'zod';
const ConfigSchema = z.object({
apiKey: z.string(),
timeout: z.number(),
});
type Config = z.infer<typeof ConfigSchema>;
function parseConfig(json: string): Config {
const data = JSON.parse(json);
return ConfigSchema.parse(data);
}
try {
await riskyOperation();
} catch (error) {
console.error(error.message);
}
Fix:
try {
await riskyOperation();
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
} else {
console.error('Unknown error:', error);
}
}
This skill is exported with review: true frontmatter, making it discoverable by the cross-cutting review plugin.
Review plugin should:
.ts, .tsx)Cross-plugin references:
This review skill addresses all 23 violations found in the TypeScript stress test:
any abuse (5/6 agents)Target: 90% reduction in type safety violations when used during code review.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.