agentleFS
LedgerHQLedgerHQ/ledger-live/.agents/skills/data-layer-advanced/SKILL.md

data-layer-advanced

Skill627 starsChanged 7 days agoMITView on GitHub

Structure a Ledger Wallet data layer where one API response serves several entities. Use when creating or reviewing cross-entity domain/api orchestration with RTK Query, createAsyncThunk, or both, including response validation and tests spanning multiple domain/entity packages.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Keep UI and feature state in features/flow.

    line 22
  2. Distinctive:

    Keep app composition out of the domain package.

    line 23
  3. Distinctive:

    Keep the result in RTK Query or dispatch the validated entities when slices must be hydrated.

    line 29
  4. Distinctive:

    Use entity mock builders when available.

    line 35
  5. Distinctive:

    Test RTK Query endpoints, thunks, or their integration according to the chosen orchestration.

    line 36
  6. Distinctive:

    When reducers are involved, create a minimal local store or use an existing domain test harness.

    line 37
  7. Distinctive:

    Never import an app store or app alias into a domain test.

    line 38

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

Data Layer: Multiple Entities

Apply only when one API response maps to several autonomous entities. Use domain-data for the rules inside each entity and api package.

Source: Data Layer Advanced Use Case

Split Ownership

domain/entity/<first>/src/schema.ts
domain/entity/<second>/src/schema.ts
domain/api/<orchestrator>/src/api.ts
  • Let each entity own its schema and inferred type. Add state, selectors, mocks, and tests only when that entity needs them.
  • Let one domain/api package own the cross-entity response contract, request, transformation, and validation.
  • Keep UI and feature state in features/flow.
  • Keep app composition out of the domain package.

Process The Response

  1. Fetch with RTK Query, createAsyncThunk, or both.
  2. In the API layer, validate and transform each response collection with its owning entity schema.
  3. Keep the result in RTK Query or dispatch the validated entities when slices must be hydrated.

Validate the collection before iterating over it: prefer entitySchema.array().parse(value) to .map() on untrusted data.

Test The Orchestration

  • Use entity mock builders when available; otherwise build schema-valid fixtures.
  • Test RTK Query endpoints, thunks, or their integration according to the chosen orchestration.
  • When reducers are involved, create a minimal local store or use an existing domain test harness.
  • Never import an app store or app alias into a domain test.
  • Assert the validated result, cache entry, and any hydrated slice that the orchestration owns.
  • Cover transport failure, invalid collection shape, and invalid entity data when relevant.

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.