[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CGHAYAPGPGK2VT83B1V9SY":3,"skill-same:01M6CGHAYAPGPGK2VT83B1V9SY":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":31,"linkOnly":32,"markdownContent":33,"markdownBody":34,"frontMatter":35,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":43,"ownerDescription":44,"updatedAt":45,"install":46,"resources":59},"01M6CGHAYAPGPGK2VT83B1V9SY","derive-types",null,"Derive types from authoritative sources (indexed access, `typeof`, `ReturnType`\u002F`Parameters`, `Pick`\u002F`Omit`, `Infer\u003Ctypeof struct>`) instead of hand-writing ad-hoc types that duplicate, run too wide or too narrow, and drift.","MetaMask\u002Fskills","MetaMask","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F11744586?v=4","01M6CGATQAN8ZP8HWEZH2379WJ","01M6CGATVJDE1ZMSRM20CFJ5S8",25,"MIT","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Ftypescript\u002Fskills\u002Fderive-types\u002Fskill.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30],"derive types","types","writing","run","access","pick","drift","infer","duplicate","sources","ad","hand","wide","2026-11-10 10:12:30",false,"---\nname: derive-types\ndescription: Derive types from authoritative sources (indexed access, `typeof`, `ReturnType`\u002F`Parameters`, `Pick`\u002F`Omit`, `Infer\u003Ctypeof struct>`) instead of hand-writing ad-hoc types that duplicate, run too wide or too narrow, and drift.\nmaturity: experimental\n---\n\n# Derive Types From Authoritative Sources\n\nDeepens the TypeScript guidance in `mms-coding-guidelines`, and is the structural counterpart to the contributor-docs rule *Prefer type inference over annotations and assertions* (`MetaMask\u002Fcontributor-docs` `docs\u002Ftypescript.md`). Where inference handles values, derivation handles types that reference other types.\n\n## Derive, don't re-declare\n\nWhen a type already exists at an authoritative source — a controller's state type, a function's return, a library's exported type, a schema\u002Fstruct — **derive from it** rather than restating it. Derive with indexed access (`State['field']`), `typeof`, `ReturnType` \u002F `Parameters` \u002F `Awaited`, utility types (`Pick` \u002F `Omit` \u002F `Partial`), and `Infer\u003Ctypeof struct>`; let inference carry the rest. Inference covers an omitted return annotation, `as const` on a literal, and `satisfies` where a `:` annotation would widen the inferred type. How narrow the result should be, including literal lookup tables and built keys, is `avoid-widening`. Inferred and derived types stay \"responsive to changes in code,\" while hand-written declarations \"rely on hard-coding, making them brittle against code drift.\"\n\nOver a union, `Pick` and `Omit` work on `keyof` the whole union, which is only the keys every member shares, so `Omit\u003CA | B, 'k'>` loses each member's own keys. Branch first with a distributive conditional type: `T extends unknown ? Omit\u003CT, K> : never` applies `Omit` to each member.\n\nAn ad-hoc type — one hand-defined to describe a value an authoritative type already describes — carries three dangers:\n\n- **Duplication.** The same shape is stated twice; every reader reconciles them and every change touches both.\n- **Incorrect in either direction.** A hand-written type is a _guess_ at the source's shape, and the guess can miss either way. Too wide, it admits values the authoritative type would reject, so invalid data still type-checks. Too narrow, it drops a case the source allows, such as a `| undefined`, and erases the compiler's record of why a runtime guard exists (see the five divergence shapes in `tsc-blindspots`).\n- **Drift.** The source evolves; the copy does not. Because it is hand-written rather than derived, the compiler cannot flag the divergence — the bug surfaces at runtime, not at build.\n\n## A grounded example (`metamask-extension` #42583)\n\nA `wallet-services` module hand-rolled a messenger type, re-declaring each controller action's signature and **hand-copying its return shape** inline.\n\n? Reinvents the controller's messenger and re-states its action returns:\n\n```typescript\ntype TokenResolutionMessenger = {\n  call(\n    action: 'AssetsContractController:getTokenStandardAndDetails',\n    address: string,\n    \u002F\u002F …\n  ): Promise\u003C\n    | {\n        balance?: string | number | bigint | { toString(radix?: number): string };\n        decimals?: string | number | bigint | { toString(radix?: number): string };\n        standard?: string;\n        symbol?: string;\n      }\n    | undefined\n  >;\n  \u002F\u002F the other action's return is discarded entirely:\n  call(action: 'AssetsContractController:getBalancesInSingleCall' \u002F* … *\u002F): Promise\u003Cunknown>;\n};\n```\n\n✅ Derive each return from the controller's exported action type; don't hand-copy it:\n\n```typescript\nimport type { AssetsContractControllerGetTokenStandardAndDetailsAction } from '@metamask\u002Fassets-controllers';\n\n\u002F\u002F the action already types its own return — derive it\ntype TokenDetails = ReturnType\u003C\n  AssetsContractControllerGetTokenStandardAndDetailsAction['handler']\n>;\n```\n\nThe messenger itself should be a `Messenger` from `@metamask\u002Fmessenger` parameterized with those exported action types, so every `call` signature comes from the controller rather than a hand-rolled overload. The hand-rolled version is worse than a plain duplicate: one return is hand-copied (already looser than the controller's real type), the other (`Promise\u003Cunknown>`) discards the type entirely.\n\nThe same PR also typed a dependency `getMetaMaskState: () => Record\u003Cstring, unknown>`, which forced every consumer to re-cast the shape by hand — including a `{ metamask: getMetaMaskState() } as never` double-cast. That downstream cast tax is what a too-wide type always imposes; deriving the dependency from the authoritative state type deletes it. Notably the same file _did_ derive one type correctly (`type Action = (typeof ACTIONS)[number]`), so the pattern was already in hand — the discipline is extending it to every referenced type.\n\n## Rule\n\nBefore writing a type, ask where the value comes from and whether that source already types it. If it does, derive. Define a fresh type only when no authoritative source exists — a genuinely new shape at a boundary you own. Before defining, exhaust deriving: search the internal `@metamask\u002F*` packages and the consuming repo for the authoritative source first.\n","# Derive Types From Authoritative Sources\n\nDeepens the TypeScript guidance in `mms-coding-guidelines`, and is the structural counterpart to the contributor-docs rule *Prefer type inference over annotations and assertions* (`MetaMask\u002Fcontributor-docs` `docs\u002Ftypescript.md`). Where inference handles values, derivation handles types that reference other types.\n\n## Derive, don't re-declare\n\nWhen a type already exists at an authoritative source — a controller's state type, a function's return, a library's exported type, a schema\u002Fstruct — **derive from it** rather than restating it. Derive with indexed access (`State['field']`), `typeof`, `ReturnType` \u002F `Parameters` \u002F `Awaited`, utility types (`Pick` \u002F `Omit` \u002F `Partial`), and `Infer\u003Ctypeof struct>`; let inference carry the rest. Inference covers an omitted return annotation, `as const` on a literal, and `satisfies` where a `:` annotation would widen the inferred type. How narrow the result should be, including literal lookup tables and built keys, is `avoid-widening`. Inferred and derived types stay \"responsive to changes in code,\" while hand-written declarations \"rely on hard-coding, making them brittle against code drift.\"\n\nOver a union, `Pick` and `Omit` work on `keyof` the whole union, which is only the keys every member shares, so `Omit\u003CA | B, 'k'>` loses each member's own keys. Branch first with a distributive conditional type: `T extends unknown ? Omit\u003CT, K> : never` applies `Omit` to each member.\n\nAn ad-hoc type — one hand-defined to describe a value an authoritative type already describes — carries three dangers:\n\n- **Duplication.** The same shape is stated twice; every reader reconciles them and every change touches both.\n- **Incorrect in either direction.** A hand-written type is a _guess_ at the source's shape, and the guess can miss either way. Too wide, it admits values the authoritative type would reject, so invalid data still type-checks. Too narrow, it drops a case the source allows, such as a `| undefined`, and erases the compiler's record of why a runtime guard exists (see the five divergence shapes in `tsc-blindspots`).\n- **Drift.** The source evolves; the copy does not. Because it is hand-written rather than derived, the compiler cannot flag the divergence — the bug surfaces at runtime, not at build.\n\n## A grounded example (`metamask-extension` #42583)\n\nA `wallet-services` module hand-rolled a messenger type, re-declaring each controller action's signature and **hand-copying its return shape** inline.\n\n? Reinvents the controller's messenger and re-states its action returns:\n\n```typescript\ntype TokenResolutionMessenger = {\n  call(\n    action: 'AssetsContractController:getTokenStandardAndDetails',\n    address: string,\n    \u002F\u002F …\n  ): Promise\u003C\n    | {\n        balance?: string | number | bigint | { toString(radix?: number): string };\n        decimals?: string | number | bigint | { toString(radix?: number): string };\n        standard?: string;\n        symbol?: string;\n      }\n    | undefined\n  >;\n  \u002F\u002F the other action's return is discarded entirely:\n  call(action: 'AssetsContractController:getBalancesInSingleCall' \u002F* … *\u002F): Promise\u003Cunknown>;\n};\n```\n\n✅ Derive each return from the controller's exported action type; don't hand-copy it:\n\n```typescript\nimport type { AssetsContractControllerGetTokenStandardAndDetailsAction } from '@metamask\u002Fassets-controllers';\n\n\u002F\u002F the action already types its own return — derive it\ntype TokenDetails = ReturnType\u003C\n  AssetsContractControllerGetTokenStandardAndDetailsAction['handler']\n>;\n```\n\nThe messenger itself should be a `Messenger` from `@metamask\u002Fmessenger` parameterized with those exported action types, so every `call` signature comes from the controller rather than a hand-rolled overload. The hand-rolled version is worse than a plain duplicate: one return is hand-copied (already looser than the controller's real type), the other (`Promise\u003Cunknown>`) discards the type entirely.\n\nThe same PR also typed a dependency `getMetaMaskState: () => Record\u003Cstring, unknown>`, which forced every consumer to re-cast the shape by hand — including a `{ metamask: getMetaMaskState() } as never` double-cast. That downstream cast tax is what a too-wide type always imposes; deriving the dependency from the authoritative state type deletes it. Notably the same file _did_ derive one type correctly (`type Action = (typeof ACTIONS)[number]`), so the pattern was already in hand — the discipline is extending it to every referenced type.\n\n## Rule\n\nBefore writing a type, ask where the value comes from and whether that source already types it. If it does, derive. Define a fresh type only when no authoritative source exists — a genuinely new shape at a boundary you own. Before defining, exhaust deriving: search the internal `@metamask\u002F*` packages and the consuming repo for the authoritative source first.\n",{"name":5,"maturity":36,"description":7},"experimental","main","a0ec29ada8d53edf5a3f24370bec058767157433","domains\u002Ftypescript\u002Fskills\u002Fderive-types",11,"https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills","https:\u002F\u002Fgithub.com\u002FMetaMask","https:\u002F\u002Fmetamask.io","MetaMask brings Ethereum to your web browser","2026-11-14 02:01:03",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add MetaMask\u002Fskills --skill derive-types",{"tool":52,"command":53},"bunx","bunx skills add MetaMask\u002Fskills --skill derive-types",{"tool":55,"command":56},"pnpm","pnpm dlx skills add MetaMask\u002Fskills --skill derive-types","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Ftypescript\u002Fskills\u002Fderive-types\u002Fskill.md",true,[60,66,70],{"path":61,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":64,"sourceHtmlUrl":65},"repos\u002Fcore.md","REFERENCE","参考文档",5255,"https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Ftypescript\u002Fskills\u002Fderive-types\u002Frepos\u002Fcore.md",{"path":67,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":68,"sourceHtmlUrl":69},"repos\u002Fmetamask-extension.md",6179,"https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Ftypescript\u002Fskills\u002Fderive-types\u002Frepos\u002Fmetamask-extension.md",{"path":71,"resourceType":62,"resourceTypeDesc":63,"sizeBytes":72,"sourceHtmlUrl":73},"repos\u002Fmetamask-mobile.md",7259,"https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Ftypescript\u002Fskills\u002Fderive-types\u002Frepos\u002Fmetamask-mobile.md",[75,83,91,118,138,145],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":82},"01M7B6HMM9ND19MSEXPDW7Q3F8","recipe-plan-and-dispatch","Plan a ticket with the engineer before a recipe fix-bug or dev run. Agree the acceptance criteria and an implementation plan, write it as an approved plan file, and print the prompt that starts the run with any agent and model. Never edits product code or starts the run.","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Fagentic\u002Fskills\u002Frecipe-plan-and-dispatch\u002Fskill.md",[],[],"2026-11-15 14:19:17",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":90},"01M72GPQFVTGCPVK22DSDJXEJY","recipe-library-audit","Run every recipe of a team recipe library on one client with mm-harness, classify each result with the failing node and exact error, and review naming and composability. Produces a per-client table; changes nothing.","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Fagentic\u002Fskills\u002Frecipe-library-audit\u002Fskill.md",[],[],"2026-11-10 22:39:42",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":31},"01M70PKJH3WSTFMSA8VYQWNDW9","recipe-performance","Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold\u002Fwarm\u002Fbackground-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout\u002Fpaint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Fagentic\u002Fskills\u002Frecipe-performance\u002Fskill.md",[],[98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117],"recipe","recipe performance","performance","analysis","app","cold","critical","tasks","react","browser","layout","screen","network","metamask","flow","recipes","deterministic","harness","mm","sentry",{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":31},"01M6CGJ7AEJCZSRGF3PBE6EWBG","x402-payments","Build x402 payment flows using MetaMask Smart Accounts Kit, machine to machine payments over HTTP with ERC-7710 delegations and ERC-7715 Advanced Permissions","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Fweb3-tools\u002Fskills\u002Fx402-payments\u002Fskill.md",[],[125,126,127,128,129,130,131,132,111,133,134,135,136,137],"x402","x402 payments","payments","with","payment","advanced","flows","machine","kit","build","permissions","smart accounts kit","http",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":31},"01M6CGJ4AEKJZJWJ704SZTWQ5T","smart-accounts-kit","Build dApps with MetaMask Smart Accounts Kit — ERC-4337 smart accounts, delegations, and Advanced Permissions (ERC-7715)","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Fweb3-tools\u002Fskills\u002Fsmart-accounts-kit\u002Fskill.md",[],[133,136,135,134,128,130,111],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":31},"01M6CGJ11KGB6862Z1ADYTMKYZ","oh-my-opencode","Multi-agent orchestration plugin for OpenCode. Use when the user wants to install, configure, or operate oh-my-opencode — including agent delegation, ultrawork mode, Prometheus planning, background tasks, category-based task routing, model resolution, tmux integration, or any oh-my-opencode feature. Covers installation, configuration, all agents (Sisyphus, Oracle, Librarian, Explore, Atlas, Prometheus, Metis, Momus), all categories, slash commands, hooks, skills, MCPs, and troubleshooting.","https:\u002F\u002Fgithub.com\u002FMetaMask\u002Fskills\u002Fblob\u002Fmain\u002Fdomains\u002Fweb3-tools\u002Fskills\u002Foh-my-opencode\u002Fskill.md",[],[152,153,154,155,156,157,158,159,105,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177],"oh my opencode","my","opencode","hooks","explore","model","momus","code","ultrawork","install","multi-agent","tmux","prometheus","planning","use","orchestration","categories","operate","mode","metis","configure","when","oracle","agent orchestration","librarian","delegation"]