21st-ai
21st-dev/skill
Generate and iterate on UI variants from the terminal, then pull the code into your project.
What is 21st-ai?
21st AI is a UI-drafting tool that generates multiple design variants from a text prompt, lets you preview and refine them in the browser, and exports the code or a design spec. Use it when you need to quickly sketch new UI components or iterate on existing drafts without leaving the editor.
- Generate multiple UI variants ("takes") from a natural-language prompt
- Preview variants in the browser and see updates in real-time
- Refine any variant with plain-English edits (iterate command)
- Export code as raw self-contained HTML or as a copy-prompt design spec
- List and track generated variants with their render status
How to install 21st-ai
npx skills add https://github.com/21st-dev/skill --skill 21st-ai- 21st CLI installed (@21st-dev/cli)
- Valid 21st account with login via `21st login` or API key
- AI generation enabled on your account (check with `21st usage`)
- For MCP use: MCP client configured with 21st server
How to use 21st-ai
- 1.Run `21st generate "your UI description"` to create variants and open the preview
- 2.Check `21st generation <projectId>` to list the takes and their render status
- 3.Open the preview URL in your browser to see all variants render in real-time
- 4.Run `21st iterate <projectId> "your change" --take N` to refine a specific variant
- 5.Run `21st take <projectId> --take N` to get the copy-prompt (recommended) or `--code` for raw HTML
- 6.Adapt the design spec or code into your project's real stack
Use cases
- Sketch a pricing page with multiple tier layouts and toggle options
- Generate hero sections or landing page components from a description
- Iterate on a generated variant by adding features (e.g., "add an annual toggle")
- Pull the final code or design spec into your project for further customization
- Explore multiple design directions quickly before committing to one
- Frontend developers building UI-heavy projects
- Designers collaborating with developers on component drafts
- Teams using 21st CLI for component management
- Developers who want to stay in the terminal/editor during design iteration
21st-ai FAQ
The copy-prompt is a design spec that tells you how to rebuild the UI in your project's real stack; raw HTML (--code) is self-contained but not recommended for production use. The copy-prompt handoff is the recommended workflow.
Yes. `generate` and `iterate` require AI credits and AI generation enabled on your account. Listing variants (`generation`) and pulling code (`take`) are free and unlimited.
Yes. You can iterate on any take individually, and each iteration appends a new version so you can step back. To start fresh, run `generate` again with a new prompt.
Use the `21st-cli-use` skill to search and fetch existing components instead, then adapt the code with your own agent.
Yes, if your editor supports MCP (Cursor, Claude Desktop, Claude Code). Run `21st init --client <name> --write` to configure the MCP server, then use the `generate`, `iterate_generation`, `get_generation`, and `get_take` tools.
Full instructions (SKILL.md)
Source of truth, from 21st-dev/skill.
name: 21st-ai
description: >-
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.
21st AI — sketch, iterate & grab code from the terminal
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.
Auth
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.
The loop
# 1) Sketch — generate variants ("takes") from a prompt. Opens the preview in
# the browser and prints the projectId.
21st generate "a pricing section with 3 tiers and a monthly/annual toggle"
# 2) List the takes (1-based numbers + whether each has rendered yet).
21st generation <projectId>
# 3) Edit ONE take in place with a natural-language change (PAID — see Metering).
21st iterate <projectId> "make it enterprise-flavored, add an annual toggle" --take 3
# 4) Grab the code to bring into the project (FREE).
21st take <projectId> --take 3 # paste-ready copy-prompt (recommended)
21st take <projectId> --take 3 --code # raw self-contained HTML instead
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.
When to use which
- generate — start fresh from a prompt. Returns a preview URL + projectId.
- generation — list the takes so you know which
--take Nto act on. - iterate — refine an EXISTING take (edited in place; a new version is appended, so you can step back in the workspace). Use this to change something already generated instead of starting over.
- take — pull a take's code. Default prints the copy-prompt (adapt-to-my-
stack spec);
--codeprints the raw HTML. Both FREE and unlimited.
Metering
- generate — requires AI enabled on the account and available AI credits. Builder and Team start with AI off; membership alone does not enable it.
- iterate — billed by real token cost per edit (the shared 21st AI credit pool); it does real model work each call, so batch changes into one clear instruction rather than many tiny ones.
- generation (listing) and take (grabbing code) are FREE.
MCP parity
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.
Tips
- A sketch is a draft, not production code — treat the copy-prompt as a design spec and rebuild it in the project's real components; don't paste the HTML as-is.
- Refer to takes by the 1-based number from
generation/ the "Take N" label in the preview.--takemust be a whole number ≥ 1 (a bad value errors rather than silently editing take 1). - Only sketch generations you created can be listed, edited, or fetched.
Related skills
More from 21st-dev/skill and the wider catalog.

21st-cli-use
Search, install, and generate React/shadcn components, themes, and templates from the 21st.dev catalog via CLI.

review-loop
Iterative worker-reviewer cycle that spawns a critic subagent to score work and provide actionable feedback until a quality gate is met.

dotnet-framework-4.8-expert
Legacy .NET Framework expert specializing in .NET Framework 4.8, WCF services, ASP.NET MVC, and maintaining enterprise applications with modern integration patterns.

machine-learning-engineer
Use when user needs ML model deployment, production serving infrastructure, optimization strategies, and real-time inference systems. Designs and implements scalable ML systems with focus on reliability and performance.

project-manager
Project management expert specializing in planning, execution, monitoring, and closure of projects. Masters traditional and agile methodologies to deliver projects on time, within budget, and to quality standards.

quant-analyst
Expert quantitative finance, algorithmic trading, and financial data analysis with Python statistical modeling.