Skip to content
Agent loop · Code quality

Strict Types Until Zero

Tighten type checking one directory at a time, fix the new type errors with real types instead of any or ignore comments, and repeat until the checker passes.

Up to 10 iterationsStop rules and safety limits
The prompt

Copy the Strict Types Until Zero loop

Stops when the type checker passes with strict settings across the whole scope, or after 10 iterations. Edit the settings block, then paste the whole prompt into your agent.

strict-types-until-zero.prompt.md
You are running the "Strict Types Until Zero" loop.

Settings (edit before running):
- Strict check command: npx tsc --noEmit --strict
- Test command: npm test
- Scope: src/
- Max iterations (directories): 10

Goal: zero type errors under strict settings for the scope above.

Before the loop: run the strict check and group errors by directory. Order directories so leaf modules (few importers) come first.

Each iteration:
1. Take the next directory from the list.
2. Fix its type errors with accurate types: explicit parameter and return types, type guards and narrowing, null and undefined checks, and generics where they remove duplication.
3. Run the strict check for the whole scope to make sure fixes did not create errors elsewhere.
4. Run the test command.
5. Log: directory, errors fixed, errors remaining overall.

Stop when:
- The strict check reports zero errors. Success. Propose the config change that turns strict mode on permanently.
- You reach the max iteration count.

Rules:
- Do not use "any", "as unknown as", non-null assertions (!), ts-ignore, or ts-expect-error to silence errors. If one is truly unavoidable, leave a comment explaining why and list it in the report.
- When a type error reveals a real bug (for example a possible null), fix the bug and call it out.
- Do not change runtime behavior except to fix those bugs.

Final report: error counts before and after, real bugs found, and any remaining escape hatches with reasons.
When to use it

When this loop fits

  • You want to switch a TypeScript project to strict mode, or a Python project to strict mypy or Pyright.
  • A codebase is full of implicit any or untyped functions that keep hiding bugs.
  • You want the migration split into small, reviewable directory-sized steps.
How it works

What happens on each pass

The agent repeats these steps until the stop condition holds or it runs out of iterations.

  1. Baseline. Run the type checker with strict settings and count errors per directory.
  2. Pick a directory. Start with the directory that has the fewest dependents, such as utilities or leaf modules.
  3. Add real types. Fix each error with accurate types, narrowing, or null checks.
  4. Check and test. Run the type checker and tests, then move to the next directory.
Recommended servers

MCP servers for this loop

The 6 strongest of 800 matching servers, ranked by how closely they fit and then by trust score.

More in Developer tools
  • Trust score 50 of 100, Fair

    agentcat

    by agentcathq · TypeScript

    Analytics tool for MCP (Model Context Protocol) servers and AI agents - tracks tool usage patterns and provides insights

    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 27 days ago.
    124 stars1.5K/wk weekly downloads— tools
  • Trust score 50 of 100, Fair

    An MCP server for weather information updating this value now.

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: C. 55/100 for listing completeness. Lost points: short README, no listed tools, short summary.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Priority — TypeScript Compiler Intelligence logo
    Trust score 47 of 100, Fair

    Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.

    RegistryRemote
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Trust score 40 of 100, Fair

    AI-powered meeting scheduling with intelligent auto-scheduling for Claude and AI agents.

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Trust score 40 of 100, Fair

    AST for TypeScript, supports creating JSON representations of React components

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Trust score 40 of 100, Fair

    MCP server that exposes Pyright language server functionality

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
Run it

How to run this loop

  1. Connect the tools. Install a server the loop can use, for example agentcat, or rely on your agent's built-in terminal and file access.
  2. Edit the settings block. Replace the example commands, targets, and limits with your project's own. Keep the iteration cap low on the first run.
  3. Paste it into an agent session. Start a fresh session in Claude Code, Cursor, or VS Code agent mode, in the repository root, and paste the prompt.
  4. Review before you merge. Read the final report and the diff. The loop leaves its work for you to review rather than shipping it.
FAQ

Strict Types Until Zero questions

When does the Strict Types Until Zero loop stop?

It stops as soon as the type checker passes with strict settings across the whole scope. It also stops after 10 iterations by default, or earlier when the prompt's own stop rules say it is stuck, and then reports what changed and what is left. Change the cap in the settings block at the top of the prompt.

Can I use this loop for Python type checking?

Yes. Use mypy --strict or pyright in strict mode as the check command and the loop works the same way. The banned escape hatches become Any, cast, and type: ignore comments.

Will strict typing find real bugs?

Usually, yes. Strict null checks in particular surface code paths where a value can be missing and nothing handles it. The prompt asks the agent to fix and report those separately, so they do not get lost inside a large typing diff.

Keep exploring
All loops