typescript-best-practices
यह क्या करती है
यह स्किल भरोसेमंद TypeScript कोड लिखने के नियम देती है। यह उन डेवलपर्स के लिए है जो कम टाइप त्रुटियाँ और कम छिपे क्रैश चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप असिस्टेंट से TypeScript या TSX फ़ाइलें लिखवाना या बदलवाना चाहते हैं।
- ✓जब आप अपने कोड से असुरक्षित type casts या ढीले टाइप हटवाना चाहते हैं।
- ✓जब आप चाहते हैं कि कोड उस बाहरी डेटा पर भरोसा करने से पहले उसे जाँचे।
Skill का लिंक
https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/typescript-best-practices/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस TypeScript फ़ाइल के टाइप साफ़ कीजिए, ताकि वह असुरक्षित casts पर निर्भर न रहे।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट कुछ नियम मानता है, जैसे नाम वाले variants इस्तेमाल करना, बाहरी डेटा के लिए unknown रखना, और उसके टाइप पर भरोसा करने से पहले schema से डेटा जाँचना। ये नियम कोड में असंभव स्टेट आने से रोकते हैं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
TypeScript best practices
Apply the type-system-discipline principle skill first.
| Rule | Summary |
|---|---|
| Discriminated unions | Model variants with a kind literal discriminant so impossible states can't be represented. No optional-field bags. |
| Branded types | Brand primitives with & { readonly __brand: "X" } so they can't be mixed up. Validate once at the boundary. A brand comes from a verifying type guard (input is AgentId), never from as. |
| Constructive modeling | Build the shape so the illegal value can't be constructed. [T, ...T[]] for non-empty, [T, T][] for even length, start plus duration for a range. Not a runtime guard, not a wish for refinement types. |
| Simplest total type | Keep T[] while every operation on it stays total. Strengthen to NonEmpty<T> only where the loose type forces !, a cast, or a "should never happen" throw. |
unknown over any |
External data is unknown. |
| Schemas before guards | Before hand-writing a property-by-property type guard, use the repository's runtime schema library and infer the type from the schema, such as z.infer. |
No as casts |
Every as is a runtime crash waiting. Cast only after validation. |
| Narrowing hierarchy | Discriminant switch > in operator > typeof/instanceof > user-defined type guard > as. |
| Type guards | Must verify the claim. A lying guard is worse than as because the bug hides behind a name that says it's safe. Name them isX or hasX. |
| Exhaustiveness | Inline const _exhaustive: never = x; in default arms so the compiler errors when a new variant is added. |
satisfies over as |
Validates the value without widening literal types. |
| Boundary validation | Parse where data crosses in, into a named domain type. Record<string, unknown> (however spelled) stops at that parse. Trust types inside. See the boundary-discipline principle skill. |
| Schema-derived types | Reach for Pick/Omit/Parameters/ReturnType/Awaited/typeof before declaring a new interface. |
| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
| Real tests | Don't mock what you can run. Prefer the framework's real test primitives with leak/disposable checks, and verify UI in a running build. Mock only what you can't run locally. |
| Structured telemetry | Prefer structured logger diagnostics with enough context to debug from an id. No console.log in shipped code. |
Examples: references/patterns.md.
अक्सर पूछे जाने वाले सवाल
क्या यह सादी JavaScript फ़ाइलों पर काम करता है?
ये नियम TypeScript फ़ाइलों, यानी .ts और .tsx, के लिए हैं।
ब्रांडेड टाइप क्या है?
वह टाइप जो किसी मान, जैसे ID, को चिह्नित करता है, ताकि उसे किसी दूसरे मान के साथ गलती से न मिलाया जा सके।
as casts से क्यों बचें?
cast कंपाइलर को बिना जाँचे मान पर भरोसा करने को कहता है, इसलिए कोड रनटाइम पर विफल हो सकता है।
जानकारी
लेखक का मूल विवरण
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
repo: cursor/plugins
लोकप्रियता
- GitHub स्टार
- 15k
- रैंकिंग में स्थान
- #11002
- लाइसेंस
- —
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
advisor
15kअगर आप इसे चालू करते हैं, तो आपका एजेंट बड़े फ़ैसले से पहले या किसी त्रुटि में अटकने पर एक ज़्यादा शक्तिशाली दूसरे मॉडल से सलाह ले सकता है।
check-agent-compatibility
15kजाँचती है कि AI कोडिंग एजेंट किसी रिपॉज़िटरी को शुरू, सत्यापित और दस्तावेज़ित कर सकते हैं या नहीं, और एक अनुकूलता स्कोर के साथ मुख्य समस्याएँ लौटाती है।
cli-for-agents
15kआपके एजेंट को कमांड-लाइन टूल ऐसे डिज़ाइन या जाँचना सिखाती है कि AI एजेंट उन्हें बिना प्रॉम्प्ट चला सकें, साफ़ help टेक्स्ट और उदाहरणों के साथ।
continual-learning
15kपिछली चैट की समीक्षा का काम एक समर्पित मेमोरी अपडेटर को सौंपकर आपकी AGENTS.md नोट्स को अद्यतन रखती है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।