Skip to content
Skillpedia
General coding7.8k Β· #13086

typescript-typecheck-fallback

What it does

This skill describes a two-step way to check TypeScript code, with a backup if the first try fails. It is for developers who check TypeScript as part of a build or review.

When to use it

  • βœ“When you have changed TypeScript files and want to confirm there are no type errors.
  • βœ“When a type check command times out or returns an unclear error.
  • βœ“When you want a check that runs as part of a review before you finish.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-typecheck-fallback/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/typescript-typecheck-fallback/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œCan you run a type check on my TypeScript files and tell me about any errors?”

5 new skills a week. 1 minute to read.

How it works

The agent first tries the quick check. If that fails in an unclear way, it hands the check to a backup helper that can work around the problem.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

TypeScript Type-Check with shell_agent Fallback

When verifying TypeScript compilation as part of a build or validation workflow, run_shell may fail with unknown errors due to shell environment issues, missing PATH entries, timeout constraints, or other transient problems. This skill describes a two-step pattern: attempt the check with run_shell first, then fall back to shell_agent if it fails.


When to Use

  • After creating or modifying TypeScript source files and you need to confirm there are no type errors.
  • As part of a CI-like verification step inside an autonomous workflow.
  • Any time run_shell returns an unexpected or unclear error for a tsc invocation.

Step-by-Step Pattern

Step 1 β€” Attempt with run_shell (fast path)

Try the direct command first. This is fast and gives immediate output when the environment is well-configured.

run_shell: npx tsc --noEmit

Evaluate the result:

  • βœ… Exit code 0, no errors β†’ Type-check passed. Done.
  • ❌ Exit code non-zero with TypeScript diagnostics β†’ Real type errors exist; surface them and fix.
  • ⚠️ Unknown error, timeout, or no useful output β†’ Proceed to Step 2.

Step 2 β€” Fall back to shell_agent (reliable path)

When run_shell fails in an ambiguous or environmental way, delegate to shell_agent with a natural-language task. shell_agent can autonomously:

  • Locate the correct npx/tsc binary
  • Retry on transient failures
  • Navigate PATH or permission issues
  • Return a structured summary of any type errors

Task string to pass to shell_agent:

Run `npx tsc --noEmit` in the project root and report all TypeScript type errors found. If there are no errors, confirm the compilation succeeded. If tsc is not available, attempt to install TypeScript locally with `npm install --save-dev typescript` first.

Evaluate the result:

  • βœ… "No errors found" / exit 0 β†’ Type-check passed.
  • ❌ Type errors listed β†’ Collect and fix the reported diagnostics, then re-run.
  • ⚠️ tsconfig.json missing β†’ Ensure the file exists in the project root before re-running.

Decision Flowchart

run_shell("npx tsc --noEmit")
        β”‚
        β”œβ”€ success (exit 0) ──────────────────► βœ… PASS
        β”‚
        β”œβ”€ type errors reported ──────────────► ❌ Fix errors, retry
        β”‚
        └─ unknown/env error ─────────────────► shell_agent(natural-language task)
                                                        β”‚
                                                        β”œβ”€ success ───► βœ… PASS
                                                        └─ errors  ───► ❌ Fix & retry

Example Implementation

# Pseudo-code for an autonomous agent loop

result = run_shell("npx tsc --noEmit", timeout=60)

if result.exit_code == 0:
    print("TypeScript check passed.")

elif result.exit_code != 0 and result.stderr contains "TS\d+":
    # Real TypeScript diagnostics β€” surface and fix them
    raise TypeScriptError(result.stderr)

else:
    # Ambiguous failure β€” delegate to shell_agent
    shell_agent(
        task="Run `npx tsc --noEmit` in the project root and report all TypeScript "
             "type errors found. If there are no errors, confirm compilation succeeded. "
             "If tsc is not available, install it first with `npm install --save-dev typescript`."
    )

Tips

  • Always have a tsconfig.json: tsc --noEmit requires a valid config. If none exists, generate one first with npx tsc --init.
  • Set a reasonable timeout: TypeScript compilation on large projects can take 30–120 seconds. Give run_shell at least timeout=90.
  • Scope to changed files when possible: Use --project tsconfig.json or a path glob to limit what tsc checks if only a subset of files changed.
  • Prefer shell_agent for first-time setups: If the project environment is freshly created and dependencies may not be fully installed, start with shell_agent directly to avoid a predictable run_shell failure.

Generalizing Beyond TypeScript

This same fallback pattern applies to any build/lint/type-check command that may be sensitive to shell environment:

Tool Primary run_shell command shell_agent fallback task
TypeScript npx tsc --noEmit "Run npx tsc --noEmit and report errors"
ESLint npx eslint src/ "Run npx eslint on the src directory and report lint errors"
Python mypy python -m mypy src/ "Run mypy on the sr
FAQ

What if the quick check works?

Then the agent is done, and any errors it reports are real issues to fix.

Can the backup change my code?

The check itself only reports errors. Fixes are a separate step.

Why is there a backup?

Some environments have timeouts or path problems that stop the quick check from running.

Details

Original description by the author

Reliably run TypeScript type-checking (npx tsc --noEmit) by using shell_agent as a fallback when run_shell fails due to environment or timeout issues.

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#13086
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills