statechart
ما الذي تفعله
تبني هذه المهارة نموذجًا رسميًا لتدفق منتج أو بروتوكول أو خدمة وتفحصه مقابل القواعد. وهي لمن يريد رؤية الخلل كمسار عبر الحالات.
متى تستخدمها
- ✓عندما يعتمد الخلل على تسلسل من الخطوات أو الشاشات.
- ✓عندما تريد مخططًا لكيفية انتقال النظام بين حالاته.
- ✓عندما تحتاج إلى إثبات أن قاعدة تتحقق، أو المسار الذي يكسرها.
رابط المهارة
https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/statechart/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أرني مخطط الحالات لتدفق الدفع وأقصر مسار يؤدي إلى خصم مزدوج.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يكتب وكيلك مواصفة TLA+ للنظام، ويشغّل فاحص النماذج، ويرسم الحالات كمخطط Mermaid. وإذا انكسرت قاعدة، يعطيك التقرير أقصر تسلسل من الخطوات يسبب ذلك.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Statechart
The chart shows how a system moves between states, in the words of the person who reads it. That person, the reader, decides whether the behavior is right.
Run
Work in a scratch folder outside the repo. Write a TLA+ spec and its config. Then run:
<skill dir>/scripts/statechart SPEC.tla [--config FILE] [--view FILE] [--out DIR]
scripts/statechart.ts is TypeScript, so run it with a runtime that can execute TypeScript.
The first run installs TLC and Java with mise and needs the network.
Write the spec
- Write each rule that the reader agrees to as an INVARIANT. A rule can be about a screen, a result, a stored value, or a message. If the model has no variable for a rule, add the variable. Never weaken a rule to make it hold.
- Write
Nextas a disjunction of the actions, such asYouPressPlay \/ YouPressStop. If you do not, TLC names every stepNext. - A state with no step out breaks
NoDeadlock, also when it is a correct end state. When an INVARIANT or a PROPERTY already has that name, the rule isCHECK_DEADLOCK. Add toNextan action that is true only in the end states and changes nothing, such asDone == phase \in {"paid", "failed"} /\ UNCHANGED vars, and give it a label instep().
Pick the chart
You do the work that needs judgment: the words on each state and arrow, the phases and their colors, the title, and the report to the reader. Put your work in a view module, and give it with --view.
To show the reader's words, the view exports state(vars). The value that state() returns picks the form:
- A string gives a flat chart:
export const state = (v) => (v.paid ? "Paid" : "Paying"); - An array gives parent states:
export const state = (v) => v.main.split("."); - An object gives one parallel region for each key:
export const state = (v) => ({ Playback: v.playback, Volume: v.volume });
Label each state with what the reader can see or cares about, such as "Paying" or "Lease held, write pending". Keep variable names out of labels. In vars, a TLA+ sequence is an object with keys from 1, so v.pc[1] is pc[1]. A set is an array.
The view can also export step(action, from, to). It gets the TLC action name and the values before and after the step, and it returns the label of the arrow. Write each step label as the user sees it happen, such as "you press play" or "the connect fails". Do not name the code or the TLA+ action. Two actions that end the same in the chart get the same label, so that they share one arrow.
When a step can occur only in some conditions, end its label with the condition in brackets, in the reader's words, such as you press play [while the file loads]. In a regions chart, the command writes the condition on the other regions on the arrow, in the words of their labels, such as [when Offline]. Your brackets replace it, and two arrows from one state can then look the same. So in a regions chart, do not write brackets for a condition on another region. When a value that no label shows decides where a step goes, name the result in the label, such as "the roster read fails".
The view can also export these:
group(vars)returns the name of a phase. Each chart state gets the color of its group. When the model states behind one chart state are in different groups, that state gets no color.colorsgives each group name a color class.titleis a string that the chart shows at the top.
The command calls state() and group() at most once for each model state, and step() at most once for each step. The chart and the report both use those answers. So make each function depend only on its arguments.
The chart does not draw a step that stays in one label. Split a label when the reader must see such a step.
Aim for about 20 arrows or fewer, because a busier chart is hard to read. First return coarser labels from state(). Give one label to values that act the same, and leave out a detail that the reader does not need, such as a call in flight whose return changes nothing. Keep each state of a bug path, and keep each mark. When a merge changes a breaks state to mayBreak, it hides where a rule breaks. Do not merge two states that break different rules, because the reader then cannot see which rule breaks where. If the chart is still too busy, return null from step() for the steps that the reader does not need, such as a reset that every state has, or a step whose arrow repeats what other arrows show. Obey these r
الأسئلة الشائعة
هل أحتاج إلى معرفة TLA+؟
لا. يكتب الوكيل المواصفة، لكن عليك الاتفاق على القواعد التي يجب أن يلتزم بها النظام.
هل يحتاج التشغيل الأول إلى الإنترنت؟
نعم. التشغيل الأول يثبّت فاحص النماذج وJava، وذلك يحتاج إلى اتصال بالشبكة.
هل يمكن إضعاف قاعدة كي ينجح الفحص؟
لا. تقول المهارة ألا تُضعَف القاعدة أبدًا لجعل الفحص ينجح.
التفاصيل
الوصف الأصلي من المؤلف
Check a TLA+ model of a system that moves between states, such as a product flow, a protocol, or a service, and draw it as a Mermaid statechart. The report gives the shortest path to each state that breaks a rule. Use for /statechart, or to show a bug as a path through states.
repo: cursor/plugins
الشعبية
- نجوم GitHub
- 15k
- الترتيب
- #10997
- الترخيص
- —
- آخر تحديث
- 31/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
advisor
15kيتيح لوكيلك استشارة نموذج ثانٍ أقوى عند نقاط مفصلية، مثل قبل قرار كبير أو عند تعثره في خطأ، إذا فعّلت ذلك.
check-agent-compatibility
15kيُجري فحصاً شاملاً لمدى قدرة وكلاء البرمجة بالذكاء الاصطناعي على تشغيل المستودع والتحقق منه وتوثيقه، ويعيد درجة توافق واحدة مع أهم المشكلات.
cli-for-agents
15kيعلّم وكيلك تصميم أدوات سطر الأوامر أو مراجعتها، حتى يستطيع وكلاء الذكاء الاصطناعي تشغيلها دون مطالبات، مع نصوص مساعدة واضحة وأمثلة.
continual-learning
15kيحافظ على ملاحظاتك في AGENTS.md محدّثة، بتسليم مهمة مراجعة المحادثات السابقة إلى مُحدِّث ذاكرة مخصص.
مهارات مشابهة
test-driven-development
311kيعلّم وكيلك كتابة اختبار فاشل أولًا، ثم رؤيته يفشل، ثم كتابة أصغر شيفرة تنجحه، قبل بناء أي ميزة أو إصلاح.
verification-before-completion
311kيعلّم وكيلك تشغيل فحوصات حقيقية وقراءة نتائجها قبل أن يقول إن المهمة أو الإصلاح أو البناء مكتمل أو ناجح.
migrate-to-shoehorn
310kيستبدل تأكيدات النوع الخطرة في ملفات الاختبار بمكتبة shoehorn، حتى تتمكن الاختبارات من استخدام بيانات جزئية وتجتاز فحوص الأنواع.