راهاندازی ایجنت
چند سؤال دربارهٔ پروژهات جواب بده و هرچه ایجنت برای ساختن با دیگ لازم دارد بگیر: دستور نصب، کانفیگ 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 دیگ وصل است، لازم نیست اینها را دستی بسازی: کافی است بگویی «پروژه را برای دیگ راهاندازی کن» تا خودش همین فایلها را بسازد.
<!-- 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. Font: IRANSansX is the Dig default and what you must use unless the user picks another. `npx digdesign@latest init` downloads the IRANSansX files from Dig into the project (public/fonts + dig-fonts.css), so the user does not need to supply any font file. Never choose Vazirmatn or any other font on your own, and never substitute next/font/google for it. In order: (a) read the project's CLAUDE.md, AGENTS.md or GEMINI.md; if it records the font, brand color or radius, follow it and do not ask again. (b) If the project already has font files or a --font-anchor, keep using them. (c) Otherwise use IRANSansX via init; only offer IRANYekan or Vazirmatn if the user asks for another font (init --font yekan|vazirmatn). Never fall back silently to the system font. Verify with getComputedStyle that the rendered family is the chosen one. Every Dig component reads the font from `--font-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 (pass `query`, results are paged; 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. Blocks are written in React. For a Vue, Svelte, Angular or Android project pass `framework` to list_blocks (`buildable_only` hides what cannot be built yet) and to get_block: you get the React code as `reference_code`, the `imports` and `install` for that framework, what is `missing`, and `translate` rules; build the same page with that framework's own components, never paste the React code, and tell the user about anything `missing`.
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.
Android (Jetpack Compose, the `:dig` module): every rule above has an Android equivalent unless the platform makes it meaningless, and review_code enforces them on .kt files (pass each file with its .kt path). Mapping: Dig components instead of the platform's stock controls (no stock Button/TextField/Switch… imported from the `androidx.compose.*` toolkits), tokens from `DigTheme.colors`/`DigSpacing`/`DigRadius`/`DigText` instead of raw `Color(0x…)`, `.dp` and `.sp` literals or the stock theme object, start/end instead of left/right, no `.alpha()` or `Color.Transparent`, one control size via `ControlSizeProvider` instead of `Modifier.height`, Persian text with `toFaDigits` and no Arabic ي/ك, imports only from symbols that exist in `ir.digdesign.compose`. The font: IRANSansX ships inside `:dig` and is the `DigTheme` default, so `DigTheme { }` renders in the right font and needs no setup. Only if the user wants another font (IRANYekan, Vazirmatn) call setup_project with platform="android" and write every file it returns (the instructions file and DigFont.kt); then every screen root is `DigTheme(fontFamily = DigFont) { … }`.
- What a form saves is the field's value, not what it displays: numeric fields show Persian digits whatever keyboard is used but give a Latin value, and Arabic letters are normalized to Persian. Never convert a value with toFaDigits before saving, never turn off normalizeArabic (passwords and one-time codes excepted), and compare or search Persian text only through toSearchKey on both sides. Email and URL fields are always Latin/LTR (type="email"/"url", Android InputMode.Email/Url), phone fields type="tel", and personal-data fields need the right autoComplete (Android: contentType, derived from the mode for email and phone).
Other web frameworks (Vue, Svelte, Angular): the tokens, Tailwind classes, RTL and font rules are the same. Install with `npx digdesign add <name> --framework <vue|svelte|angular>` and pass `framework` to get_component and get_component_demo (and to setup_project) to get that port's file list and its own usage code. If a component is not ported to the framework, the tool says where it exists; tell the user, do not paste the React version. review_code reads .vue, .svelte and Angular files with the same rules.
- After building a screen, pass its full, untrimmed code (several files via `files`, or run `dig review <paths>` locally) to review_code and fix every finding before showing it to the user.
<!-- dig:end -->
۵. اولین درخواست
این را به ایجنت بده. اگر از بلاک ورود شروع کرد و در پایان review_code را صدا زد، همهچیز درست وصل است.
با MCP دیگ یک صفحهٔ ورود با رمز یکبارمصرف بساز؛ اول list_blocks را ببین و از بلاک مناسب شروع کن، آیکونها را از دیگچه بگیر و در پایان کد را با review_code بازبینی کن.