agentleFS
MicrosoftKnown publishermicrosoft/scope/.agents/skills/typescript/SKILL.md

typescript

Skill7 starsChanged 2 months agoMITView on GitHub

TypeScript best practices for this monorepo. Use this skill when: (1) writing new TypeScript code, (2) reviewing TypeScript code, (3) working with API responses, fetch calls, or JSON parsing, (4) adding or modifying types and interfaces.

33 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use python, react and 2 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.
  • rogue-dev-studioSkill

    python

    Python 3.13 with uv package manager via mise. Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `python` work when listed in TEAM.yaml or explicitly requested.

    Also in 9 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 6 projects that use this

  • 0xSeroSkill

    security

    Also in 4 projects that use this

  • BlockSkill

    debugging

    Debugging guidelines and best practices

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 27 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create a local interface: if no shared type exists and the response shape is known

    line 48
  2. Very specific:

    Use Zod .parse(): when you need runtime validation (e.g., external APIs you don't control)

    line 49
  3. Very specific:

    Use unknown when the type is genuinely not known, then narrow with type guards

    line 80
  4. Distinctive:

    Use generics when writing reusable utilities

    line 81
  5. Very specific:

    If you must use any (e.g., third-party library boundaries), contain it — cast to a typed variable immediately

    line 82

“Common” is measured: kept by at least 6 in 10 of the 27 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 Best Practices

Never Leave Values Untyped at any Boundaries

Whenever data crosses a boundary that erases type information (response.json(), JSON.parse(), external library returns, database query results, queue message payloads), immediately annotate or narrow the type:

// ❌ BAD — `any` leaks through, wrong property access compiles silently
const data = await response.json();
data.turns; // no error even if turns lives at data.run.turns

const parsed = JSON.parse(rawMessage);
parsed.requestId; // unverified assumption

// ✅ GOOD — type boundary is explicit, TypeScript verifies all access
import type { RequestDocument } from "shared";
const data: RequestDocument = await response.json();
data.run?.turns; // correct path, verified at compile time

const parsed: QueueMessagePayload = JSON.parse(rawMessage);
parsed.requestId; // known to exist

Why This Matters

  • any propagates silently — one untyped value infects everything it touches
  • Bugs from wrong property paths are invisible at compile time
  • Tests may share the same wrong assumption as the code (mocks mirror the bug)
  • Adding a type annotation is zero-cost at runtime but catches entire classes of bugs

Guidelines

  1. Import the shared type from packages/shared when one exists (e.g., RequestDocument, RunState, ReportDocument)
  2. Create a local interface if no shared type exists and the response shape is known
  3. Use Zod .parse() when you need runtime validation (e.g., external APIs you don't control)
  4. Use optional chaining (?.) instead of || {} fallbacks — it preserves type narrowing

Prefer Optional Chaining Over Fallback Objects

// ❌ BAD — `|| {}` erases type information, downstream access is untyped
const run = request.run || {};
run.turns; // type is `{}`, no autocomplete, no error checking

// ✅ GOOD — preserves the original type, TypeScript tracks nullability
const run = request.run;
run?.turns; // type is `ConversationTurn[] | undefined`

Use Shared Types from packages/shared

This monorepo defines canonical types in packages/shared/src/types/. Always import from there rather than redeclaring shapes:

TypeUse For
RequestDocumentFull request document (includes run?: RunState)
RunStatePer-attempt run state (status, turns, outcome)
ConversationTurnIndividual iteration within a run
ReportDocumentReport job state
ReportTemplateDocumentReport template configuration
LogEventStructured log entry
ScenarioTask + criteria definition

Avoid any in New Code

  • Use unknown when the type is genuinely not known, then narrow with type guards
  • Use generics when writing reusable utilities
  • If you must use any (e.g., third-party library boundaries), contain it — cast to a typed variable immediately
// ❌ BAD — any spreads and defeats type checking
function process(data: any) {
  return data.items.map((i: any) => i.name);
}

// ✅ GOOD — typed boundary, any is contained
interface ApiResponse { items: Array<{ name: string }> }
function process(data: unknown): string[] {
  const typed = data as ApiResponse;
  return typed.items.map(i => i.name);
}

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.