Skip to content

feat(typescript): add tsc-blindspots and type-safe authoring, JS->TS migration skills - #69

Open
MajorLift wants to merge 11 commits into
MetaMask:mainfrom
MajorLift:add/typescript-typing-skill
Open

feat(typescript): add tsc-blindspots and type-safe authoring, JS->TS migration skills#69
MajorLift wants to merge 11 commits into
MetaMask:mainfrom
MajorLift:add/typescript-typing-skill

Conversation

@MajorLift

@MajorLift MajorLift commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Adds a typescript domain with five experimental skills — the reasoning layer for TypeScript authoring and JS→TS migration that coding-guidelines only gestures at.

Why it earns a place as an extension skill: the extension is a large, ongoing JS→TS migration authored increasingly by AI agents (Claude, Cursor, Codex, headless cloud agents). Three failure modes recur under conversion pressure — reaching for any, hand-writing ad-hoc types that duplicate an authoritative source, and converting a multi-thousand-line file in one unreviewable pass. @typescript-eslint/no-explicit-any is a CI hard-gate for the first; the reasoning behind all three is un-lintable and belongs in a skill that reaches every operator.

Skills

  • avoid-anyany is a directive that disables type checking, not a wide type. Substitute by position (assignee → unknown, assigned → never); the one exception is a generic constraint, declared with an inline eslint-disable.
  • derive-types — derive from authoritative sources (indexed access, typeof, ReturnType/Parameters, Pick/Omit, Infer<typeof struct>) instead of ad-hoc types that duplicate, run too wide, and drift. Grounded in a real extension counterexample (#42583).
  • decompose-large-files — decompose a large file by coherent, independently-mergeable units to improve modularity, maintainability, and reviewability, and to unblock incremental TS migration. Extract by coherent subject; never fragment for its own sake. Modeled on the MetamaskController decomposition (#41735).
  • migration-context-cost — reason about the fan-in/fan-out cost of a conversion: how much context a file drags in, and therefore whether it is a cheap first migration or one that pulls half the repo with it.
  • tsc-blindspots — find the type defects tsc is structurally unable to report. A green build is not evidence the types are correct: hand-written types that restate an authoritative source can disagree with it, and the language and config carry standing blind spots.

Grounded in MetaMask/contributor-docs docs/typescript.md. Shipped experimental (opt-in via --maturity experimental); no repos/ overlay, so it applies to metamask-extension, metamask-mobile, and core alike. Commits GPG-signed.

tsc-blindspots lives here rather than in testing (it supersedes #85, which placed it there). Its subject is whether a hand-written type agrees with its authoritative source — the question derive-types answers from the authoring side, one step earlier. Both rest on this domain's premise that a green tsc proves well-formedness, not correctness; in a partially-migrated repo with checkJs off it often cannot prove even that. It ships scripts/substitution-ab.sh plus three references.


Validation runs

Trial runs of this PR's skills against merged metamask-extension PRs nobody flagged. Every claim was re-verified against the real diff before posting. Clean results are included on purpose — a skill that only ever reports problems cannot be calibrated.

PR Skill Verdict Finding
#41333 tsc-blindspots Gap local type restates upstream Log.topics; naive probe reports false clean

Each comment carries a trial-run disclaimer and links back here for feedback.

MajorLift added a commit to MajorLift/metamask-skills that referenced this pull request Jul 16, 2026
…d by the `typescript-typing` skill

Their content now ships as the `typescript-typing` skill in MetaMask#69,
where it distributes via the CLI — knowledge/ files are never synced.
@MajorLift MajorLift changed the title Add typescript-typing skill (any-handling + type derivation) Add typescript domain: avoid-any, derive-types, decompose-large-files Jul 16, 2026
…ary-identification is step one of any migration
…und unit conversion, swap in the stronger derive-types example, slim CHANGELOG

- migration-context-cost: line count is a factor not a non-factor; fan-in is a reading cost (not a change/review surface), fan-out is the change surface; drop the wrong "upstream types land first" and off-topic barrel bullet
- decompose-large-files: the point is converting to TS in small self-contained units, not extraction
- derive-types: replace the NetworkState restatement with the reinvented-messenger + hand-copied-return example (derive via `ReturnType<Action['handler']>`)
- CHANGELOG: list the domain, not each skill
@MajorLift
MajorLift force-pushed the add/typescript-typing-skill branch from 5e7bc67 to 801758f Compare July 22, 2026 16:31
CHANGELOG.md tracks consumer-facing changes to the `@metamask/skills` package,
per CONTRIBUTING's "CLI / tooling changes" section. No merged skill-only PR adds
an entry (MetaMask#80, MetaMask#78, MetaMask#70, MetaMask#62, MetaMask#61 all touch zero changelog lines).

It was also the sole source of this branch's conflict with `main`, since every
skill PR edits the same `[Unreleased]` block.
@MajorLift MajorLift changed the title Add typescript domain: avoid-any, derive-types, decompose-large-files feat(typescript): add authoring and JS→TS migration skills Jul 30, 2026
@MajorLift
MajorLift marked this pull request as draft July 30, 2026 14:03
…main

Was a separate PR against `domains/testing`. It belongs here: its subject is
whether a hand-written type agrees with its authoritative source, which is the
question `derive-types` answers from the authoring side, and it shares this
domain's premise that a green `tsc` is not evidence the types are correct.

Directory name and frontmatter `name` already agree; only the domain moved.
@MajorLift MajorLift changed the title feat(typescript): add authoring and JS→TS migration skills feat(typescript): add authoring, migration, and compiler-blindspot skills Jul 30, 2026
@MajorLift MajorLift changed the title feat(typescript): add authoring, migration, and compiler-blindspot skills feat(typescript): add typescript-compiler-blindspot and authoring, migration skills Jul 30, 2026
@MajorLift MajorLift changed the title feat(typescript): add typescript-compiler-blindspot and authoring, migration skills feat(typescript): add typescript-compiler-blindspots and type-safe authoring, JS->TS migration skills Jul 30, 2026
@MajorLift
MajorLift marked this pull request as ready for review July 30, 2026 18:15
@MajorLift

MajorLift commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Context budget

What this PR costs an agent, measured from an install rather than read from the diff. Three tiers, and only the first is unavoidable.

Skill Frontmatter Selected + refs & knowledge
avoid-any 359 chars ~1,605 tok ~1,605 tok
decompose-large-files 266 chars ~1,612 tok ~1,612 tok
derive-types 210 chars ~1,168 tok ~1,168 tok
migration-context-cost 243 chars ~781 tok ~781 tok
tsc-blindspots 1,244 chars ~3,406 tok ~8,327 tok

Frontmatter is the only tier paid unconditionally — every agent loads it on every run once the skill is installed, used or not, because it is what the agent reads to decide relevance. The 28 skills across the eleven open skill PRs sit at a median of ~1,716 tokens selected and ~1,860 with references followed. All are within the 1,536-character description budget.

Selected is paid only when the agent picks the skill. + refs & knowledge is the ceiling if every bundled reference is then read; it is a worst case, not an expectation.

Method

tools/install --repo metamask-extension --maturity experimental against this branch at e170b394c, measured per installed skill directory. Repo overlays are merged into the emitted SKILL.md, so they land in the selected tier rather than being missed by a source-byte count. Token figures are bytes/4 — a proxy for scale, not accounting.

These figures are pinned to the commit above and drift on every push; #96 tracks automating them.

The skill lives in the `typescript` domain, so the prefix repeated information
already carried by the path and by every discovery surface that shows it.
Installed as `mms-compiler-blindspots`.
@MajorLift MajorLift changed the title feat(typescript): add typescript-compiler-blindspots and type-safe authoring, JS->TS migration skills feat(typescript): add compiler-blindspots and type-safe authoring, JS->TS migration skills Jul 31, 2026
@MajorLift MajorLift changed the title feat(typescript): add compiler-blindspots and type-safe authoring, JS->TS migration skills feat(typescript): add tsc-blindspots and type-safe authoring, JS->TS migration skills Jul 31, 2026
Skills install flat as `mms-<name>`, so `domains/typescript/` does not
disambiguate the name at the callsite — and "compiler" reads as React Compiler in
a repo where that is a live subject. The skill is about `tsc` specifically: its
own first clause is "the type defects `tsc` is structurally unable to report".

Also adds the slash trigger to the description, which listed only prose phrases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant