- Home
- Skills
- Code Quality & Review
- Typelock: type safety that stays switched on
More screenshots
Works with the AI Agents you already use
Typelock: type safety that stays switched on
Replaces `as any` with type guards, schema parses, satisfies and unknown. Audits a folder for unsafe casts and fixes them in order of risk until tsc passes.
Free
Typelock: type safety that stays switched on
Example session with this skill installed
Audit the src/api folder for unsafe types and fix the high risk findings.
- Read your context and instructions
- Compiled the typelock
I have audited the src/api folder for type-safety violations. I found 3 high-risk findings related to boundary data and 1 medium-risk finding in a utility function.
TypeScript Audit Results
| Risk | Location | Finding | Recommended Fix |
|---|---|---|---|
| High | src/api/client.ts:22 | res.json() as any | Use UserSchema.parse() |
| High | src/api/config.ts:5 | process.env.API_URL! | Add explicit null check and throw |
| High | src/api/transform.ts:12 | data: any parameter | Change to unknown and narrow |
| Medium | src/api/utils.ts:45 | // @ts-ignore | Replace with @ts-expect-error |
I have applied fixes for the high-risk items. The any cast in the client has been replaced with a Zod schema parse, and the environment variable access now includes a runtime validation check.
// src/api/client.ts refactored
import { UserSchema } from "./schemas";
export async function fetchUser(id: string) {
const response = await fetch(`/api/users/${id}`);
const json = await response.json();
// Fixed: Replaced 'as any' with schema validation
return UserSchema.parse(json);
}
// src/api/config.ts refactored
const rawUrl = process.env.API_URL;
if (!rawUrl) {
throw new Error("Missing required environment variable: API_URL");
}
export const API_URL = rawUrl;
Next steps
- Review the generated Zod schema in
src/api/schemas.tsto ensure it matches the latest API spec. - Run
npm run typecheckto verify the medium-risk fixes don't conflict with global types. - Decide if
noUncheckedIndexedAccessshould be enabled intsconfig.json.
Connects securely to your tools. The creator never sees your data.
About this skill
A single as any cast can silence errors across an entire call chain, hiding bugs that only appear at runtime. This skill enforces TypeScript type safety by replacing unsafe casts and non-null assertions with verifiable compiler checks.
What it does
- Eliminates
anycasts by swapping them for type guards,satisfiesoperators, or exhaustiveneverchecks. - Validates data boundaries using the project's existing schema libraries like Zod or Valibot to parse external inputs.
- Audits codebases to find and rank type-safety risks in files or folders, prioritizing API boundaries and shared utilities.
- Refactors unsafe patterns such as non-null assertions and
@ts-ignorecomments into safer alternatives like narrowing or@ts-expect-error. - Recommends strict configurations one flag at a time, such as like
noUncheckedIndexedAccessandexactOptionalPropertyTypes.
How it works
- Context discovery: The skill analyzes the project's stack,
package.json, andtsconfig.jsonto identify existing validation libraries and strictness levels. - Audit execution: Run
audit <path>to generate a prioritized list of type-safety violations ranked by risk level. - Refactor and verify: The skill applies fixes in batches, running
tsc --noEmitafter each change to ensure no new errors are introduced.
Frameworks & tools
Works with any TypeScript project. It integrates with validation libraries like Zod and Valibot, and utilizes standard TypeScript features like satisfies, unknown, and type predicates.
Why this beats prompting it yourself
Generic prompts often replace as any with as unknown as T, which just moves the problem. This skill follows a specific hierarchy of safety, forcing runtime validation at boundaries and narrowing within local logic to ensure types actually match reality.
Use cases
- Refactoring a legacy TypeScript codebase to enable strict mode.
- Sanitizing API responses and environment variables to prevent runtime crashes.
- Removing non-null assertions from complex logic chains to handle edge cases safely.
- Implementing exhaustive switch-case checks to prevent bugs when adding new union members.
Known limitations
Does not add new heavy dependencies for validation. Casts that are truly unavoidable in third-party glue code are wrapped rather than fully eliminated.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 1 day ago
- Free to download with an account