ts-perf

A TypeScript performance checker for finding what makes type-checking and builds slow. It measures compiler timings, file counts, memory use, and type-checking activity, then examines compiler trace files and project settings.

In plain words
What is it for?
Use it to measure a baseline, inspect TypeScript trace files, find expensive type operations, and review tsconfig.json for build-speed changes.
Why use it?
It helps locate the specific files, types, or compiler work causing long waits, instead of relying on guesswork.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/andronics/claude-plugin-typescript-pro/ts-perf
Clone the repo
git clone --depth 1 https://github.com/andronics/claude-plugin-typescript-pro
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,792 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00012 $0.01792
Opus 5 $0.00006 $0.00896
Sonnet 5 $0.00002 $0.00358
Haiku 4.5 $0.00001 $0.00179

Measured 2d ago against content hash 807ff8bad543, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ts-perf scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/ts-perf.md · 282 lines

How it starts

The opening of the file, as written. The whole thing — 282 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Analyze TypeScript performance and provide optimization recommendations:

  1. Performance Measurement

    Type-Checking Performance:

    # Measure baseline
    time npx tsc --noEmit
    
    # Extended diagnostics
    npx tsc --extendedDiagnostics
    
    # Generate trace for analysis
    npx tsc --generateTrace trace-$(date +%s)
    

    Capture metrics:

    • Total type-checking time
    • Files processed count
    • Types instantiated count
    • I/O time vs computation time
    • Memory usage
  2. Analyze Trace File

    • Generate trace: npx tsc --generateTrace trace
    • Parse trace/*.json files
    • Identify slowest operations:
      • Slow type checks (which types are expensive)
      • Slow files (which files take longest)
      • Type instantiations (which types are instantiated most)
      • Type checking hotspots

    Provide instructions:

    Upload trace to https://ui.perfetto.dev/ for visual analysis
    Look for:
    - Red bars (expensive operations)
    - Long chains (deep type recursion)
    - Repeated patterns (type caching opportunities)
    
  3. Configuration Analysis

    Review tsconfig.json for Performance:

    Check and suggest optimizations:

    {
      "compilerOptions": {
        // ✅ Enable for faster builds
        "skipLibCheck": true,          // Skip .d.ts files
        "incremental": true,           // Cache previous builds
        "composite": true,             // For project references
    
        // ⚠️ Disable if not needed
        "declaration": false,          // Only for libraries
        "declarationMap": false,       // Only if debugging types
        "sourceMap": false,            // Only for debugging
    
        // ✅ Optimize module resolution
        "moduleResolution": "bundler", // Faster than "node"
    
        // ✅ Exclude unnecessary files
        "exclude": [
          "node_modules",
          "dist",
          "**/*.test.ts"
        ]
      }
    }
    
  4. Identify Performance Bottlenecks

    Overly Complex Types:

    // 🔴 Slow: Deep recursion
    type DeepPartial<T> = {
      [P in keyof T]?: T[P] extends object
        ? DeepPartial<T[P]>
        : T[P];
    };
    
    // 🟢 Faster: Limit recursion depth
    type DeepPartial<T, Depth extends number = 3> = Depth extends 0
      ? T
      : {
          [P in keyof T]?: T[P] extends object
            ? DeepPartial<T[P], Prev<Depth>>
            : T[P];
        };
    

    Expensive Template Literals:

    // 🔴 Slow: Generates huge unions
    type AllPaths = `${string}/${string}/${string}`;
    
    // 🟢 Faster: Specific patterns
    type SpecificPaths =
      | `/users/${number}`
      | `/posts/${number}/comments`;
    

    Large Union Types:

    // 🔴 Slow: 1000+ member union
    type AllNumbers = 0 | 1 | 2 | ... | 999;
    
    // 🟢 Faster: Use branded type
    type NumberInRange = number & { __brand: 'InRange' };
    
  5. Build Tool Performance

    Compare Build Tools:

    • Measure current build time
    • Compare with faster alternatives:
      • tsc: Baseline, slow but complete type checking
      • esbuild: 10-100x faster, no type checking
      • swc: 20-70x faster, limited type support
      • Vite: Fast dev server, esbuild-based

    Recommendation Matrix:

    Library project → tsup (esbuild + type gen)
    Web app → Vite (HMR + fast builds)
    Node service → esbuild + tsc --noEmit
    Monorepo → Project references + Turborepo
    
  6. Monorepo Optimization

    Enable Project References:

    // Root tsconfig.json
    {
      "files": [],
      "references": [
        { "path": "./packages/core" },
        { "path": "./packages/ui" }
      ]
    }
    
    // Package tsconfig.json
    {
      "compilerOptions": {
        "composite": true,
        "incremental": true
      }
    }
    

    Benefits:

    • Parallel type checking
    • Incremental builds
    • Better caching
    • Faster watch mode
  7. File-Level Analysis

    Identify slow files:

    • Files with most type errors
    • Files with complex types
    • Large files (>1000 lines)
    • Files importing many dependencies

Read the full file on GitHub · 282 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 282 lines · 12 tokens per session scan A 807ff8bad543

Subscribe to this mod's changes

ts-perf is a command published in the GitHub repository andronics/claude-plugin-typescript-pro (4 stars, last pushed 10mo ago), licensed MIT. It adds 12 tokens to every session and 1,792 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.