راه‌اندازی ایجنت

چند سؤال دربارهٔ پروژه‌ات جواب بده و هرچه ایجنت برای ساختن با دیگ لازم دارد بگیر: دستور نصب، کانفیگ MCP دیگ و دیگچه، فایل قواعدی که ایجنت اول می‌خواند، DESIGN.md و brand.css. از این به بعد ایجنت فونت و رنگ را حدس نمی‌زند و کامپوننت دست‌ساز نمی‌سازد.

۱. ایجنتت را با محصولت آشنا کن

این چند انتخاب یک بار در فایل قواعد ثبت می‌شود. از آن به بعد ایجنت هر صفحه را با همین رنگ، فونت و گردی می‌سازد و دیگر درباره‌شان سؤال نمی‌پرسد.

با کدام ایجنت کد می‌نویسی؟

کد رنگ را بنویس یا روی مربع رنگی بزن و از پالت انتخاب کن. اگر خالی بماند، رنگ پیش‌فرض دیگ استفاده می‌شود.

فونت فارسی
گردی گوشه‌ها
حالت تیره

۲. دیگ را نصب کن

در ریشهٔ پروژه اجرا کن. تم و توکن‌ها را نصب می‌کند و صفحه را راست‌به‌چپ می‌کند.

npx digdesign@latest init

۳. ایجنت را به دیگ و دیگچه وصل کن

دیگ کامپوننت، بلاک و توکن می‌دهد و دیگچه آیکون. هر دو عمومی‌اند و توکن نمی‌خواهند.

claude mcp add --transport http dig https://docs.digdesign.ir/api/mcp
claude mcp add --transport http digche https://icons.digdesign.ir/api/mcp

۴. این فایل‌ها را در ریشهٔ پروژه بگذار

با هر تغییر به‌روز می‌شود

ریشهٔ پروژه یعنی پوشهٔ اصلی پروژه، همان‌جا که فایل package.json قرار دارد. هر فایل را با همان نامی که روی زبانه‌اش نوشته شده بساز و متن را داخلش کپی کن.

  • CLAUDE.md: ایجنت پیش از هر کاری این فایل را می‌خواند، پس فونت و رنگ را دوباره نمی‌پرسد. اگر از قبل داری، این متن را به انتهایش اضافه کن.
  • DESIGN.md: رنگ‌ها، فونت و قواعد طراحی محصولت، برای هر ایجنتی که به MCP دیگ وصل نیست.

اگر ایجنتت به MCP دیگ وصل است، لازم نیست این‌ها را دستی بسازی: کافی است بگویی «پروژه را برای دیگ راه‌اندازی کن» تا خودش همین فایل‌ها را بسازد.

CLAUDE.md
<!-- dig:start (generated by Dig; edit outside this block) -->
# This product: UI rules for coding agents

This product is built on Dig, a Persian right-to-left design system. Read this file before writing any UI.

## Decisions already made

- Font: IRANSansX. Load it with next/font/local with the licensed font files and set it once in brand.css through --font-anchor. Do not ask the user again.
- Brand color: Dig default. If the user later gives a brand color, call customize_theme once and replace brand.css.
- Corner radius: Dig default. Containers use rounded-xl, controls keep their default radius.
- Dark theme flavor: blue. Set data-dark-theme="blue" on <html>.
- Design tokens and component rules for this product are in DESIGN.md next to this file.

## Tools

- Dig MCP (`dig`): components, blocks, tokens, page patterns, contrast checks and code review.
- Digche MCP (`digche`): icons. Pick icons by meaning with recommend_icons; never draw an SVG by hand.

## How to work

Dig is a Persian, right-to-left (RTL) React + Tailwind design system.
Before building any UI with Dig, the project must be set up once:
1. Run `npx digdesign@latest init`: it installs the theme (all color, spacing, radius, shadow and type tokens) and utils. Without the theme, components render with wrong font sizes, colors and spacing.
2. The root element must have lang="fa" dir="rtl".
3. First read the project's CLAUDE.md, AGENTS.md or GEMINI.md: if it already records Dig decisions (font, brand color, radius), follow them and do not ask again. Otherwise, before choosing a font, ask the user which Persian font they want: IRANSansX (Dig default), IRANYekan or Vazirmatn. If the user has no preference or does not answer, use IRANSansX; the theme already defaults to it. Load the chosen font (next/font/local for licensed IRANSansX/IRANYekan files, next/font/google for Vazirmatn) and set it once in brand.css as `:root { --font-anchor: var(--font-<name>), "<Family>"; }`. Every Dig component reads the font from this anchor; never set fontFamily or font-[…] on body or individual components.
4. If the product has its own brand color, ask for it. Then call setup_project once (font, brand, radius, dark_theme) and write every file it returns: the instructions file that records these decisions, DESIGN.md and brand.css. brand.css guarantees contrast. Never paste the brand hex into components.
5. For a whole page, check list_blocks (or the `blocks` in search results) first and start from get_block when one fits; never ship a block as-is, work through its `adapt` checklist.
6. Before composing any page, call get_page_patterns with the page you are building and follow its rules (layout, spacing hierarchy, uniform radius and control size, tabs for single choice, bold marketing heroes, Persian data). They keep pages modern and consistent even when no block fits.
Rules while building:
- Use Dig components for every control; never hand-roll a native <select>, input or button when a Dig component exists. Find them with search_components (a whole page like «صفحهٔ ورود» or dashboard also works and returns the components that page needs), then call get_component_demo for correct usage, its `api` (allowed props and values) and `requirements.install`; its snippets are complete code with imports. Never use a prop or variant value that is not in `api`.
- Never write raw hex colors or pixel values; call get_tokens and use its Tailwind classes. For any custom color pair, verify it with check_contrast.
- For form fields use TextField with label, description, required or optional props instead of composing labels by hand.
- Use logical properties (ms-, me-, ps-, pe-, start-, end-), never left/right, so layouts stay correct in RTL.
- All controls on a screen share one size (sm, default, lg or xl). Wrap the page or form in <ControlSizeProvider size="…"> from @/components/ui/control-size instead of passing size to each control, and never change a control's height with className (h-12, h-[48px]). Button, Input, TextField, SearchField, Select, DatePicker, NumberField and Toggle all follow the provider.
- Never show disabled state with opacity; Dig controls already change color when disabled.
- After building a screen, pass its code to review_code and fix every finding before showing it to the user.
<!-- dig:end -->

۵. اولین درخواست

این را به ایجنت بده. اگر از بلاک ورود شروع کرد و در پایان review_code را صدا زد، همه‌چیز درست وصل است.

با MCP دیگ یک صفحهٔ ورود با رمز یک‌بارمصرف بساز؛ اول list_blocks را ببین و از بلاک مناسب شروع کن، آیکون‌ها را از دیگچه بگیر و در پایان کد را با review_code بازبینی کن.