[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75G9QJGDXZ5P9SS0P9CVY7A":3,"skill-same:01M75G9QJGDXZ5P9SS0P9CVY7A":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M75G9QJGDXZ5P9SS0P9CVY7A","python-type-safety",null,"Python type safety with type hints, generics, protocols, and strict type checking. Use when adding type annotations, implementing generic classes, defining structural interfaces, or configuring mypy\u002Fpyright.","RudyCity\u002Fsuperagent","RudyCity","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F82188919?v=4","01M75FP5X8AW8ACBH0SH34WS7M","01M75FP5YAHJK8M1Q52BWXB82K",70,"MIT","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpython-type-safety\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: python-type-safety\ndescription: Python type safety with type hints, generics, protocols, and strict type checking. Use when adding type annotations, implementing generic classes, defining structural interfaces, or configuring mypy\u002Fpyright.\n---\n\n# Python Type Safety\n\nLeverage Python's type system to catch errors at static analysis time. Type annotations serve as enforced documentation that tooling validates automatically.\n\n## When to Use This Skill\n\n- Adding type hints to existing code\n- Creating generic, reusable classes\n- Defining structural interfaces with protocols\n- Configuring mypy or pyright for strict checking\n- Understanding type narrowing and guards\n- Building type-safe APIs and libraries\n\n## Core Concepts\n\n### 1. Type Annotations\n\nDeclare expected types for function parameters, return values, and variables.\n\n### 2. Generics\n\nWrite reusable code that preserves type information across different types.\n\n### 3. Protocols\n\nDefine structural interfaces without inheritance (duck typing with type safety).\n\n### 4. Type Narrowing\n\nUse guards and conditionals to narrow types within code blocks.\n\n## Quick Start\n\n```python\ndef get_user(user_id: str) -> User | None:\n    \"\"\"Return type makes 'might not exist' explicit.\"\"\"\n    ...\n\n# Type checker enforces handling None case\nuser = get_user(\"123\")\nif user is None:\n    raise UserNotFoundError(\"123\")\nprint(user.name)  # Type checker knows user is User here\n```\n\n## Fundamental Patterns\n\n### Pattern 1: Annotate All Public Signatures\n\nEvery public function, method, and class should have type annotations.\n\n```python\ndef get_user(user_id: str) -> User:\n    \"\"\"Retrieve user by ID.\"\"\"\n    ...\n\ndef process_batch(\n    items: list[Item],\n    max_workers: int = 4,\n) -> BatchResult[ProcessedItem]:\n    \"\"\"Process items concurrently.\"\"\"\n    ...\n\nclass UserRepository:\n    def __init__(self, db: Database) -> None:\n        self._db = db\n\n    async def find_by_id(self, user_id: str) -> User | None:\n        \"\"\"Return User if found, None otherwise.\"\"\"\n        ...\n\n    async def find_by_email(self, email: str) -> User | None:\n        ...\n\n    async def save(self, user: User) -> User:\n        \"\"\"Save and return user with generated ID.\"\"\"\n        ...\n```\n\nUse `mypy --strict` or `pyright` in CI to catch type errors early. For existing projects, enable strict mode incrementally using per-module overrides.\n\n### Pattern 2: Use Modern Union Syntax\n\nPython 3.10+ provides cleaner union syntax.\n\n```python\n# Preferred (3.10+)\ndef find_user(user_id: str) -> User | None:\n    ...\n\ndef parse_value(v: str) -> int | float | str:\n    ...\n\n# Older style (still valid, needed for 3.9)\nfrom typing import Optional, Union\n\ndef find_user(user_id: str) -> Optional[User]:\n    ...\n```\n\n### Pattern 3: Type Narrowing with Guards\n\nUse conditionals to narrow types for the type checker.\n\n```python\ndef process_user(user_id: str) -> UserData:\n    user = find_user(user_id)\n\n    if user is None:\n        raise UserNotFoundError(f\"User {user_id} not found\")\n\n    # Type checker knows user is User here, not User | None\n    return UserData(\n        name=user.name,\n        email=user.email,\n    )\n\ndef process_items(items: list[Item | None]) -> list[ProcessedItem]:\n    # Filter and narrow types\n    valid_items = [item for item in items if item is not None]\n    # valid_items is now list[Item]\n    return [process(item) for item in valid_items]\n```\n\n### Pattern 4: Generic Classes\n\nCreate type-safe reusable containers.\n\n```python\nfrom typing import TypeVar, Generic\n\nT = TypeVar(\"T\")\nE = TypeVar(\"E\", bound=Exception)\n\nclass Result(Generic[T, E]):\n    \"\"\"Represents either a success value or an error.\"\"\"\n\n    def __init__(\n        self,\n        value: T | None = None,\n        error: E | None = None,\n    ) -> None:\n        if (value is None) == (error is None):\n            raise ValueError(\"Exactly one of value or error must be set\")\n        self._value = value\n        self._error = error\n\n    @property\n    def is_success(self) -> bool:\n        return self._error is None\n\n    @property\n    def is_failure(self) -> bool:\n        return self._error is not None\n\n    def unwrap(self) -> T:\n        \"\"\"Get value or raise the error.\"\"\"\n        if self._error is not None:\n            raise self._error\n        return self._value  # type: ignore[return-value]\n\n    def unwrap_or(self, default: T) -> T:\n        \"\"\"Get value or return default.\"\"\"\n        if self._error is not None:\n            return default\n        return self._value  # type: ignore[return-value]\n\n# Usage preserves types\ndef parse_config(path: str) -> Result[Config, ConfigError]:\n    try:\n        return Result(value=Config.from_file(path))\n    except ConfigError as e:\n        return Result(error=e)\n\nresult = parse_config(\"config.yaml\")\nif result.is_success:\n    config = result.unwrap()  # Type: Config\n```\n\n## Detailed worked examples and patterns\n\nDetailed sections (starting with `## Advanced Patterns`) live in `references\u002Fdetails.md`. Read that file when the navigation summary above is insufficient.\n\n## Best Practices Summary\n\n1. **Annotate all public APIs** - Functions, methods, class attributes\n2. **Use `T | None`** - Modern union syntax over `Optional[T]`\n3. **Run strict type checking** - `mypy --strict` in CI\n4. **Use generics** - Preserve type info in reusable code\n5. **Define protocols** - Structural typing for interfaces\n6. **Narrow types** - Use guards to help the type checker\n7. **Bound type vars** - Restrict generics to meaningful types\n8. **Create type aliases** - Meaningful names for complex types\n9. **Minimize `Any`** - Use specific types or generics. `Any` is acceptable for truly dynamic data or when interfacing with untyped third-party code\n10. **Document with types** - Types are enforceable documentation\n","# Python Type Safety\n\nLeverage Python's type system to catch errors at static analysis time. Type annotations serve as enforced documentation that tooling validates automatically.\n\n## When to Use This Skill\n\n- Adding type hints to existing code\n- Creating generic, reusable classes\n- Defining structural interfaces with protocols\n- Configuring mypy or pyright for strict checking\n- Understanding type narrowing and guards\n- Building type-safe APIs and libraries\n\n## Core Concepts\n\n### 1. Type Annotations\n\nDeclare expected types for function parameters, return values, and variables.\n\n### 2. Generics\n\nWrite reusable code that preserves type information across different types.\n\n### 3. Protocols\n\nDefine structural interfaces without inheritance (duck typing with type safety).\n\n### 4. Type Narrowing\n\nUse guards and conditionals to narrow types within code blocks.\n\n## Quick Start\n\n```python\ndef get_user(user_id: str) -> User | None:\n    \"\"\"Return type makes 'might not exist' explicit.\"\"\"\n    ...\n\n# Type checker enforces handling None case\nuser = get_user(\"123\")\nif user is None:\n    raise UserNotFoundError(\"123\")\nprint(user.name)  # Type checker knows user is User here\n```\n\n## Fundamental Patterns\n\n### Pattern 1: Annotate All Public Signatures\n\nEvery public function, method, and class should have type annotations.\n\n```python\ndef get_user(user_id: str) -> User:\n    \"\"\"Retrieve user by ID.\"\"\"\n    ...\n\ndef process_batch(\n    items: list[Item],\n    max_workers: int = 4,\n) -> BatchResult[ProcessedItem]:\n    \"\"\"Process items concurrently.\"\"\"\n    ...\n\nclass UserRepository:\n    def __init__(self, db: Database) -> None:\n        self._db = db\n\n    async def find_by_id(self, user_id: str) -> User | None:\n        \"\"\"Return User if found, None otherwise.\"\"\"\n        ...\n\n    async def find_by_email(self, email: str) -> User | None:\n        ...\n\n    async def save(self, user: User) -> User:\n        \"\"\"Save and return user with generated ID.\"\"\"\n        ...\n```\n\nUse `mypy --strict` or `pyright` in CI to catch type errors early. For existing projects, enable strict mode incrementally using per-module overrides.\n\n### Pattern 2: Use Modern Union Syntax\n\nPython 3.10+ provides cleaner union syntax.\n\n```python\n# Preferred (3.10+)\ndef find_user(user_id: str) -> User | None:\n    ...\n\ndef parse_value(v: str) -> int | float | str:\n    ...\n\n# Older style (still valid, needed for 3.9)\nfrom typing import Optional, Union\n\ndef find_user(user_id: str) -> Optional[User]:\n    ...\n```\n\n### Pattern 3: Type Narrowing with Guards\n\nUse conditionals to narrow types for the type checker.\n\n```python\ndef process_user(user_id: str) -> UserData:\n    user = find_user(user_id)\n\n    if user is None:\n        raise UserNotFoundError(f\"User {user_id} not found\")\n\n    # Type checker knows user is User here, not User | None\n    return UserData(\n        name=user.name,\n        email=user.email,\n    )\n\ndef process_items(items: list[Item | None]) -> list[ProcessedItem]:\n    # Filter and narrow types\n    valid_items = [item for item in items if item is not None]\n    # valid_items is now list[Item]\n    return [process(item) for item in valid_items]\n```\n\n### Pattern 4: Generic Classes\n\nCreate type-safe reusable containers.\n\n```python\nfrom typing import TypeVar, Generic\n\nT = TypeVar(\"T\")\nE = TypeVar(\"E\", bound=Exception)\n\nclass Result(Generic[T, E]):\n    \"\"\"Represents either a success value or an error.\"\"\"\n\n    def __init__(\n        self,\n        value: T | None = None,\n        error: E | None = None,\n    ) -> None:\n        if (value is None) == (error is None):\n            raise ValueError(\"Exactly one of value or error must be set\")\n        self._value = value\n        self._error = error\n\n    @property\n    def is_success(self) -> bool:\n        return self._error is None\n\n    @property\n    def is_failure(self) -> bool:\n        return self._error is not None\n\n    def unwrap(self) -> T:\n        \"\"\"Get value or raise the error.\"\"\"\n        if self._error is not None:\n            raise self._error\n        return self._value  # type: ignore[return-value]\n\n    def unwrap_or(self, default: T) -> T:\n        \"\"\"Get value or return default.\"\"\"\n        if self._error is not None:\n            return default\n        return self._value  # type: ignore[return-value]\n\n# Usage preserves types\ndef parse_config(path: str) -> Result[Config, ConfigError]:\n    try:\n        return Result(value=Config.from_file(path))\n    except ConfigError as e:\n        return Result(error=e)\n\nresult = parse_config(\"config.yaml\")\nif result.is_success:\n    config = result.unwrap()  # Type: Config\n```\n\n## Detailed worked examples and patterns\n\nDetailed sections (starting with `## Advanced Patterns`) live in `references\u002Fdetails.md`. Read that file when the navigation summary above is insufficient.\n\n## Best Practices Summary\n\n1. **Annotate all public APIs** - Functions, methods, class attributes\n2. **Use `T | None`** - Modern union syntax over `Optional[T]`\n3. **Run strict type checking** - `mypy --strict` in CI\n4. **Use generics** - Preserve type info in reusable code\n5. **Define protocols** - Structural typing for interfaces\n6. **Narrow types** - Use guards to help the type checker\n7. **Bound type vars** - Restrict generics to meaningful types\n8. **Create type aliases** - Meaningful names for complex types\n9. **Minimize `Any`** - Use specific types or generics. `Any` is acceptable for truly dynamic data or when interfacing with untyped third-party code\n10. **Document with types** - Types are enforceable documentation\n",{"name":5,"description":7},"main","62c7af5ced2c21355d148c243edb6d5921cca1a6",".agents\u002Fskills\u002Fpython-type-safety",8,"https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent","https:\u002F\u002Fgithub.com\u002FRudyCity","2026-11-14 22:58:49",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add RudyCity\u002Fsuperagent --skill python-type-safety",{"tool":36,"command":37},"bunx","bunx skills add RudyCity\u002Fsuperagent --skill python-type-safety",{"tool":39,"command":40},"pnpm","pnpm dlx skills add RudyCity\u002Fsuperagent --skill python-type-safety","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpython-type-safety\u002FSKILL.md",true,[44],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"references\u002Fdetails.md","REFERENCE","参考文档",5862,"https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpython-type-safety\u002Freferences\u002Fdetails.md",[51,58,65,72,79,86],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M75GP28CM6QCSXSHKFF3NNKS","telegram_bot","Use Telegram Bot when the user asks for Telegram Bot or this provider's API.","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002Fmuse-bridge-kit\u002Fskills\u002Ftelegram-bot\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":18},"01M75GNZGZYM7NWDV6MBP3HS14","superagent-bridge","Operate the Muse\u003C->superagent Telegram bridge: poll the private group for task_request\u002Ftask_result envelopes, validate senders, and reply with task_batch\u002Ftask_done as Muse (the remote brain).","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002Fmuse-bridge-kit\u002Fskills\u002Fsuperagent-bridge\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M75GNHN19HJWZ7NAPM5E5JCV","Writing Skills","TDD for process documentation - test with subagents before writing, iterate until bulletproof","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M75GNCQEKVRA4FH161NZPZNB","writing-shape","Take a markdown file of raw material and shape it into an article through a conversational session — drafting candidate openings, growing the piece paragraph by paragraph, arguing about format (lists, tables, callouts, quotes) at each step. Use when the user has a pile of notes, fragments, or a rough draft and wants help turning it into something publishable.","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-shape\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M75GNAF9NAYCSTBDZDGMK0DZ","Writing Plans","Create detailed implementation plans with bite-sized tasks for engineers with zero codebase context","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-plans\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":18},"01M75GN72EV0V5NQAW9CSPFRFH","writing-guidelines","Review docs\u002Fprose for Writing Guidelines compliance. Use when asked to \"review my docs\", \"check writing style\", \"audit prose\", \"review docs voice and tone\", or \"check this page against the writing handbook\".","https:\u002F\u002Fgithub.com\u002FRudyCity\u002Fsuperagent\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fwriting-guidelines\u002FSKILL.md",[],[]]