agentleFS
LedgerHQLedgerHQ/ledger-live/.agents/skills/coin-families-contract/SKILL.md

coin-families-contract

Skill628 starsChanged 5 days agoMITView on GitHub

Coin-specific families logic must live in families/. Generic UI uses the families contract only (no if (family === "evm") in shared code). Use when working in "**/families/**", "**/mvvm/**", "**/renderer/**" and "**/screens/**".

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Desktop: Add an optional property to LLDCoinFamily in apps/ledger-live-desktop/src/renderer/families/types.ts (e.g.

    line 25
  2. Very specific:

    Mobile: Use the same idea: a typed contract (or generated map like noAssociatedAccountsByFamily) that families can optionally fill.

    line 26
  3. Very specific:

    Put the component or logic in families/<family>/ (e.g.

    line 30

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

Coin families contract (Desktop & Mobile UI)

Principle: Coin-specific UI and behavior must live in families/. Generic screens, hooks, and components must not branch on family === "evm" (or any family name). They must use the families contract: optional slots defined in the family type, implemented per family, and consumed via a single lookup (e.g. useLLDCoinFamily(currency.family).SlotName). This keeps generic code family-agnostic and supports modularisation and lazy loading.

Do not do (anti-patterns)

  • Generic code (outside families/<family>/):
    • if (currency.family === "evm") / if (transaction.family === "solana") to render or behave differently.
    • Coin-specific hooks or logic in shared ViewModels / screens (e.g. Canton onboarding branch inside a generic Scan Device VM).
    • Importing a specific coin module (e.g. @ledgerhq/coin-canton) in generic UI to branch on that coin.
  • Exception: Type-narrowing inside a family folder (e.g. invariant(transaction.family === "bitcoin", "...") in families/bitcoin/) is acceptable; the rule applies to generic (shared) code only.

Do (correct pattern)

  1. Define a slot on the contract

    • Desktop: Add an optional property to LLDCoinFamily in apps/ledger-live-desktop/src/renderer/families/types.ts (e.g. NoAssociatedAccounts?: React.ComponentType<...>).
    • Mobile: Use the same idea: a typed contract (or generated map like noAssociatedAccountsByFamily) that families can optionally fill.
  2. Implement only in the family

    • Put the component or logic in families/<family>/ (e.g. families/hedera/NoAssociatedAccounts.tsx) and add it to the family object (Desktop: the default export of families/<family>/index.ts, loaded on demand through loaders.ts; Mobile: in the generated aggregation if applicable).
  3. Use the contract in generic code
    • Generic code looks up by family and uses the slot if present, with no if (family === "hedera"):
    • Desktop: useLLDCoinFamily(currency.family).NoAssociatedAccounts → use it when defined. The hook lives in apps/ledger-live-desktop/src/renderer/families/useLLDCoinFamily.ts and is imported from ~/renderer/families. It suspends while the family chunk loads, so it needs a <Suspense> boundary above it. Outside React, importLLDCoinFamily(name) from the same module returns a promise.
    • Mobile: e.g. getCustomNoAssociatedAccounts(currency) returning a component from a family map, then pass it to the screen (e.g. as CustomNoAssociatedAccounts in route params).

Reference example: Scan Device "no associated accounts"

  • Contract (Desktop):
    apps/ledger-live-desktop/src/renderer/families/types.ts — NoAssociatedAccounts?: React.ComponentType<AddAccountsStepProps> on LLDCoinFamily.
  • Family implementation:
    apps/ledger-live-desktop/src/renderer/families/hedera/NoAssociatedAccounts.tsx and hedera/index.ts exporting it in the family object.
  • Generic usage (Desktop):
    apps/ledger-live-desktop/src/mvvm/features/AddAccountDrawer/screens/ScanAccounts/useScanAccounts.ts: useLLDCoinFamily(currency.family).NoAssociatedAccounts, with no Hedera-specific branch.
  • Generic usage (Mobile):
    useScanDeviceAccountsViewModel.ts: getCustomNoAssociatedAccounts(currency) from ~/generated/NoAssociatedAccounts; result passed as CustomNoAssociatedAccounts to the NoAssociatedAccounts screen. No if (family === "hedera") in the VM.

When you need new coin-specific behavior in a generic flow (e.g. post-add-account navigation, custom empty state): extend the contract (add a new optional slot and document it), implement it in the relevant family folder, and have the generic code only read from the contract. Do not add new if (family === "…") branches in shared UI.

Paths

  • Desktop: apps/ledger-live-desktop/src/renderer/families/: contract in types.ts, implementations per family, one dynamic import per family in loaders.ts, lookup through useLLDCoinFamily; generic code under renderer/, mvvm/.
  • Mobile: apps/ledger-live-mobile/src/families/ — family-specific UI and flows; generic code under mvvm/, screens/. Use generated maps or a small helper (e.g. getCustomNoAssociatedAccounts) so generic code never branches on family name.

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.