Devtools import boundary

From LedgerHQ/ledger-live · View interactive version

Devtools import boundary is an AI agent skill from the GitHub repository LedgerHQ/ledger-live. Enforce import boundaries inside the devtools scope. Use when doing any work in "devtools/**".

How to use this skill

Skill file

DevTools import boundaries

Every @devtools/* package is self-contained. A @devtools/* package may import another one only where CODE2 allows it, and pnpm lint:boundaries enforces it:

To change what a package may import, edit those tables.

Rules for the registry and the host apps

  1. The registry reaches tools lazily (DEVTOOLS_LAZY_RULE). The shell loads @devtools/registry eagerly, so the registry may reach a tool only through import type, export type … from, typeof import("…") or loader: () => import("@devtools/<tool>"). A value import or require() bundles the tool with the shell.
  2. App product code does not import @devtools/* (DEVTOOLS_HOST_APP_RULE). In each app of DEVTOOLS_HOST_APPS, only files under allowedUnder (src/mvvm/features/DevTools/) may import @devtools/*, type imports included. A product hook calling a bindings hook, or a product type derived from DevToolsConfig or a bindings port type, belongs in that folder.
  3. Product code enters the DevTools folder through its entries (DEVTOOLS_HOST_FOLDER_RULE). A file outside allowedUnder may reach only the files listed in entries, through a static import, import() or lazy(() => import(...)) alike. A lazy import of any other file would still make product code depend on a tool module at runtime. To lazy-load a new screen of the folder, add it to entries. The rule resolves relative paths and the aliases of the app's tsconfig.json (LLD/*, LLM/*, ~/*). Test files (*.test.*, __tests__/, __integrations__/) are exempt.

What lint cannot catch

Why

The devtools architecture decouples tools from the shell through the registry. The shell lazy-loads tools via metadata.loader; tools never know the shell exists. If a tool imports the shell or another tool directly:

bindings builds each tool's props, so it needs a tool's props types without loading the tool. That is what DEVTOOLS_TYPE_ONLY_IMPORTS grants it.

If bindings or shell import a tool package's values directly (instead of through the registry):

Consequences of a violation

Correct pattern

Cross-cutting concerns (shared types, utilities) must not live in a tool package. Extract them to a standalone library with no @devtools/* scope, then import that from whichever packages need it.

App state and wiring for a tool arrive as props, built in @devtools/bindings — the single sanctioned bridge to Ledger Live internals. A tool that needs more data from the app gets new props, not a new import.

Documentation

When adding a new package under devtools/, its README.md must state:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.