agentleFS
0xrohan100xrohan10/skills/typescript-structure/SKILL.md

typescript-structure

Skill2 starsChanged 4 months agoMITView on GitHub

TypeScript structure through narrow domain modules and explicit dependency graphs. Use when designing or refactoring module boundaries, public APIs, domain types, imports, or Effect service architecture.

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    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:

    Keep constructors, operations, comparison, encoding, and decoding with that type.

    line 14
  2. Very specific:

    Use the same names for the same operations across modules: make, decode, encode, equals, compare.

    line 20
  3. Very specific:

    Put the module's primary value first: update(user, patch).

    line 21
  4. Very specific:

    Put callbacks and options last: map(users, transform).

    line 22
  5. Very specific:

    Put expected failure in Effect, Result, or another explicit return type.

    line 31
  6. Distinctive:

    Use named imports or stable module qualifiers so identifier provenance is visible.

    line 36
  7. Distinctive:

    Import internal dependencies from their owning leaf module.

    line 37
  8. Distinctive:

    Keep imports acyclic. Extract a lower-level module when a cycle reveals a shared primitive.

    line 39
  9. Very specific:

    Use domain-specific equals, compare, and hashing rather than representation-based shortcuts.

    line 40
  10. Distinctive:

    Put API documentation on exported declarations.

    line 44
  11. Distinctive:

    When a changed module uses Effect, read the Effect structure rules.

    line 51
  12. Distinctive:

    Before finishing, verify every changed module:

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 Structure

Apply these rules to every module created or changed. Project conventions take precedence where they already make a clear choice.

Modules Follow Types

  • Give every important domain type a dedicated module.
  • Name the exported type after the domain concept.
  • Keep constructors, operations, comparison, encoding, and decoding with that type.
  • Export the smallest interface used by real clients. Keep representation and helpers private.
  • Draft the exports and one client call site before implementing the module.

Keep Interfaces Uniform

  • Use the same names for the same operations across modules: make, decode, encode, equals, compare.
  • Put the module's primary value first: update(user, patch).
  • Put callbacks and options last: map(users, transform).
  • Make the default operation safe. Use OrThrow only for an explicitly throwing variant: find and findOrThrow.
  • Introduce a capability interface when generic code consumes it.

Encode Valid States

  • Replace boolean flags and state-dependent optional fields with discriminated unions.
  • Exhaustively switch on every union. Close the default branch with never or the project's equivalent.
  • Brand primitives whose domain invariants matter and expose validated construction.
  • Put expected failure in Effect, Result, or another explicit return type.
  • Decode unknown where untrusted data enters the program.

Keep Names Explicit

  • Use named imports or stable module qualifiers so identifier provenance is visible.
  • Import internal dependencies from their owning leaf module.
  • Restrict barrels to curated package entry points; use leaf imports for the internal dependency graph.
  • Keep imports acyclic. Extract a lower-level module when a cycle reveals a shared primitive.
  • Use domain-specific equals, compare, and hashing rather than representation-based shortcuts.

Make Intent Checkable

  • Put API documentation on exported declarations; put implementation rationale beside the relevant code.
  • Make deliberately discarded synchronous results explicit with void.
  • Observe every promise through await, return, or an explicit runtime boundary.
  • Enforce formatting, import, exhaustiveness, and ignored-result conventions with project tooling.

Effect Modules

When a changed module uses Effect, read the Effect structure rules. Verify APIs against the installed Effect version.

Completion Gate

Before finishing, verify every changed module:

  • gives each important type one owner;
  • exposes only client-required operations;
  • matches analogous modules in names, argument order, and failure behavior;
  • makes invalid states and expected failures visible in types;
  • uses explicit, acyclic imports;
  • passes the project's formatter, typecheck, lint, and tests.

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.