enforcing-type-safety/SKILL.md
Enforces type safety in TypeScript/Python implementations. Any/any types strictly prohibited. Use when processing API responses, integrating external libraries, or implementing data validation. Supports strict mode configuration and type guard implementation.
npx skillsauth add juanjosegongi/skills enforcing-type-safetyInstall 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.
This skill consists of the following files:
❌ Absolutely Forbidden:
- Use of the 'any' type
- The 'Function' type (equivalent to any)
- Overuse of non-null assertions (!)
✅ Alternatives:
- Explicit type definitions (interface/type)
- 'unknown' + Type Guards
- Generics
- Utility Types
❌ Absolutely Forbidden:
- Use of the 'Any' type
- bare except
- eval/exec
✅ Alternatives:
- Explicit Type Hints
- TypedDict
- Protocol (Structural Subtyping)
- Union types
Explicitly define types for all functions and variables.
TypeScript:
function getUserById(id: string): User | null {
// Implementation
}
Python:
def get_user_by_id(user_id: str) -> Optional[User]:
# Implementation
pass
Handle 'unknown' types or ambiguous types safely using type guards.
TypeScript:
function isUser(data: unknown): data is User {
return typeof data === 'object' &&
data !== null &&
'id' in data &&
'name' in data
}
if (isUser(data)) {
console.log(data.name) // Type-safe
}
Python:
from typing import TypeGuard
def is_user(data: object) -> TypeGuard[User]:
return isinstance(data, dict) and \
'id' in data and 'name' in data
if is_user(data):
print(data['name']) // Type-safe
TypeScript: Enable strict mode
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true
}
}
Python: Run mypy/pyright
mypy src/
pyright src/
| Situation | Bad Example | Good Example |
|------|--------|--------|
| API Response | response: any | response: ApiResponse |
| Unknown Type | data: any | data: unknown + Type Guard |
| Multiple Types | value: any | value: string \| number |
| Optional | user!.name | user?.name ?? 'Unknown' |
| Array Operation | items: any[] | items: User[] |
src/
├── types/
│ ├── api.ts # API type definitions
│ ├── models.ts # Data model types
│ └── utils.ts # Utility types
├── guards/
│ └── type-guards.ts # Type guard functions
└── ...
Code type safety is evaluated at the following levels:
Before writing new code:
Check Type Definition Files
Types for External Libraries
Scope of Shared Types
Refer to each file for details.
development
Guides Dockerfile creation and optimization. Use when Dockerfile or Docker Compose is detected. Supports multi-stage builds, cache optimization, security hardening, and image size minimization.
development
Provides comprehensive testing and TDD guidance. Use for writing tests before implementing new features (TDD, test-driven development, red-green-refactor), creating reproduction tests for bug fixes, running regression tests during refactoring, and checking test coverage during code reviews. Enforces AAA pattern, test-first workflow, and 100% business logic coverage goal. Also covers testing anti-patterns, mock discipline, and testable design.
data-ai
A completely different skill for database operations. Use when working with PostgreSQL queries, schema design, or database migrations.
testing
Another sample skill for testing. Use when the user wants to create widgets with advanced features or mentions beta testing.