agentleFS
web-infra-devweb-infra-dev/rstest/.agents/skills/typescript/SKILL.md

typescript

Skill514 starsChanged 9 days agoMITView on GitHub

TypeScript anti-slop guardrails. Use when writing or reviewing .ts, .tsx, and .mts files. Covers patterns that Biome, tsc, and rslint do not catch.

66 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use msw, rust and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • thongdn-itSkill

    msw

    MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.

    Also in 3 projects that use this

  • MicrosoftSkill

    rust

    Use this guide when working on Rust changes in the FAST monorepo.

    Also in 9 projects that use this

  • SupabaseSkill

    react-hook-form

    Correct React Hook Form usage anywhere in the monorepo — data flow, subscriptions,

    Also in 3 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 10 projects that use this

  • leonaaardobSkill

    drizzle

    Complete Drizzle ORM documentation in markdown format. Use when working with Drizzle ORM - covers schema definition, queries, migrations, database connections (PostgreSQL, MySQL, SQLite), integrations (Neon, Supabase, PlanetScale, Cloudflare D1, Turso), column types, relations, transactions, and framework usage (Next.js, SvelteKit, Astro).

    Also in 3 projects that use this

  • thongdn-itSkill

    tailwind

    Tailwind CSS v4 performance optimization and best practices guidelines (formerly tailwindcss-v4-style). This skill should be used when writing, reviewing, or refactoring Tailwind CSS v4 code to ensure optimal build performance, minimal CSS output, and correct usage of v4 features. Triggers on tasks involving Tailwind configuration, @theme directive, utility classes, responsive design, dark mode, container queries, or CSS generation optimization.

    Also in 5 projects that use this

  • +1 more from thongdn-it

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 9 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 52 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When in doubt, copy the local pattern in the file you are editing rather than importing a style from elsewhere.

    line 12
  2. Distinctive:

    Do not add runtime checks that the type system already guarantees.

    line 35
  3. Very specific:

    Treat as as a last resort, not a way to silence errors.

    line 56
  4. Very specific:

    Never as any or as unknown as X unless at a proven interop seam or test-only partial mock.

    line 68
  5. Distinctive:

    If control flow already proved the type, the cast is redundant — remove it.

    line 69
  6. Distinctive:

    When a cast is truly needed, add a one-line comment explaining why.

    line 70
  7. Distinctive:

    Do not extract a function, class, or type that is used exactly once, unless it genuinely improves readability at the call site.

    line 78
  8. Very specific:

    If a catch block doesn't add information or recover, delete the try/catch.

    line 98
  9. Distinctive:

    When two declarations describe the same thing — types, constants, defaults, validation rules — one must derive from the other.

    line 125
  10. Very specific:

    Before writing a helper function, search the codebase.

    line 129
  11. Distinctive:

    Don't introduce deep conditional types, mapped types, or template literal types unless they clearly reduce complexity.

    line 133
  12. Distinctive:

    Don't create a reusable utility type for one call site.

    line 134
  13. Distinctive:

    Prefer the smallest type shape that explains the contract.

    line 135
  14. Very specific:

    Use import type for type-only imports.

    line 140

“Common” is measured: kept by at least 6 in 10 of the 52 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

TypeScript Anti-Slop guardrails

Skip formatting and lint rules — tooling handles those. This skill targets patterns that produce valid-looking but poor-quality code.

When in doubt, copy the local pattern in the file you are editing rather than importing a style from elsewhere.

1. No restating comments

Comments that repeat what the next line does are noise. Only comment why, never what.

// wrong
// Set the current file path
context.setFilePath(filePath);
// Initialize the reporter
const reporter = new Reporter(config);

// right — let code speak; comment only non-obvious intent
// Force sequential execution — parallel runs corrupt shared fixture state
context.setFilePath(filePath);
const reporter = new Reporter(config);

Also avoid: section-header comments inside functions (// --- Validate ---), JSDoc that adds nothing beyond the signature, temporal markers (// added for, // Phase 1).

2. No unnecessary defensive code

Do not add runtime checks that the type system already guarantees. Trust the types.

// wrong — param is already typed string
function resolvePattern(pattern: string): string {
  if (typeof pattern !== 'string') {
    throw new Error('pattern must be a string');
  }
  return glob(pattern);
}

// right — trust the type system
function resolvePattern(pattern: string): string {
  return glob(pattern);
}

Also avoid: redundant ?? [] / || {} on fields that are always initialized (normalize once at construction instead), null checks on values you just produced, try/catch around code that cannot throw.

3. Minimize as

Treat as as a last resort, not a way to silence errors. If you need as, the types are probably wrong.

// wrong — casting to escape a type error
const name = (config as any).testName;

// right — narrow or fix the type
if ('testName' in config) {
  const name = config.testName;
}
  • Never as any or as unknown as X unless at a proven interop seam or test-only partial mock.
  • If control flow already proved the type, the cast is redundant — remove it.
  • When a cast is truly needed, add a one-line comment explaining why.

4. Minimize any

noExplicitAny is off in this repository, so self-police. Prefer unknown + narrowing, or a generic, before reaching for any. Never let any leak into exported APIs, config types, or cross-package contracts.

5. No One-Use abstractions

Do not extract a function, class, or type that is used exactly once, unless it genuinely improves readability at the call site.

// wrong — called once, five lines away
function formatTestName(name: string): string {
  return name.replace(/\.test$/, '');
}
// ... later:
const display = formatTestName(file);

// right — inline it
const display = file.replace(/\.test$/, '');

Also avoid: interfaces with single implementations, factory functions that create one thing, options objects with 10 optional fields for features that don't exist yet.

Threshold: extract when used in 3+ places, or when the extraction meaningfully shortens a complex function.

6. No Catch-and-Rethrow without context

If a catch block doesn't add information or recover, delete the try/catch.

// wrong — catches and rethrows with just a message rewrite
try {
  await loadConfig(path);
} catch (error) {
  throw new Error(
    `Failed to load: ${error instanceof Error ? error.message : error}`,
  );
}

// right — use cause to preserve the chain
try {
  await loadConfig(path);
} catch (error) {
  throw new Error(`Failed to load config at ${path}`, { cause: error });
}

// also right — just don't catch if you add nothing
await loadConfig(path);

Also avoid: bare rethrow (catch (e) { throw e; }), empty catch blocks, catch blocks that only console.log.

7. Single source of truth — prevent drift

When two declarations describe the same thing — types, constants, defaults, validation rules — one must derive from the other. Duplicating independently causes drift: they match today, diverge silently tomorrow. Derive via extends, Pick, ReturnType, typeof, satisfies, or simply importing the canonical definition.

8. Search before creating utilities

Before writing a helper function, search the codebase. If it exists, import it. If it exists but isn't exported, export it. Don't create a second isObject() or normalizeSlashes().

9. No Over-Engineered types

  • Don't introduce deep conditional types, mapped types, or template literal types unless they clearly reduce complexity.
  • Don't create a reusable utility type for one call site.
  • Prefer the smallest type shape that explains the contract.
  • This repository uses both type and interface — follow nearby code.

Repository conventions

  • Use import type for type-only imports.
  • Public config properties: use JSDoc with @default.
  • Preserve existing file-local patterns unless there is a clear bug or maintenance win.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.