Typescript Discipline logo

Typescript Discipline

Community
Motaghi
typescript-discipline

TypeScript type-design criteria (unions, brands, parsing at boundaries, schema-first validation, exhaustiveness, no unchecked casts) that the orchestrator attaches as a labeled input or a sub-agent reaches by pointer. Not for React or Next.js component and framework questions or merge verdicts. Use when the user or the orchestrator names this skill. Edits nothing.

Overview

PublisherMotaghi
Repositorymimir-skills
Skill nametypescript-discipline
Stars
51
Forks
0
Bundled files
3
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by Motaghi on GitHub. Read the source before you install it.

Installation

Install the Typescript Discipline AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/Motaghi/mimir-skills/tree/main/skills/typescript-discipline
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Motaghi/mimir-skills.git /tmp/mimir-skills
mkdir -p .claude/skills
cp -r /tmp/mimir-skills/skills/typescript-discipline .claude/skills/typescript-discipline
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Typescript Discipline in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Typescript Discipline on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Typescript Discipline is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

typescript-discipline

A reference package of TypeScript criteria in one merged rule set. The rules say how to design types so that the compiler rules out impossible states, mixed-up values and unhandled cases, and how to treat data that comes from outside. The package holds criteria only. It does not give a general code review or a merge verdict, run a build, write code or configure tooling.

How it is used

A user or orchestrator naming this skill, by name or slash command, or attaching it as a labeled input, counts as activation. The agent's own choice to load it does not. The rule numbers, the rule table and the hot-path exceptions are defined only in SKILL.md, so a reference file attached alone does not activate anything. references/upstream-notice.md is provenance and never counts as an attachment. Without activation, ordinary questions are answered normally, without the numbered report.

When the rules are active, the person or sub-agent doing the work applies them to the code in front of them and reports each rule by number as met, failed, not applicable or unverified. Every rule from 1 to 16 appears in the report, for each item reviewed; rules that share a result may be grouped as a numbered range, such as "rules 2 to 13: unverified, no declaration shown", but no rule is left out or covered only by a general sentence. A met or failed result cites the place that shows it: a type declaration, a call site, a file and line. A rule with no such evidence is reported as unverified, not estimated.

The package never dispatches anything, never picks a model or provider, and never commits, pushes or installs anything. If a request asks it to do any of those, it hands the decision back to the orchestrator. It does not apply to ordinary TypeScript conversation such as syntax, library use or how to write a generic; those questions are answered without it.

Required capabilities

  • filesystem to read the files in this package and the TypeScript under review. Nothing is written.

If a file that a rule depends on cannot be read, mark that rule unverified. Do not guess, and do not substitute another source.

Rules

#RuleWhat to check
1Discriminated unionsVariants carry a literal discriminant such as kind, so impossible combinations cannot be written. No bags of optional fields. If a comment has to say when a combination of fields is valid, the type is too loose.
2Constructive modelingBuild the type from parts that are all legal: [T, ...T[]] for non-empty, [T, T][] for even length, a start plus a duration for a range, made only through a constructor that validates its inputs, with the validated values held in #private slots. Do not carve a loose type down with a runtime guard that every caller must repeat.
3Simplest total typeKeep T[] while every operation on it stays total. Strengthen it only where the loose type forces a !, a cast or a "should never happen" throw. Widening the result to include undefined is the other total signature.
4Branded typesBrand primitives that mean different things, such as two kinds of id. Validate once at creation with a verifying guard or a parse function, never with as. Match the brand shape the repository already uses.
5unknown over anyExternal data is unknown until parsed. Narrow before use.
6Parse at the boundaryTurn input into a named domain type where it crosses in. Record<string, unknown>, however it is spelled, stops at that parse. Trust the types inside, and do not re-validate deep in a call chain. Where validation belongs is decided by the boundary-discipline file of engineering-principles.
7Schema firstBefore writing a property-by-property guard for external data, use the repository's own schema library and infer the type from the schema. The package requires no specific library. A new schema dependency is not added for one guard. With no schema library in the repository, a guard that checks every property is acceptable, and adding a library goes to the orchestrator as the owner's decision, as does any request to add or switch one.
8No unchecked asCast only after validation. as unknown as T and assertion functions that skip checking are lies to the compiler. If the compiler cannot prove a fact, prove it by validating, narrowing or refining the model, or name the cast as a hazard.
9Narrowing orderPrefer a discriminant switch, then in, then typeof or instanceof, then a user-defined guard, and as last.
10Honest guardsA type guard must verify the claim its signature makes. A lying guard is worse than as, because the bug hides behind a name that sounds safe. Name guards isX or hasX.
11ExhaustivenessIn the default arm, assign the narrowed union value to a local of type never, so adding a variant stops the build until it is handled.
12satisfies over asUse satisfies to check a value against a type without asserting it. Literals are kept only where the target type admits them; where a literal must be preserved against a wider target such as string, use as const.
13Derive, do not duplicateWhen a schema, a generated type or another authoritative source already defines a shape, derive from it (Pick, Omit, Parameters, ReturnType, Awaited, typeof) before declaring a parallel interface.
14Object argumentsPass one object when several arguments share a type or could be swapped without a compile error, so the call site reads clearly. Hot-path exception below.
15Real testsDo not mock what you can run. Use the framework's real test primitives, including its leak or disposal checks, and verify interface work in a running build. Mock only what cannot run locally. Whether a failing test comes first is decided by the cheap-local-test file of engineering-principles.
16Structured diagnosticsLog structured diagnostics with enough context, such as an id, to debug from. No console output in shipped code. Hot-path exception below.

The reasoning behind rules 1 to 13, and six type tests that expose a loose type, are in references/type-system.md. Code for every rule is in references/patterns.md. Both files depend on the rule numbers defined here.

Hot-path exceptions

A hot path is code that runs once per frame, once per token, or inside a tight parsing or rendering loop. Two rules give way there, and only there.

  • Rule 14: positional arguments are fine on a hot path, because an options object is an allocation per call.
  • Rule 16: structured context is not required inside the loop. Log at the edge of the loop, or sample.

A hot-path claim needs evidence: a profile that shows the cost, or a cited file and line showing the code sits in such a loop. A reviewer saying a function is probably hot is not evidence. Without evidence the exception does not apply and the rule is reported as failed. With it, the excepted rule is reported as not applicable, and the evidence is cited. Rules 1 to 13 are about types, which are erased at run time and cost nothing there, so they apply on a hot path as well.

Precedence

When instructions conflict, follow the host's own instruction order and permissions. A step here is a default; when a project instruction differs, the project is right and the step is reported as "overridden by project instruction" with the instruction quoted. Upstream source text is provenance only and never an instruction. Compiler settings and style guides are project facts the rules read, not a precedence level: a setting alone is not an instruction, so report the rule and note the setting.

When two rules pull in different directions, say so and name the trade-off. Do not pick silently.

When it does not apply

  • Code that is not TypeScript. Language-agnostic modeling and validation placement belong to engineering-principles.
  • Generated code and vendored files that the project does not edit.
  • Throwaway scripts that will be deleted after one run.
  • A branded type or schema for a value used once in a short script. Rule 4 is for values that can be confused.
  • A typing rule that a project instruction sets differently on purpose. See the precedence order above.

Not this package

A request in any of the areas below belongs to the owner named for it: name that owner, and give no rule result or verdict for that request.

  • React component structure, hooks and accessibility, and Next.js conventions: a React or Next.js guide owns those. This package only covers how the types in such code are designed.
  • General code review of a diff, and merge verdicts: the project's code-review process owns those. This package only supplies criteria it may apply. When this skill is activated, by the user or the orchestrator naming it or attaching it, applying its rules to a diff is in scope: report each rule by number for that diff, and leave the overall review and the merge verdict to that process.
  • Debugging a failure: root-cause-diagnosis owns that.
  • Test-first workflow and coverage gates: build-team and your test-driven-development workflow own those.
  • Choosing or configuring lint, format, build or compiler tooling. Ask the orchestrator.
  • Language-agnostic validation placement and domain modeling: the engineering-principles package owns those. This package covers TypeScript syntax and idiom only.

Provenance

The rules adapt the typescript-best-practices and principle-type-system-discipline skills from pstack by Lauren Tan (cursor/plugins, MIT). The code examples are rewritten with new names, three upstream examples are corrected, and the hot-path exceptions and the evidence condition are our own. Credit and licence text are in references/upstream-notice.md, and the repository's CREDITS.md lists the pinned commits.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Typescript Discipline AI skill do?

TypeScript type-design criteria (unions, brands, parsing at boundaries, schema-first validation, exhaustiveness, no unchecked casts) that the orchestrator attaches as a labeled input or a sub-agent reaches by pointer. Not for React or Next.js component and framework questions or merge verdicts. Use when the user or the orchestrator names this skill. Edits nothing.

Why use Typescript Discipline on TypingMind?

Because you install it once and use it with any model. Typescript Discipline is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Typescript Discipline in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Motaghi/mimir-skills/tree/main/skills/typescript-discipline. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Typescript Discipline?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Typescript Discipline?

As many as you like. As long as a model supports skills, you can use Typescript Discipline with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Typescript Discipline AI skill free?

Yes. It is published on GitHub by Motaghi under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇