Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro
Skip to content

NewMCP server for your coding agent. Set it up ›

The Best UI Library for Claude Code: Setup, Prompts and CLAUDE.md

What a UI library needs to work well with Claude Code and other coding agents, three ways to connect one (CLI, MCP server, build prompts), a CLAUDE.md to copy, and the mistakes that produce generic pages.

Ask a coding agent for a landing page and you usually get the same one: a centred headline, a gradient blob, three identical cards. The agent is not being lazy. With no library to draw on, it writes every component from scratch, and from-scratch output regresses to the average of everything it has seen.

The fix is not a cleverer prompt. It is giving the agent a UI library it can install from, read and follow. This guide covers what makes a library work well with Claude Code (and Cursor, Codex and similar agents), three ways to connect one, a CLAUDE.md you can copy, and the mistakes that bring the generic pages back. The examples use Nexus UI, which we make, so read the product-specific parts with that in mind. The ideas apply to any library.

What an agent needs from a UI library

An agent is a fast developer with no eyes and no memory of your project. That changes what counts as a good library:

  1. A command, not a copy-paste. If adding a component means opening a website and copying code, the agent cannot do it. If it is npx shadcn@latest add name, the agent can run it in one step.
  2. Source it can read. Copy-in libraries write plain React and Tailwind into your repo, so the agent reads the real file, sees the real props and edits it like anything else you wrote. A component hidden inside node_modules is harder to adjust.
  3. Predictable names and props. The agent will guess. Consistent naming, typed props and sensible defaults mean fewer wrong guesses.
  4. A way to find things by purpose. "A pricing section with a monthly and yearly switch" should lead somewhere, whether that is search, a catalogue the agent can read, or an MCP server.
  5. A written brief for rebuilding. Sometimes you do not want the component, you want the idea adapted to your stack. A build prompt, a precise description of structure, props and motion, covers that.

Route 1: install with the shadcn CLI

Nexus UI is a shadcn registry, so any agent that can run a shell command can use it. Connect the registry once, in a project where npx shadcn@latest init has already created components.json:

npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

Leave {name} exactly as written. After that, the agent installs by name:

npx shadcn@latest add @nexus-labs/glow-button
npx shadcn@latest add @nexus-labs/pricing-section

The CLI writes the files under your components folder and installs the packages they declare, such as framer-motion. Free items need nothing more. Pro items need an API key kept in .env.local and a header in components.json; the CLI guide has the exact steps. Never paste the key into a prompt or commit it.

Route 2: connect the MCP server

The CLI answers "install this named thing". An MCP server answers "what do you have for this?". With the server connected, the agent can search the library by description and then fetch a component's files and install command itself, so you can ask for what you want in plain words.

In Claude Code, run this once in your project folder:

claude mcp add --transport http nexus-ui https://www.nexus-ui.com/api/mcp

Free components work with no account. For Pro components, add your API key as a header:

claude mcp add --transport http nexus-ui https://www.nexus-ui.com/api/mcp \
  --header "Authorization: Bearer nxs_your_key_here"

Setup for Cursor, VS Code and Codex is on the MCP server page. The shadcn project also publishes its own MCP server, which is worth connecting for the base components; the two sit side by side without conflict.

Route 3: build prompts

Many Nexus UI components and sections have a build prompt: the stack, file layout, props, motion and edge cases written out as a brief. Hand it to the agent when you want the component built into your own conventions rather than dropped in as-is, for example in a project that does not use Framer Motion. Look for Build prompt on a component or block page. It is free on free components and part of Pro on Pro ones.

There is also a plain-text overview for AI tools at /llms.txt.

Write a CLAUDE.md that makes the agent use the library

Without instructions, an agent will often install a component and then rewrite half of it, or reach for a second animation library. A short CLAUDE.md in the project root prevents both. Claude Code reads it at the start of every session, so keep it brief and concrete.

# UI

- Build UI with Nexus UI components before writing new ones. Search the nexus-ui MCP
  server first; install with `npx shadcn@latest add @nexus-labs/<name>`.
- Installed components live in `src/components/<name>/`. Change their props and
  classes through usage, and edit the file only when the usage cannot do it.
- Animation uses framer-motion. Do not add another animation library.
- Use the colour tokens in `app/globals.css`. Do not hard-code hex values.
- Respect `prefers-reduced-motion` in anything you write.
- After adding a component, run the type check and the linter.

Cursor reads rules from .cursor/rules or an AGENTS.md, and Codex reads AGENTS.md, so the same text works there under the right file name.

Prompts that work

Name the thing, say where it goes, and say what to keep. Compare these:

  • Vague: "Make the pricing page look better."
  • Specific: "Add the @nexus-labs/pricing-section block to app/pricing/page.tsx. Use our three plans (Free, Team, Enterprise) from lib/plans.ts, keep our existing colour tokens, and run the type check when you are done."

Three habits make the difference. Give the data, because agents invent plausible plans and numbers when you do not. Say what must not change, so existing tokens and routes stay put. And ask for one section at a time, since a whole page in one prompt is where the generic layout comes back.

Mistakes that bring back the generic page

  • Letting the agent rewrite the component. If the installed file does what you need, change how you use it. A rewrite throws away the part you chose the library for.
  • Adding a second animation or UI library. Two motion systems on one screen fight each other. State the one you use in CLAUDE.md.
  • Hard-coded colours and sizes. The agent will invent hex values unless pointed at your tokens.
  • No data. Placeholder copy and made-up figures make every page feel the same. Pass real content.
  • Skipping the check. Ask the agent to run the type check and linter after each addition, and look at the result in the browser yourself. A passing build does not mean it looks right.

So which library is best

There is no single answer, but you can test any candidate against the five needs above: can the agent install it by command, read its source, guess its props, find things by purpose and rebuild from a brief. A library that fails the first one will always need a human in the loop.

If you are still choosing a base, see the best React component library and the shadcn/ui alternatives. For the rules that make an agent's animation code good, read our Framer Motion skill for Claude Code, and the product pages at /claude-code and /mcp have the setup in one place.

Frequently asked questions

What is the best UI library for Claude Code?

The best one is the one the agent can install with a single command, read as plain source and find by description. Copy-in libraries on a shadcn registry meet the first two by design, and an MCP server adds the third. Nexus UI is built that way, and shadcn/ui itself works well too.

Can Claude Code install Nexus UI components?

Yes. Claude Code can run npx shadcn@latest add @nexus-labs/<name> after the registry is connected, or find the component through the MCP server and install it from there. Free components need no key. Pro components need an API key from your dashboard.

Does Claude Code need an MCP server to use a UI library?

No. The shadcn CLI route works with only a shell. The MCP server is an addition that lets the agent search by description instead of you naming the component.

How do I stop Claude Code building the same landing page every time?

Give it a library to build from, real content to put in, and a CLAUDE.md that says to use that library and not to rewrite its components. Ask for one section at a time and name the component you want.

Is Nexus UI free to use with Claude Code?

Some components are free and need no account. The rest are Pro and need a Pro plan with an API key, which works for the CLI and the MCP server. Build prompts are free on free components and part of Pro on the rest. Current prices are on the pricing page.

Does this work with Cursor and Codex too?

Yes. The CLI is the same shell command in any agent. The MCP server is configured through each tool's own settings file, and the rules file is .cursor/rules or AGENTS.md instead of CLAUDE.md. Setup for each is on the MCP server page.

Where should the API key go?

In .env.local, which a new Next.js project already ignores in git, and read from the environment by the CLI or the MCP configuration. Never put the key in a prompt, a committed file or a screenshot.

Build it with the components from this guide.