agentleFS
dlupiakdlupiak/claude-session-dashboard/.claude/skills/typescript-rules/SKILL.md

typescript-rules

Skill71 starsChanged 9 months agoMITView on GitHub

TypeScript coding conventions

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never use any — use unknown with type guards or explicit types

    line 10
  2. Very specific:

    Prefer interface for object shapes, type for unions/intersections

    line 11
  3. Very specific:

    Use satisfies for type-safe object literals: const x = { ...

    line 13
  4. Very specific:

    Use @/ path alias for imports from apps/web/src/

    line 16
  5. Very specific:

    Use type imports for type-only: import type { Foo } from './types'

    line 18
  6. Very specific:

    No cross-slice imports — shared code goes in src/lib/

    line 24
  7. Very specific:

    Test files: *.test.ts(x) co-located with source

    line 31
  8. Very specific:

    Use discriminated unions for result types: { ok: true.

    line 35
  9. Distinctive:

    Prefer named function declarations over arrow functions for top-level exports

    line 39
  10. Distinctive:

    Use explicit return types on exported functions

    line 40
  11. Distinctive:

    Keep functions small — max ~50 lines

    line 41
  12. Very specific:

    Use z.infer<typeof schema> for derived types

    line 46

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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 Rules

Types

  • Never use any — use unknown with type guards or explicit types
  • Prefer interface for object shapes, type for unions/intersections
  • Export types alongside their functions, not from barrel files
  • Use satisfies for type-safe object literals: const x = { ... } satisfies Config

Imports

  • Use @/ path alias for imports from apps/web/src/
  • Group imports: external libs → @/lib/ → relative slice imports
  • Use type imports for type-only: import type { Foo } from './types'

Architecture Boundaries

Vertical slice structure (src/features/<slice>/)

  • Each slice owns its own server functions, queries, components, and types
  • No cross-slice imports — shared code goes in src/lib/
  • src/lib/ modules must NOT import from src/features/

File naming

  • Server function files: *.server.ts
  • Query/hooks files: *.queries.ts
  • Component files: PascalCase (e.g., SessionCard.tsx)
  • Test files: *.test.ts(x) co-located with source

Error Handling

  • Throw typed errors, not strings: throw new Error('message')
  • Use discriminated unions for result types: { ok: true; data: T } | { ok: false; error: string }
  • Catch unknown, narrow with instanceof

Functions

  • Prefer named function declarations over arrow functions for top-level exports
  • Use explicit return types on exported functions
  • Keep functions small — max ~50 lines

Zod

  • Validate all external input (API responses, form data, URL params) with Zod
  • Co-locate schemas with server functions, not in separate schema files
  • Use z.infer<typeof schema> for derived types

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.