# How do I reuse app code units?

Checked 2026-11-15 against GilbApp d5296208bbffa2ab70076e6194f5537c4be1ddf7.

Search the code library, read the unit's reference, clone the repository at its commit, install it with its peers, and prove it.

## Before you start

Git and [Node.js](http://support.gilb.com/help/how-do-i-install-nodejs-and-check-which-version-i-have) on your computer, and an app written in React and TypeScript.

## Steps

1. Search the code library for the unit you need.

   Search the reference documents of the App Builder vault, with no token, by words in the unit's title or tag:
   GET https://appbuilder.gilb.com/base/search?q=&lt;words\>&amp;type=ReferenceDocument&amp;vault=https://appbuilder.gilb.com/base

   A code unit is a ready piece of app code, such as a card, a picker or the sign-in card, kept in its own folder. The GilbPlatformCode Library is a standards group in that vault with one reference document per unit; a document is in it when its partOf is https://appbuilder.gilb.com/base/e/gilbplatformcode-library-06gjdp49a9sm10t4hgdme4agwm. The search answers only addresses, 20 a page, and also finds documents that are not units. In GilbApp the library shows under "Standards", "References" only if you have been [given access to the App Builder vault](http://support.gilb.com/help/how-do-i-get-access-to-a-vault-someone-else-owns). Do not search GitHub to learn that no unit exists.
2. Read the unit's reference document.

   Read the document's exhibit, with no token, and note the GitHub folder and the commit it gives:
   GET https://appbuilder.gilb.com/lws/referencedocument/&lt;id\>/exhibits

   &lt;id\> is the last part of the address the search gave. The exhibit says what the unit does and gives its GitHub folder, such as units/value-card, the commit, the package name and the clone address. The document's unitTag names the kind of unit, such as t:Value.card, and its appliesTo line says when to take it, or which unit to take instead.
3. Clone the repository at the unit's commit.

   Clone the code repository, go into its folder and check out the commit the exhibit gave, one line at a time:
   git clone https://github.com/KaiGilb/GilbPlatformCode.git
   cd GilbPlatformCode
   git checkout &lt;commit\>

   The repository is public. Read the unit's README in its folder first, above all "What the host must supply": some units need your app to hand them its reads and writes.
4. Install the unit and its peers in the order printed.

   Print the install line for the unit, in the GilbPlatformCode folder, and run the npm install line it prints in your app:
   node scripts/peers.mjs &lt;unit\>

   A unit's peers are the other units it needs, installed before it. The units are not on the npm registry; they are installed from the folders of your clone. Put install-links=true in your app's own .npmrc, so each unit is installed as a copy and not a link. The package ships TypeScript source, which your bundler compiles, and React 19 is a peer.
5. Prove the unit before you rely on it.

   Run the unit's proofs in the GilbPlatformCode folder; the script says PASS or where it failed:
   node scripts/proof.mjs &lt;unit\>

   It runs npm ci and npm test, then the type check and the check that the unit names no host, when the unit has them. With --changed &lt;base ref\> --with-dependents it also proves every unit built on a changed one. The same check runs on every change to the repository, on Node 22.
6. Check where the unit came from, if you need to.

   Read the unit's unit.json, then check every unit's record against its README and package:
   node scripts/manifest.mjs check

   A unit copied from GilbApp carries a unit.json that records where it came from: the repository, the commit and the lines. The script answers exit 0 for a pass, 1 for a fail and 2 for bad input. Whether that source has changed in GilbApp since the copy is checked by scripts/drift.mjs, which needs a clone of GilbApp's own code; that code is private, so you cannot run that check.

## Deeper

Also asked:

How do I reuse ready-made code units? Search the GilbPlatformCode Library, read the unit's reference document, clone the repository at its commit, install the unit with its peers and prove it. [Ask Kai Gilb in writing](http://support.gilb.com/help/how-do-i-ask-for-licence-permission-and-when-does-it-end) before you ship one.

If you do not code, you need none of these steps. Agent.Coder, the agent that builds apps, does them for you [when it builds your app](http://support.gilb.com/help/how-do-i-build-an-app-with-an-ai-coder), so your app can reuse parts others have already built; it records what it searched for and what it chose. The library's code has no licence, so before you ship an app that holds one of these parts, ask Kai Gilb in writing through GilbPlatform, as the note at the end of this answer says.

The repository holds two libraries: units/, React and TypeScript units for apps, and web-units/, Vue 3 and Nuxt 3 units for websites, found through the GilbWebsiteCode Library instead. A unit you take is a copy: when the library changes, you take the new commit yourself.

Agent.Coder, the agent that builds apps, looks in this library before it writes any new piece of code. An agent is your AI following one written procedure, its standing instructions, for one kind of work.

The repository's code has no licence; the repository holds no licence file. The library's reference documents carry GilbPlatform.Licence, which lets GilbPlatform customers, their apps and their AI read, follow and run them inside GilbPlatform. Neither says you may copy a unit's code into an app of your own: ask Kai Gilb in writing through GilbPlatform before you ship one \(GilbPlatform.Licence.Permission\).

Source: KaiGilb/GilbPlatformCode 7a40fd01 \(head of main, public, read with gh api 2026-11-11\): README.md:5 \(the repository is the code home, not the search; search References in the App Builder vault; "Do not search GitHub to learn that none exists"\), :9 \(clone\), :13-14 \(units/ apps, web-units/ websites, two libraries\), :20-26 \(peers.mjs prints the npm install line\), :28-36 \(proof.mjs: npm ci, npm test, typecheck, check:host-agnostic; --changed --with-dependents\), :38-61 \(unit.json, manifest.mjs check, exit 0/1/2\), :65-75 \(drift.mjs needs a local clone of the private app repo\); units/value-card/README.md:45-63 \(install-links=true in .npmrc; TypeScript source; React 19 peer\); units/value-card/package.json:4 \("private": true, not on a registry\); .github/workflows/units.yml:1-36 \(proofs on every pull request and push, Node 22\); git tree at 7a40fd01: 406 entries under units/; repo licence: none \(gh api .license null; re-read 2026-11-11: license null, private false; no LICENSE file\). GilbPlatform.Licence \(A 06gj9wh899wc7cbn72ek2q8pgc, pack GilbPlatformAuthorStandard, 2026-11-11\): rules 2 Subscribers, 5 StayInVault, 11 Permission \("For any use these terms do not allow, ask Kai Gilb in writing through GilbPlatform. Nothing else is allowed unless Kai Gilb allows it in writing."\), 12 YourWork \("These terms cover the standards themselves"\): the licence covers the reference documents, not the repository's code, so neither gives a right to copy a unit into an app. Rule\_Code\_gilbplatformcode-chooser-search \(A 06gjdq7m01y1sc3qrfevnpy5rc, 2026-11-11\) RuleGpccodeSearchChooserFirst \(by t: tag and words; "the References screen of appbuilder"\), RuleGpccodePresentOrRefuse \(steward's note; "What the host must supply"; take from the GitHub folder at the commit\), RuleGpccodeNoGitHubAsLibrary; Agent.Coder.GilbStack item 7. Public reads, no token, 2026-11-11: https://appbuilder.gilb.com/base/search?q=card&amp;type=ReferenceDocument&amp;vault=https://appbuilder.gilb.com/base -\> 200 count 57; https://appbuilder.gilb.com/lws/referencedocument/06gr3xrm21y272ecwnpm7mxgvc/exhibits -\> 200 \(partOf the library, unitTag t:ScreenCard.plan, exhibit with GitHub folder, Commit, Package, Clone\); https://appbuilder.gilb.com/lws/vault/&lt;appbuilder\>/references -\> 403 \(listing closed; search and single reads open, directReader PublicGrantee\). The example find-units.ts was run as plain JS against production: 20 units for "value card". Rows: Developer.FindCodeUnitInLibrary, ReuseAppCodeUnits, ProveCodeUnit, CheckCodeUnitOrigin. Agent.Coder \(GilbStack item 7: look up the GilbPlatformCode Library before writing any new unit; record what you searched and what you chose; BeforeStarting 5\).

## For developers

### TypeScript: find-units.ts

```typescript
// Search the GilbPlatformCode Library. No token: the App Builder vault can be read by anyone.
const APPBUILDER = "https://appbuilder.gilb.com";
const LIBRARY = `${APPBUILDER}/base/e/gilbplatformcode-library-06gjdp49a9sm10t4hgdme4agwm`;

export async function findUnits(words: string) {
  const q = new URLSearchParams({ q: words, type: "ReferenceDocument", vault: `${APPBUILDER}/base` });
  const found = await (await fetch(`${APPBUILDER}/base/search?${q}`)).json();
  const units: { title: string; tag: string; exhibit: string }[] = [];
  for (const id of found.ids as string[]) {
    const tail = id.slice(id.lastIndexOf("/") + 1);
    const doc = await (await fetch(`${APPBUILDER}/lws/referencedocument/${tail}/exhibits`)).json();
    if (doc.reference?.partOf?.["@id"] !== LIBRARY) continue; // not a unit of the app library
    units.push({ title: doc.reference.title, tag: doc.reference.unitTag, exhibit: doc.exhibits[0]?.referenceExhibit });
  }
  return units; // each exhibit gives the GitHub folder, the commit and the package
}
```
