[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73GFE2ZWGEPDNEJBSRZH7RC":3,"skill-same:01M73GFE2ZWGEPDNEJBSRZH7RC":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":48,"ownerHtmlUrl":49,"ownerBlogUrl":50,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M73GFE2ZWGEPDNEJBSRZH7RC","type-safety-patterns",null,"Type safety — Python type hints with mypy\u002Fpyright, TypeScript strict mode, branded types, Zod validation, runtime checks","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Ftype-safety-patterns\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: type-safety-patterns\ndescription: Type safety — Python type hints with mypy\u002Fpyright, TypeScript strict mode, branded types, Zod validation, runtime checks\ntriggers:\n  - type safety\n  - type hints python\n  - mypy pyright\n  - typescript strict\n  - branded types\n  - zod schema\n  - runtime type checking\n  - type narrowing\n  - no any typescript\n  - type annotations\ndo_not_use_for:\n  - full validation schemas — use pydantic for complex input validation\n  - error handling — use error-handling-patterns\n  - general AI anti-patterns — use ai-code-maintainability\nsee_also:\n  - ai-code-maintainability\n  - error-handling-patterns\n  - pydantic-ai\n---\n\n# Type Safety Patterns\n\n## Python: Strict Type Hints\n\n```python\nfrom __future__ import annotations  # postponed eval, works with forward refs\nfrom typing import Optional, Union, Literal, TypeVar, Generic\nfrom collections.abc import Callable, Sequence\nfrom dataclasses import dataclass\n\n# Avoid bare Optional[X] — use X | None (Python 3.10+)\ndef find_user(user_id: str) -> User | None: ...\n\n# Union with discriminator\ntype Event = ClickEvent | SubmitEvent | ErrorEvent\n\n# Literal for fixed string values\nStatus = Literal[\"active\", \"inactive\", \"pending\"]\n\ndef update_status(user_id: str, status: Status) -> None: ...\n\n# TypeVar for generic functions\nT = TypeVar(\"T\")\n\ndef first_or_default(items: Sequence[T], default: T) -> T:\n    return items[0] if items else default\n```\n\n## Python: Mypy \u002F Pyright Config\n\n```toml\n# pyproject.toml — pyright (recommended, faster)\n[tool.pyright]\npythonVersion = \"3.11\"\ntypeCheckingMode = \"strict\"\nreportMissingImports = true\nreportMissingTypeStubs = false\nreportUnknownMemberType = false  # relax for external libs\n\n# mypy alternative\n[tool.mypy]\npython_version = \"3.11\"\nstrict = true\nignore_missing_imports = true\nwarn_return_any = true\nwarn_unused_ignores = true\n```\n\n## Python: Branded\u002FNewtype\n\n```python\nfrom typing import NewType, Annotated\n\n# NewType — distinct at type-check time, same at runtime\nUserId = NewType(\"UserId\", str)\nOrderId = NewType(\"OrderId\", str)\n\ndef get_user(user_id: UserId) -> User: ...\ndef get_order(order_id: OrderId) -> Order: ...\n\nuser_id = UserId(\"u-123\")\norder_id = OrderId(\"o-456\")\n\n# get_user(order_id)  # ← mypy error: Expected UserId, got OrderId\n\n# Annotated with constraints\nfrom annotated_types import Gt, Le\nfrom pydantic import TypeAdapter\n\nPositiveInt = Annotated[int, Gt(0)]\nPercentage = Annotated[float, Gt(0.0), Le(100.0)]\n\nadapter = TypeAdapter(Percentage)\nadapter.validate_python(50.0)    # ok\nadapter.validate_python(150.0)   # ValidationError\n```\n\n## TypeScript: Strict Mode\n\n```json\n\u002F\u002F tsconfig.json\n{\n  \"compilerOptions\": {\n    \"strict\": true,\n    \"noUncheckedIndexedAccess\": true,   \u002F\u002F arr[0] is T | undefined\n    \"exactOptionalPropertyTypes\": true,  \u002F\u002F ? means missing, not undefined\n    \"noImplicitReturns\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"forceConsistentCasingInFileNames\": true\n  }\n}\n```\n\n## TypeScript: Branded Types\n\n```typescript\n\u002F\u002F Nominal typing — prevents accidental mix-ups\ndeclare const __brand: unique symbol;\ntype Brand\u003CT, B> = T & { [__brand]: B };\n\ntype UserId = Brand\u003Cstring, \"UserId\">;\ntype OrderId = Brand\u003Cstring, \"OrderId\">;\n\nfunction createUserId(raw: string): UserId {\n  return raw as UserId;  \u002F\u002F only place we cast\n}\n\nfunction getUser(id: UserId): Promise\u003CUser> { ... }\n\nconst userId = createUserId(\"u-123\");\nconst orderId = \"o-456\" as OrderId;\n\ngetUser(userId);   \u002F\u002F ✅ ok\ngetUser(orderId);  \u002F\u002F ❌ TypeScript error: Argument of type 'OrderId' not assignable to 'UserId'\n```\n\n## TypeScript: Zod Runtime Validation\n\n```typescript\nimport { z } from \"zod\";\n\n\u002F\u002F Schema as single source of truth for type + validation\nconst UserSchema = z.object({\n  id: z.string().uuid(),\n  name: z.string().min(1).max(100),\n  age: z.number().int().min(0).max(150),\n  role: z.enum([\"admin\", \"user\", \"guest\"]),\n  email: z.string().email(),\n  createdAt: z.coerce.date(),\n});\n\ntype User = z.infer\u003Ctypeof UserSchema>;   \u002F\u002F no duplicate interface needed\n\n\u002F\u002F Validate at boundary\nfunction parseUser(raw: unknown): User {\n  return UserSchema.parse(raw);            \u002F\u002F throws ZodError if invalid\n}\n\n\u002F\u002F Or safe parse (no throw)\nconst result = UserSchema.safeParse(raw);\nif (!result.success) {\n  logger.warn(\"invalid user data\", { errors: result.error.issues });\n  return null;\n}\nconst user = result.data;   \u002F\u002F User — fully typed\n```\n\n## Type Narrowing\n\n```typescript\n\u002F\u002F Discriminated union — exhaustive checking\ntype Shape =\n  | { kind: \"circle\"; radius: number }\n  | { kind: \"square\"; side: number }\n  | { kind: \"triangle\"; base: number; height: number };\n\nfunction area(shape: Shape): number {\n  switch (shape.kind) {\n    case \"circle\":   return Math.PI * shape.radius ** 2;\n    case \"square\":   return shape.side ** 2;\n    case \"triangle\": return (shape.base * shape.height) \u002F 2;\n    default:\n      \u002F\u002F exhaustive check — TypeScript errors if a case is missing\n      const _exhaustive: never = shape;\n      throw new Error(`Unknown shape: ${_exhaustive}`);\n  }\n}\n```\n\n## Anti-Fake-Pass Checks\n\n- `from __future__ import annotations` is needed for forward references in Python 3.9\n- `NewType` only creates distinct types at check time — `isinstance()` won't detect them at runtime\n- `noUncheckedIndexedAccess: true` makes `arr[0]` type `T | undefined` — handle the undefined case\n- Zod `parse()` throws `ZodError` — use `safeParse()` in user-facing code\n- `strict: true` in tsconfig enables 8 flags at once — add each flag individually if migrating legacy code\n- Branded types require a `createXxx()` factory that does the cast — don't cast everywhere\n","# Type Safety Patterns\n\n## Python: Strict Type Hints\n\n```python\nfrom __future__ import annotations  # postponed eval, works with forward refs\nfrom typing import Optional, Union, Literal, TypeVar, Generic\nfrom collections.abc import Callable, Sequence\nfrom dataclasses import dataclass\n\n# Avoid bare Optional[X] — use X | None (Python 3.10+)\ndef find_user(user_id: str) -> User | None: ...\n\n# Union with discriminator\ntype Event = ClickEvent | SubmitEvent | ErrorEvent\n\n# Literal for fixed string values\nStatus = Literal[\"active\", \"inactive\", \"pending\"]\n\ndef update_status(user_id: str, status: Status) -> None: ...\n\n# TypeVar for generic functions\nT = TypeVar(\"T\")\n\ndef first_or_default(items: Sequence[T], default: T) -> T:\n    return items[0] if items else default\n```\n\n## Python: Mypy \u002F Pyright Config\n\n```toml\n# pyproject.toml — pyright (recommended, faster)\n[tool.pyright]\npythonVersion = \"3.11\"\ntypeCheckingMode = \"strict\"\nreportMissingImports = true\nreportMissingTypeStubs = false\nreportUnknownMemberType = false  # relax for external libs\n\n# mypy alternative\n[tool.mypy]\npython_version = \"3.11\"\nstrict = true\nignore_missing_imports = true\nwarn_return_any = true\nwarn_unused_ignores = true\n```\n\n## Python: Branded\u002FNewtype\n\n```python\nfrom typing import NewType, Annotated\n\n# NewType — distinct at type-check time, same at runtime\nUserId = NewType(\"UserId\", str)\nOrderId = NewType(\"OrderId\", str)\n\ndef get_user(user_id: UserId) -> User: ...\ndef get_order(order_id: OrderId) -> Order: ...\n\nuser_id = UserId(\"u-123\")\norder_id = OrderId(\"o-456\")\n\n# get_user(order_id)  # ← mypy error: Expected UserId, got OrderId\n\n# Annotated with constraints\nfrom annotated_types import Gt, Le\nfrom pydantic import TypeAdapter\n\nPositiveInt = Annotated[int, Gt(0)]\nPercentage = Annotated[float, Gt(0.0), Le(100.0)]\n\nadapter = TypeAdapter(Percentage)\nadapter.validate_python(50.0)    # ok\nadapter.validate_python(150.0)   # ValidationError\n```\n\n## TypeScript: Strict Mode\n\n```json\n\u002F\u002F tsconfig.json\n{\n  \"compilerOptions\": {\n    \"strict\": true,\n    \"noUncheckedIndexedAccess\": true,   \u002F\u002F arr[0] is T | undefined\n    \"exactOptionalPropertyTypes\": true,  \u002F\u002F ? means missing, not undefined\n    \"noImplicitReturns\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"forceConsistentCasingInFileNames\": true\n  }\n}\n```\n\n## TypeScript: Branded Types\n\n```typescript\n\u002F\u002F Nominal typing — prevents accidental mix-ups\ndeclare const __brand: unique symbol;\ntype Brand\u003CT, B> = T & { [__brand]: B };\n\ntype UserId = Brand\u003Cstring, \"UserId\">;\ntype OrderId = Brand\u003Cstring, \"OrderId\">;\n\nfunction createUserId(raw: string): UserId {\n  return raw as UserId;  \u002F\u002F only place we cast\n}\n\nfunction getUser(id: UserId): Promise\u003CUser> { ... }\n\nconst userId = createUserId(\"u-123\");\nconst orderId = \"o-456\" as OrderId;\n\ngetUser(userId);   \u002F\u002F ✅ ok\ngetUser(orderId);  \u002F\u002F ❌ TypeScript error: Argument of type 'OrderId' not assignable to 'UserId'\n```\n\n## TypeScript: Zod Runtime Validation\n\n```typescript\nimport { z } from \"zod\";\n\n\u002F\u002F Schema as single source of truth for type + validation\nconst UserSchema = z.object({\n  id: z.string().uuid(),\n  name: z.string().min(1).max(100),\n  age: z.number().int().min(0).max(150),\n  role: z.enum([\"admin\", \"user\", \"guest\"]),\n  email: z.string().email(),\n  createdAt: z.coerce.date(),\n});\n\ntype User = z.infer\u003Ctypeof UserSchema>;   \u002F\u002F no duplicate interface needed\n\n\u002F\u002F Validate at boundary\nfunction parseUser(raw: unknown): User {\n  return UserSchema.parse(raw);            \u002F\u002F throws ZodError if invalid\n}\n\n\u002F\u002F Or safe parse (no throw)\nconst result = UserSchema.safeParse(raw);\nif (!result.success) {\n  logger.warn(\"invalid user data\", { errors: result.error.issues });\n  return null;\n}\nconst user = result.data;   \u002F\u002F User — fully typed\n```\n\n## Type Narrowing\n\n```typescript\n\u002F\u002F Discriminated union — exhaustive checking\ntype Shape =\n  | { kind: \"circle\"; radius: number }\n  | { kind: \"square\"; side: number }\n  | { kind: \"triangle\"; base: number; height: number };\n\nfunction area(shape: Shape): number {\n  switch (shape.kind) {\n    case \"circle\":   return Math.PI * shape.radius ** 2;\n    case \"square\":   return shape.side ** 2;\n    case \"triangle\": return (shape.base * shape.height) \u002F 2;\n    default:\n      \u002F\u002F exhaustive check — TypeScript errors if a case is missing\n      const _exhaustive: never = shape;\n      throw new Error(`Unknown shape: ${_exhaustive}`);\n  }\n}\n```\n\n## Anti-Fake-Pass Checks\n\n- `from __future__ import annotations` is needed for forward references in Python 3.9\n- `NewType` only creates distinct types at check time — `isinstance()` won't detect them at runtime\n- `noUncheckedIndexedAccess: true` makes `arr[0]` type `T | undefined` — handle the undefined case\n- Zod `parse()` throws `ZodError` — use `safeParse()` in user-facing code\n- `strict: true` in tsconfig enables 8 flags at once — add each flag individually if migrating legacy code\n- Branded types require a `createXxx()` factory that does the cast — don't cast everywhere\n",{"name":5,"see_also":24,"triggers":28,"description":7,"do_not_use_for":39},[25,26,27],"ai-code-maintainability","error-handling-patterns","pydantic-ai",[29,30,31,32,33,34,35,36,37,38],"type safety","type hints python","mypy pyright","typescript strict","branded types","zod schema","runtime type checking","type narrowing","no any typescript","type annotations",[40,41,42],"full validation schemas — use pydantic for complex input validation","error handling — use error-handling-patterns","general AI anti-patterns — use ai-code-maintainability","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Ftype-safety-patterns",1,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-11 23:56:26",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill type-safety-patterns",{"tool":59,"command":60},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill type-safety-patterns",{"tool":62,"command":63},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill type-safety-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Ftype-safety-patterns\u002FSKILL.md",true,[],[68,76,83,91,99,107],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":72,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":95,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":103,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]