Creating a Shared Library
Use the create-shared-library skill to scaffold a shared component library for your micro-apps: one versioned npm package of React components, hooks, and utils that every one of your widgets installs. The skill creates the GitLab project in your group (next to your micro-apps), renames the package, verifies it, and publishes the first release.
For what a shared library is, how it's structured, and how to grow it by hand, see Creating a Shared Library in Widget Development.
Prerequisites
You should already have:
- Completed Step 1 of the AI Quickstart Getting Started (authenticated with
glab). - Maintainer access on the GitLab group the library will live in. The skill needs it to clean up the template's history before the first release.
- The
create-shared-libraryskill installed. At the Claude Code prompt:Then restart Claude Code./plugin install create-shared-library@invent-skills
Create the library
In your terminal, cd into a clean directory where the new repo can be cloned, then start Claude Code there:
cd ~/projects
claude
- At the Claude Code prompt, describe what you want in natural language. For example:
create a shared component library
- Answer the prompts:
- Group: your GitLab group, the one that holds your micro-apps.
- Vendor: Claude proposes one based on the group; confirm or correct it. It becomes part of the package name and can't be changed once published.
- Library name: defaults to
shared-components. - Description: what the library contains.
- Claude shows the result before creating anything, for example:
Approve to proceed.Project: acme-shared-componentsPackage: @invent/acme-shared-components
- Grant permission for each command Claude runs. The skill creates the GitLab project, clones it locally, sets it up, runs a 10-point verification (build, tests, lint, Storybook, and package configuration), and pushes the scaffold to
master, which publishes version1.0.0.
When the skill finishes, check the release:
npm view @invent/acme-shared-components version # 1.0.0
Use the library in a micro-app
In the micro-app that should use the library, install it like any other @invent package:
cd ~/projects/widgets-acme-client-summary
npm i @invent/acme-shared-components
This adds it to the micro-app's package.json dependencies. Then import from the package root:
import { GreetingCard } from '@invent/acme-shared-components';
The micro-app also needs the library's peer dependencies: @invent/tailwind-integration, react-query, and react-use. If npm reports any as missing, install them the same way. To pick up a newer release of the library later, run npm i @invent/acme-shared-components@latest.
For registry auth and the full list of requirements, see Using your library in a widget.
Validate an existing library
To check a library at any time, for example when a component you added can't be imported, run this inside the library's directory:
/create-shared-library:validate
The most common finding is a component that isn't exported from the top-level index.ts. The library's barrels use named exports, so every new component must be listed in all three. See Adding a component.
After scaffolding
From here on, master is protected, and every merge to it publishes a new version. Make all changes on a branch and open a merge request with the gitlab-mr skill; see Creating an MR. Use feat: and fix: commit prefixes, and mark breaking changes with feat!: so they're released as a new major version.