20 of the best prompts for enforcing TypeScript strict mode, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
20 of the best prompts for enforcing TypeScript strict mode, step by step across 4 stages. Works with ChatGPT, Claude, and Gemini.
Published June 28, 2026
Most people try to use AI for Enforcing TypeScript Strict Mode with a single vague prompt and get generic results. This guide takes a different approach: 4 targeted stages, from Diagnose the Wall through Prevent Recurrence, each with a prompt that gives the AI exactly the context it needs. Windsurf sometimes bypasses TypeScript type safety by using any types, incorrect assertions, or ts-ignore comments. This can lead to runtime errors and unexpected behavior in applications. These prompts help developers ensure that Windsurf adheres to strict TypeScript rules, maintaining code integrity and reliability. Works with ChatGPT, Claude, and Gemini.
Identify where Windsurf is bypassing TypeScript strict mode.
Identify Any Type Usage
Scan the project for instances of the 'any' type usage in TypeScript files. Generate a comprehensive list that includes the names of the files and the specific line numbers where the 'any' type is found. Additionally, explain why using 'any' can be problematic in TypeScript and suggest alternatives for better type safety. Format the output as a structured report for easy reference.
Find Incorrect Assertions
Identify all incorrect type assertions in the codebase related to windsurf-violating-typescript-strict-mode. Provide a detailed list that includes the specific file paths and line numbers for each occurrence. For each incorrect assertion, explain why it is considered incorrect and suggest the appropriate type that should be used instead. Format the output as a structured report for easy reference.
Locate ts-ignore Comments
Search through the project code to locate all instances of 'ts-ignore' comments. For each instance, provide the exact line number and file name where the comment is found. Additionally, explain the reason for each 'ts-ignore' usage, detailing the specific TypeScript error or warning it is suppressing, and include any relevant context that clarifies why the comment was necessary.
Review TypeScript Config
Review the following tsconfig.json file: [PASTE CONTENT]. Confirm whether strict mode is enabled and identify any settings that could allow type safety violations. Provide a detailed analysis of each relevant setting, explaining its implications for type safety in the project. Based on your findings, suggest specific changes to enhance type safety and justify each recommendation.
Analyze Cascade Changes
Analyze the changes made by Cascade mode in the project and identify any files that were modified where type safety might have been compromised. For each file, summarize the specific changes made, including the lines affected and the nature of the modifications. Additionally, explain how these changes could potentially impact type safety and suggest necessary adjustments to ensure compliance with TypeScript's strict mode.
Address each identified violation of TypeScript strict mode.
Replace Any with Specific Types
Identify each instance of the 'any' type in the provided TypeScript code: [CODE SNIPPET]. For each occurrence, suggest a more specific type that maintains the original functionality while enhancing type safety. Explain the reasoning behind your choice of type, how it improves the code, and provide examples of how the new type can be used in the context of the existing code.
Correct Type Assertions
Review the following type assertions in my TypeScript code: [CODE SNIPPET]. Identify any incorrect assertions and provide a corrected version for each one that aligns with the actual data structure. For each correction, explain why the original assertion was incorrect and how the corrected version better reflects the data type. Ensure your response is clear and structured, addressing at least three examples.
Remove Unnecessary ts-ignore
Identify all instances of ts-ignore comments in the codebase. For each instance, analyze the underlying type issue that necessitated the ts-ignore and provide detailed code changes that address these type issues. Ensure that the code adheres to TypeScript's strict mode requirements, and include explanations for each change made. Highlight how each change resolves the specific type issue and improves type safety. Format your response to clearly separate each ts-ignore instance along with its corresponding fix, making it easy to follow the adjustments made.
Update TypeScript Config
Revise the tsconfig.json file to enforce stricter type checks in your TypeScript project. Include specific options to add or modify, such as enabling STRICT_NULL_CHECKS and NO_IMPLICIT_ANY, along with any other relevant compiler options. For each change, explain its purpose and how it contributes to improved type safety. Additionally, identify potential issues that may arise from these changes and provide strategies to address them, ensuring that existing functionality remains intact.
Revert Unsafe Cascade Edits
Identify instances in the code where Cascade mode changes have bypassed type safety. Provide a detailed explanation of why these changes are unsafe, and for each instance, revert the changes while supplying the corrected code. Ensure that the revised code adheres to TypeScript's strict mode requirements, and explain any modifications made to maintain type safety. Format the output with clear comments indicating the original unsafe code and the rationale for the corrections.
Ensure all fixes adhere to TypeScript strict mode.
Run TypeScript Compiler
Compile the project using the TypeScript compiler and provide a detailed report of any remaining type errors found. For each error, include the error message, the file name, and the line number where the error occurs, and suggest possible solutions or fixes to effectively resolve each type error.
Check for Any Types
Re-scan the codebase for instances of 'any' types and provide a detailed report. Identify each occurrence by specifying the file name and line number, and for each instance, explain its necessity or suggest a more specific type that could be used instead. Additionally, summarize the overall impact of 'any' types on type safety within the codebase, highlighting potential risks and areas for improvement.
Validate Type Assertions
Validate all type assertions in the provided TypeScript code: [CODE SNIPPET]. Identify any assertions that are incorrect or unnecessary, and explain why each is problematic. For each issue found, provide a detailed report that includes the line number, the specific assertion, and recommendations for how to correct or remove it. Additionally, summarize the overall state of type assertions in the codebase, highlighting any patterns or common issues you observe.
Confirm ts-ignore Removal
Review the codebase for the windsurf-violating-typescript-strict-mode use case and confirm that all unnecessary ts-ignore comments have been removed. Verify that the code compiles successfully without any errors or warnings, and provide a summary of any remaining issues. Additionally, suggest further improvements to enhance code quality and maintainability.
Audit Cascade Changes
Conduct an audit of all Cascade mode changes to ensure compliance with TypeScript strict mode. Summarize your findings by highlighting areas of non-compliance, potential issues, and recommendations for adjustments. Include specific examples of changes that either meet or violate strict mode requirements, and provide an overall assessment of the compliance status. Format the summary clearly and use bullet points for easy readability.
Create safeguards to maintain TypeScript strict mode adherence.
Draft CLAUDE.md Rule
Draft a new rule for CLAUDE.md that addresses the prevention of bypassing TypeScript strict mode in future code edits. Include a clear explanation of why maintaining strict mode is crucial for type safety and code quality. Identify common issues encountered due to bypassing this mode, and provide specific examples of how these issues can be avoided in practice. Structure the rule for clarity and ease of implementation, and suggest best practices for developers to follow to ensure compliance with this rule.
Add Type Safety Comments
Add detailed comments throughout the codebase to explain the importance of type safety in TypeScript. Specifically, highlight the risks associated with using 'any' types, including potential runtime errors, loss of code clarity, and difficulties in maintaining the code. Ensure each comment is placed near relevant code sections and provides clear examples of how type safety improves code reliability and maintainability. Aim for a comprehensive overview that can serve as a guide for developers working on this codebase, covering at least five key areas where type safety is beneficial.
Create Session-Opener Checklist
Create a comprehensive checklist for opening new coding sessions that ensures all necessary configurations are in place. Include specific steps to verify that TypeScript strict mode is enabled, confirm that the correct project dependencies are installed, ensure the code editor is set up with the appropriate extensions, and review any relevant documentation or notes from previous sessions. Structure the checklist in a clear, step-by-step format to allow for easy tracking of each item as it is completed.
Establish Naming Conventions
Establish effective naming conventions for a TypeScript project that enhance the visibility of type safety violations during code reviews. Focus on aspects such as variable names, function names, and class names. Provide specific examples of naming patterns that indicate potential type issues, and explain how these conventions assist developers in quickly identifying and addressing violations. Additionally, suggest guidelines for documenting these conventions within the project to ensure consistency among team members.
Implement Project Guard
Propose a project guard mechanism for a TypeScript project that automatically identifies and flags type safety violations during code commits. Describe in detail how this guard will be integrated into the existing workflow, including the specific tools or libraries to be utilized. Outline the steps required for setup and explain how the mechanism will notify developers of violations, along with suggested corrective actions, to ensure strict type safety is maintained throughout the development lifecycle.
Windsurf may use 'any' types to quickly resolve type conflicts, but this can bypass TypeScript's strict type checks. It's important to replace 'any' with specific types to maintain type safety.
You can adjust your CLAUDE.md rules to explicitly forbid ts-ignore comments, prompting Windsurf to find alternative solutions that adhere to type safety.
Review the changes made by Cascade mode and revert any that violate TypeScript strict mode. Use the prompts to ensure future changes comply with type safety.
Yes, by setting strict rules in your CLAUDE.md file and ensuring your tsconfig.json enforces strict type checks, you can guide Windsurf to prioritize type safety.
Use the TypeScript compiler to check for type errors and ensure your tsconfig.json is set to enforce strict mode. Regular audits can help maintain adherence.
AI Prompts for Identify Type Safety Violations
By bypassing TypeScript type safety, the AI may introduce runtime errors that are difficult to debug.
See promptsAI Prompts for Enforcing TypeScript Type Safety
Cursor bypassing TypeScript type safety leads to runtime errors and unstable code.
See promptsAI Prompts for Enforcing TypeScript Strict Mode
Claude Code bypasses TypeScript type safety by using any types, incorrect assertions, or ts-ignore comments, leading to potential runtime errors.
See prompts