- 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.
Requires a working TypeScript environment to run compiler checks. Fixes for third-party library type mismatches may require manual intervention for local declarations or patches.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
1 use
Times used to date
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 29 days ago
- Free with an Agensi account