npx skills add ...
npx skills add 21st-dev/skill --skill 21st-ai
Generate and iterate on UI with 21st AI from the terminal via the `21st` CLI (`@21st-dev/cli`): sketch a UI from a prompt, preview the variants in the browser, edit any variant in place with a natural-language change, and pull the final code into the project. Use whenever the user wants to BUILD / SKETCH new UI ("sketch a pricing page", "generate a hero with 21st", "make me a <X> section"), ITERATE on a generated draft ("edit the third variant", "add a toggle to that take"), or GRAB the code of a draft ("pull that variant's code", "сгенери UI на 21st", "поправь третий вариант", "забери код того наброска"). For finding/installing existing components use the `21st-cli-use` skill; to publish your own, `21st-registry`.
npx skills add 21st-dev/skill --skill 21st-ai
21st AI is a fast UI-drafting board. Mental model: draft it here, then finish
it — sketch a few variants from a prompt, preview them, refine the one you like
with plain-English edits, and pull its code into the repo. The whole loop runs
from the 21st CLI (or the matching MCP tools), so you never leave the editor.
Sketch mode produces self-contained HTML + Tailwind drafts (fast, no build). The recommended handoff is the copy-prompt: a spec that tells you to rebuild the design in the target project's real stack — not paste raw HTML verbatim.
Same credential as the rest of the CLI: 21st login (saved token) or a
21st_sk_ key via --api-key / TWENTYFIRST_TOKEN. 21st usage (MCP:
get_usage) shows the account tier, aiGenerationEnabled, and remaining free
daily component-code retrieval quota. It does not report the AI credit balance.
(See the 21st-cli-use skill for the full auth notes.)
Before generating or iterating, check MCP get_usage.aiGenerationEnabled or
the 21st AI generation line from 21st usage. CLI 1.17.1 also supports
21st usage --json. Proceed only when AI is explicitly enabled; missing or
unknown status does not grant access. A base Builder
subscription does not enable AI. When it is false, use search →
get_component and adapt the code with the user's own agent. Do not attempt
generate or iterate_generation, including through the CLI as a fallback.
Open the preview URL (printed by generate, and returned by iterate) in the
editor's built-in browser to watch the variants render and update in place.
--take N to act on.--code prints the raw HTML. Both FREE and unlimited.The same loop is exposed as MCP tools for MCP hosts (Cursor, Claude Desktop,
Claude Code): generate (with mode: "sketch"), get_generation,
iterate_generation and get_take. iterate_generation also returns the
freshly-edited html + copyPrompt, so you can grab the code without a second
call. Wire up the server with 21st init --client <name> --write.
The MCP tool list depends on the account: generate and iterate_generation
are listed only when AI is enabled. get_generation and get_take remain
available for reading existing drafts. After enabling AI, refresh the client's
tool list or reconnect the MCP server. If a cached tool call returns
ai_subscription_required, stop generation attempts and use the component
search and retrieval workflow above.
generation / the "Take N" label in
the preview. --take must be a whole number ≥ 1 (a bad value errors rather
than silently editing take 1).