[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GQ4RVW5WN4ZKHTZT61GD6":3,"skill-same:01M71GQ4RVW5WN4ZKHTZT61GD6":104},{"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":27,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":6,"ownerHtmlUrl":62,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":63,"install":64,"resources":77},"01M71GQ4RVW5WN4ZKHTZT61GD6","library-design-patterns",null,"Two-tier design, progressive enhancement, non-blocking patterns, and security-first architecture for Python libraries. Use when creating or refactoring Python libraries. TRIGGER when: library design, module architecture, reusable component, two-tier. DO NOT TRIGGER when: simple scripts, config files, documentation-only changes.","JSGforever\u002Fskillguard","JSGforever","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F85541948?v=4","01M71FQD3E132VMR5F4TAYX3YS","01M71FQD4DYW0XJ4XQ4YQH75Y9",2,"GPL-3.0","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"library design patterns","library","patterns","design","design patterns","only","when","progressive enhancement","docstring","separation of concerns","false","files","refactoring","knowledge","api","libraries","documentation","architecture","component","cli","2026-11-10 10:12:30",false,"---\nname: library-design-patterns\nversion: 1.0.0\ntype: knowledge\ndescription: \"Two-tier design, progressive enhancement, non-blocking patterns, and security-first architecture for Python libraries. Use when creating or refactoring Python libraries. TRIGGER when: library design, module architecture, reusable component, two-tier. DO NOT TRIGGER when: simple scripts, config files, documentation-only changes.\"\nkeywords: library, module, two-tier, progressive enhancement, cli, docstring, api, reusability, separation of concerns, graceful degradation, security validation, CWE-22, CWE-59, CWE-117\nauto_activate: false\nallowed-tools: [Read]\n---\n\n# Library Design Patterns Skill\n\nStandardized architectural patterns for Python library design in the autonomous-dev plugin ecosystem. Promotes reusability, testability, security, and maintainability through proven design patterns.\n\n## When This Skill Activates\n\n- Creating new Python libraries\n- Refactoring existing libraries\n- Designing reusable components\n- Implementing CLI interfaces\n- Validating library architecture\n- Keywords: \"library\", \"module\", \"two-tier\", \"progressive enhancement\", \"cli\", \"api\"\n\n---\n\n## Core Design Patterns\n\n### 1. Two-Tier Design Pattern\n\n**Definition**: Separate core logic (library) from user interface (CLI script) to maximize reusability and testability.\n\n**Structure**:\n- **Tier 1 (Core Library)**: Pure Python module with business logic, no I\u002FO assumptions\n- **Tier 2 (CLI Interface)**: Thin wrapper script for command-line usage, handles argparse and user interaction\n\n**Benefits**:\n- Reusability: Core logic can be imported and reused in other contexts\n- Testability: Pure functions are easier to unit test without mocking I\u002FO\n- Separation of Concerns: Business logic separate from presentation layer\n- Maintainability: Changes to CLI don't affect core logic and vice versa\n\n**Example**:\n```\nplugin_updater.py       # Core library - pure logic\nupdate_plugin.py        # CLI interface - user interaction\n```\n\n**When to Use**:\n- Any library that might be used both programmatically and from command line\n- Complex business logic that needs thorough testing\n- Features that may be integrated into multiple workflows\n\n**See**: `docs\u002Ftwo-tier-design.md`, `templates\u002Flibrary-template.py`, `examples\u002Ftwo-tier-example.py`\n\n---\n\n### 2. Progressive Enhancement Pattern\n\n**Definition**: Start with simple validation (strings), progressively add stronger validation (Path objects, whitelists) without breaking existing code.\n\n**Progression**:\n1. **Level 1 (Strings)**: Accept string paths, basic validation\n2. **Level 2 (Path Objects)**: Convert to pathlib.Path, add existence checks\n3. **Level 3 (Whitelist Validation)**: Restrict to approved directories, prevent path traversal\n\n**Benefits**:\n- Graceful Degradation: Works in degraded environments (missing dependencies)\n- Backward Compatibility: Existing code continues to work\n- Security Hardening: Stronger validation added over time without breaking changes\n- Flexibility: Can operate in various security contexts\n\n**Example**:\n```python\n# Level 1: Accept strings\ndef process(file: str) -> Result:\n    return _process_path(file)\n\n# Level 2: Upgrade to Path objects\ndef process(file: Union[str, Path]) -> Result:\n    path = Path(file) if isinstance(file, str) else file\n    if not path.exists():\n        raise FileNotFoundError(f\"File not found: {path}\")\n    return _process_path(path)\n\n# Level 3: Add whitelist validation\ndef process(file: Union[str, Path], *, allowed_dirs: Optional[List[Path]] = None) -> Result:\n    path = Path(file) if isinstance(file, str) else file\n    if allowed_dirs and not any(path.is_relative_to(d) for d in allowed_dirs):\n        raise SecurityError(f\"Path outside allowed directories: {path}\")\n    if not path.exists():\n        raise FileNotFoundError(f\"File not found: {path}\")\n    return _process_path(path)\n```\n\n**See**: `docs\u002Fprogressive-enhancement.md`, `examples\u002Fprogressive-enhancement-example.py`\n\n---\n\n### 3. Non-Blocking Enhancement Pattern\n\n**Definition**: Design enhancements (features beyond core functionality) to never block core operations. If enhancement fails, core feature should still succeed.\n\n**Principles**:\n- Core operations must complete even if enhancements fail\n- Enhancements wrapped in try\u002Fexcept with graceful degradation\n- Log enhancement failures but don't raise exceptions\n- Provide manual fallback instructions if enhancement unavailable\n\n**Benefits**:\n- Reliability: Core features always work\n- Resilience: Graceful handling of missing dependencies or permissions\n- User Experience: Clear feedback when enhancements unavailable\n- Maintainability: Easier to add\u002Fremove enhancements without breaking core\n\n**Example**:\n```python\ndef implement_feature(spec: FeatureSpec) -> Result:\n    # Core operation (must succeed)\n    result = _implement_core_logic(spec)\n\n    # Enhancement: Auto-commit (may fail)\n    try:\n        if auto_commit_enabled():\n            commit_changes(result.files)\n    except Exception as e:\n        logger.warning(f\"Auto-commit failed: {e}\")\n        logger.info(\"Manual fallback: git add . && git commit\")\n\n    # Feature succeeded regardless of enhancement\n    return result\n```\n\n**See**: `docs\u002Fnon-blocking-enhancements.md`, `examples\u002Fnon-blocking-example.py`\n\n---\n\n### 4. Security-First Design Pattern\n\n**Definition**: Build security validation into library architecture from the start. Validate all inputs, sanitize outputs, audit all operations.\n\n**Core Principles**:\n- **Input Validation**: Validate all user input against expected types and ranges\n- **Path Traversal Prevention (CWE-22)**: Use whitelists, resolve paths, check boundaries\n- **Command Injection Prevention (CWE-78)**: Use subprocess arrays, avoid shell=True\n- **Log Injection Prevention (CWE-117)**: Sanitize all log messages, escape newlines\n- **Audit Logging**: Log security-relevant operations to audit trail\n\n**Security Layers**:\n1. **Input Validation**: Type checking, range validation, format verification\n2. **Path Validation**: Whitelist checking, symlink resolution, boundary verification\n3. **Command Validation**: Argument array construction, shell prevention\n4. **Output Sanitization**: Log message escaping, error message filtering\n5. **Audit Trail**: Security operations logged to `logs\u002Fsecurity_audit.log`\n\n**Example**:\n```python\nfrom plugins.autonomous_dev.lib.security_utils import validate_path, audit_log\n\ndef process_file(filepath: str, *, allowed_dirs: List[Path]) -> None:\n    \"\"\"Process file with security validation.\n\n    Security:\n        - CWE-22 Prevention: Path traversal validation\n        - CWE-117 Prevention: Sanitized audit logging\n    \"\"\"\n    # Validate path (CWE-22 prevention)\n    safe_path = validate_path(\n        filepath,\n        must_exist=True,\n        allowed_dirs=allowed_dirs\n    )\n\n    # Audit security operation (CWE-117 safe)\n    audit_log(\"file_processed\", filepath=str(safe_path))\n\n    # Process file\n    return _process(safe_path)\n```\n\n**See**: `docs\u002Fsecurity-patterns.md`, `examples\u002Fsecurity-validation-example.py`\n\n---\n\n### 5. Docstring Standards Pattern\n\n**Definition**: Consistent Google-style docstrings with comprehensive documentation for all public APIs.\n\n**Structure**:\n```python\ndef function(arg1: Type1, arg2: Type2, *, kwarg: Type3 = default) -> ReturnType:\n    \"\"\"One-line summary (imperative mood).\n\n    Optional detailed description explaining behavior, edge cases,\n    and important implementation details.\n\n    Args:\n        arg1: Description of first argument\n        arg2: Description of second argument\n        kwarg: Description of keyword argument (default: value)\n\n    Returns:\n        Description of return value and its structure\n\n    Raises:\n        ExceptionType: When and why this exception is raised\n        AnotherException: Another error condition\n\n    Example:\n        >>> result = function(\"value1\", \"value2\", kwarg=\"custom\")\n        >>> print(result.status)\n        'success'\n\n    Security:\n        - CWE-XX: How this function prevents security issue\n        - Validation: What input validation is performed\n\n    See:\n        - Related function or documentation\n        - External reference or skill\n    \"\"\"\n```\n\n**Required Sections**:\n- Summary line (one line, imperative mood)\n- Args section (all parameters documented)\n- Returns section (return value structure)\n- Raises section (all exceptions)\n- Security section (for security-sensitive functions)\n\n**See**: `docs\u002Fdocstring-standards.md`, `templates\u002Fdocstring-template.py`\n\n---\n\n## Usage Guidelines\n\n### For Library Authors\n\nWhen creating or refactoring libraries:\n\n1. **Use two-tier design** for any library with CLI interface\n2. **Apply progressive enhancement** for validation and security\n3. **Make enhancements non-blocking** so core features always work\n4. **Build security in from start** with input validation and audit logging\n5. **Document thoroughly** using Google-style docstrings\n\n### For Claude\n\nWhen creating or analyzing libraries:\n\n1. **Load this skill** when keywords match (\"library\", \"module\", \"two-tier\", etc.)\n2. **Follow design patterns** for consistent architecture\n3. **Validate security** using CWE prevention patterns\n4. **Check docstrings** against standards\n5. **Reference templates** in `templates\u002F` directory\n\n### Token Savings\n\nBy centralizing library design patterns in this skill:\n\n- **Before**: ~40 tokens per library for inline pattern documentation\n- **After**: ~10 tokens for skill reference comment\n- **Savings**: ~30 tokens per library\n- **Total**: ~1,200 tokens across 40 libraries (5-6% reduction)\n\n---\n\n## Progressive Disclosure\n\nThis skill uses Claude Code 2.0+ progressive disclosure architecture:\n\n- **Metadata** (frontmatter): Always loaded (~200 tokens)\n- **Full content**: Loaded only when keywords match\n- **Result**: Efficient context usage, scales to 100+ skills\n\nWhen you use terms like \"library design\", \"two-tier\", \"progressive enhancement\", or \"security validation\", Claude Code automatically loads the full skill content to provide detailed guidance.\n\n---\n\n## Templates and Examples\n\n### Templates (reusable code structures)\n- `templates\u002Flibrary-template.py`: Two-tier library template\n- `templates\u002Fcli-template.py`: CLI interface template\n- `templates\u002Fdocstring-template.py`: Comprehensive docstring examples\n\n### Examples (real implementations)\n- `examples\u002Ftwo-tier-example.py`: plugin_updater.py pattern\n- `examples\u002Fprogressive-enhancement-example.py`: security_utils.py pattern\n- `examples\u002Fsecurity-validation-example.py`: Path validation patterns\n\n### Documentation (detailed guides)\n- `docs\u002Ftwo-tier-design.md`: Two-tier architecture guide\n- `docs\u002Fprogressive-enhancement.md`: Progressive validation guide\n- `docs\u002Fsecurity-patterns.md`: Security-first design guide\n- `docs\u002Fdocstring-standards.md`: Docstring formatting standards\n\n---\n\n## Cross-References\n\nThis skill integrates with other autonomous-dev skills:\n\n- **error-handling-patterns**: Exception handling and recovery strategies\n- **python-standards**: Python code style and type hints\n- **security-patterns**: Comprehensive security guidance (OWASP, CWE)\n- **testing-guide**: Unit testing and TDD for libraries\n- **python-standards**: API documentation standards and docstring conventions\n\n**See**: `skills\u002Ferror-handling-patterns\u002F`, `skills\u002Fpython-standards\u002F`, `skills\u002Fsecurity-patterns\u002F`\n\n---\n\n## Maintenance\n\nThis skill should be updated when:\n\n- New library design patterns emerge in the codebase\n- Security best practices evolve\n- Python language features enable better patterns\n- Common anti-patterns are identified\n\n**Last Updated**: 2025-11-16 (Phase 8.8 - Initial creation)\n**Version**: 1.0.0\n\n---\n\n## Hard Rules\n\n**FORBIDDEN**:\n- Libraries with circular dependencies between modules\n- Public APIs without type hints and docstrings\n- Side effects in library constructors (I\u002FO, network calls)\n\n**REQUIRED**:\n- All libraries MUST have a single clear entry point\n- All public functions MUST be importable from the package root or documented module\n- Error handling MUST use specific exception types (never bare `except:`)\n- Libraries MUST work without optional dependencies (graceful degradation)\n","# Library Design Patterns Skill\n\nStandardized architectural patterns for Python library design in the autonomous-dev plugin ecosystem. Promotes reusability, testability, security, and maintainability through proven design patterns.\n\n## When This Skill Activates\n\n- Creating new Python libraries\n- Refactoring existing libraries\n- Designing reusable components\n- Implementing CLI interfaces\n- Validating library architecture\n- Keywords: \"library\", \"module\", \"two-tier\", \"progressive enhancement\", \"cli\", \"api\"\n\n---\n\n## Core Design Patterns\n\n### 1. Two-Tier Design Pattern\n\n**Definition**: Separate core logic (library) from user interface (CLI script) to maximize reusability and testability.\n\n**Structure**:\n- **Tier 1 (Core Library)**: Pure Python module with business logic, no I\u002FO assumptions\n- **Tier 2 (CLI Interface)**: Thin wrapper script for command-line usage, handles argparse and user interaction\n\n**Benefits**:\n- Reusability: Core logic can be imported and reused in other contexts\n- Testability: Pure functions are easier to unit test without mocking I\u002FO\n- Separation of Concerns: Business logic separate from presentation layer\n- Maintainability: Changes to CLI don't affect core logic and vice versa\n\n**Example**:\n```\nplugin_updater.py       # Core library - pure logic\nupdate_plugin.py        # CLI interface - user interaction\n```\n\n**When to Use**:\n- Any library that might be used both programmatically and from command line\n- Complex business logic that needs thorough testing\n- Features that may be integrated into multiple workflows\n\n**See**: `docs\u002Ftwo-tier-design.md`, `templates\u002Flibrary-template.py`, `examples\u002Ftwo-tier-example.py`\n\n---\n\n### 2. Progressive Enhancement Pattern\n\n**Definition**: Start with simple validation (strings), progressively add stronger validation (Path objects, whitelists) without breaking existing code.\n\n**Progression**:\n1. **Level 1 (Strings)**: Accept string paths, basic validation\n2. **Level 2 (Path Objects)**: Convert to pathlib.Path, add existence checks\n3. **Level 3 (Whitelist Validation)**: Restrict to approved directories, prevent path traversal\n\n**Benefits**:\n- Graceful Degradation: Works in degraded environments (missing dependencies)\n- Backward Compatibility: Existing code continues to work\n- Security Hardening: Stronger validation added over time without breaking changes\n- Flexibility: Can operate in various security contexts\n\n**Example**:\n```python\n# Level 1: Accept strings\ndef process(file: str) -> Result:\n    return _process_path(file)\n\n# Level 2: Upgrade to Path objects\ndef process(file: Union[str, Path]) -> Result:\n    path = Path(file) if isinstance(file, str) else file\n    if not path.exists():\n        raise FileNotFoundError(f\"File not found: {path}\")\n    return _process_path(path)\n\n# Level 3: Add whitelist validation\ndef process(file: Union[str, Path], *, allowed_dirs: Optional[List[Path]] = None) -> Result:\n    path = Path(file) if isinstance(file, str) else file\n    if allowed_dirs and not any(path.is_relative_to(d) for d in allowed_dirs):\n        raise SecurityError(f\"Path outside allowed directories: {path}\")\n    if not path.exists():\n        raise FileNotFoundError(f\"File not found: {path}\")\n    return _process_path(path)\n```\n\n**See**: `docs\u002Fprogressive-enhancement.md`, `examples\u002Fprogressive-enhancement-example.py`\n\n---\n\n### 3. Non-Blocking Enhancement Pattern\n\n**Definition**: Design enhancements (features beyond core functionality) to never block core operations. If enhancement fails, core feature should still succeed.\n\n**Principles**:\n- Core operations must complete even if enhancements fail\n- Enhancements wrapped in try\u002Fexcept with graceful degradation\n- Log enhancement failures but don't raise exceptions\n- Provide manual fallback instructions if enhancement unavailable\n\n**Benefits**:\n- Reliability: Core features always work\n- Resilience: Graceful handling of missing dependencies or permissions\n- User Experience: Clear feedback when enhancements unavailable\n- Maintainability: Easier to add\u002Fremove enhancements without breaking core\n\n**Example**:\n```python\ndef implement_feature(spec: FeatureSpec) -> Result:\n    # Core operation (must succeed)\n    result = _implement_core_logic(spec)\n\n    # Enhancement: Auto-commit (may fail)\n    try:\n        if auto_commit_enabled():\n            commit_changes(result.files)\n    except Exception as e:\n        logger.warning(f\"Auto-commit failed: {e}\")\n        logger.info(\"Manual fallback: git add . && git commit\")\n\n    # Feature succeeded regardless of enhancement\n    return result\n```\n\n**See**: `docs\u002Fnon-blocking-enhancements.md`, `examples\u002Fnon-blocking-example.py`\n\n---\n\n### 4. Security-First Design Pattern\n\n**Definition**: Build security validation into library architecture from the start. Validate all inputs, sanitize outputs, audit all operations.\n\n**Core Principles**:\n- **Input Validation**: Validate all user input against expected types and ranges\n- **Path Traversal Prevention (CWE-22)**: Use whitelists, resolve paths, check boundaries\n- **Command Injection Prevention (CWE-78)**: Use subprocess arrays, avoid shell=True\n- **Log Injection Prevention (CWE-117)**: Sanitize all log messages, escape newlines\n- **Audit Logging**: Log security-relevant operations to audit trail\n\n**Security Layers**:\n1. **Input Validation**: Type checking, range validation, format verification\n2. **Path Validation**: Whitelist checking, symlink resolution, boundary verification\n3. **Command Validation**: Argument array construction, shell prevention\n4. **Output Sanitization**: Log message escaping, error message filtering\n5. **Audit Trail**: Security operations logged to `logs\u002Fsecurity_audit.log`\n\n**Example**:\n```python\nfrom plugins.autonomous_dev.lib.security_utils import validate_path, audit_log\n\ndef process_file(filepath: str, *, allowed_dirs: List[Path]) -> None:\n    \"\"\"Process file with security validation.\n\n    Security:\n        - CWE-22 Prevention: Path traversal validation\n        - CWE-117 Prevention: Sanitized audit logging\n    \"\"\"\n    # Validate path (CWE-22 prevention)\n    safe_path = validate_path(\n        filepath,\n        must_exist=True,\n        allowed_dirs=allowed_dirs\n    )\n\n    # Audit security operation (CWE-117 safe)\n    audit_log(\"file_processed\", filepath=str(safe_path))\n\n    # Process file\n    return _process(safe_path)\n```\n\n**See**: `docs\u002Fsecurity-patterns.md`, `examples\u002Fsecurity-validation-example.py`\n\n---\n\n### 5. Docstring Standards Pattern\n\n**Definition**: Consistent Google-style docstrings with comprehensive documentation for all public APIs.\n\n**Structure**:\n```python\ndef function(arg1: Type1, arg2: Type2, *, kwarg: Type3 = default) -> ReturnType:\n    \"\"\"One-line summary (imperative mood).\n\n    Optional detailed description explaining behavior, edge cases,\n    and important implementation details.\n\n    Args:\n        arg1: Description of first argument\n        arg2: Description of second argument\n        kwarg: Description of keyword argument (default: value)\n\n    Returns:\n        Description of return value and its structure\n\n    Raises:\n        ExceptionType: When and why this exception is raised\n        AnotherException: Another error condition\n\n    Example:\n        >>> result = function(\"value1\", \"value2\", kwarg=\"custom\")\n        >>> print(result.status)\n        'success'\n\n    Security:\n        - CWE-XX: How this function prevents security issue\n        - Validation: What input validation is performed\n\n    See:\n        - Related function or documentation\n        - External reference or skill\n    \"\"\"\n```\n\n**Required Sections**:\n- Summary line (one line, imperative mood)\n- Args section (all parameters documented)\n- Returns section (return value structure)\n- Raises section (all exceptions)\n- Security section (for security-sensitive functions)\n\n**See**: `docs\u002Fdocstring-standards.md`, `templates\u002Fdocstring-template.py`\n\n---\n\n## Usage Guidelines\n\n### For Library Authors\n\nWhen creating or refactoring libraries:\n\n1. **Use two-tier design** for any library with CLI interface\n2. **Apply progressive enhancement** for validation and security\n3. **Make enhancements non-blocking** so core features always work\n4. **Build security in from start** with input validation and audit logging\n5. **Document thoroughly** using Google-style docstrings\n\n### For Claude\n\nWhen creating or analyzing libraries:\n\n1. **Load this skill** when keywords match (\"library\", \"module\", \"two-tier\", etc.)\n2. **Follow design patterns** for consistent architecture\n3. **Validate security** using CWE prevention patterns\n4. **Check docstrings** against standards\n5. **Reference templates** in `templates\u002F` directory\n\n### Token Savings\n\nBy centralizing library design patterns in this skill:\n\n- **Before**: ~40 tokens per library for inline pattern documentation\n- **After**: ~10 tokens for skill reference comment\n- **Savings**: ~30 tokens per library\n- **Total**: ~1,200 tokens across 40 libraries (5-6% reduction)\n\n---\n\n## Progressive Disclosure\n\nThis skill uses Claude Code 2.0+ progressive disclosure architecture:\n\n- **Metadata** (frontmatter): Always loaded (~200 tokens)\n- **Full content**: Loaded only when keywords match\n- **Result**: Efficient context usage, scales to 100+ skills\n\nWhen you use terms like \"library design\", \"two-tier\", \"progressive enhancement\", or \"security validation\", Claude Code automatically loads the full skill content to provide detailed guidance.\n\n---\n\n## Templates and Examples\n\n### Templates (reusable code structures)\n- `templates\u002Flibrary-template.py`: Two-tier library template\n- `templates\u002Fcli-template.py`: CLI interface template\n- `templates\u002Fdocstring-template.py`: Comprehensive docstring examples\n\n### Examples (real implementations)\n- `examples\u002Ftwo-tier-example.py`: plugin_updater.py pattern\n- `examples\u002Fprogressive-enhancement-example.py`: security_utils.py pattern\n- `examples\u002Fsecurity-validation-example.py`: Path validation patterns\n\n### Documentation (detailed guides)\n- `docs\u002Ftwo-tier-design.md`: Two-tier architecture guide\n- `docs\u002Fprogressive-enhancement.md`: Progressive validation guide\n- `docs\u002Fsecurity-patterns.md`: Security-first design guide\n- `docs\u002Fdocstring-standards.md`: Docstring formatting standards\n\n---\n\n## Cross-References\n\nThis skill integrates with other autonomous-dev skills:\n\n- **error-handling-patterns**: Exception handling and recovery strategies\n- **python-standards**: Python code style and type hints\n- **security-patterns**: Comprehensive security guidance (OWASP, CWE)\n- **testing-guide**: Unit testing and TDD for libraries\n- **python-standards**: API documentation standards and docstring conventions\n\n**See**: `skills\u002Ferror-handling-patterns\u002F`, `skills\u002Fpython-standards\u002F`, `skills\u002Fsecurity-patterns\u002F`\n\n---\n\n## Maintenance\n\nThis skill should be updated when:\n\n- New library design patterns emerge in the codebase\n- Security best practices evolve\n- Python language features enable better patterns\n- Common anti-patterns are identified\n\n**Last Updated**: 2025-11-16 (Phase 8.8 - Initial creation)\n**Version**: 1.0.0\n\n---\n\n## Hard Rules\n\n**FORBIDDEN**:\n- Libraries with circular dependencies between modules\n- Public APIs without type hints and docstrings\n- Side effects in library constructors (I\u002FO, network calls)\n\n**REQUIRED**:\n- All libraries MUST have a single clear entry point\n- All public functions MUST be importable from the package root or documented module\n- Error handling MUST use specific exception types (never bare `except:`)\n- Libraries MUST work without optional dependencies (graceful degradation)\n",{"name":5,"type":41,"version":53,"keywords":54,"description":7,"allowed-tools":55,"auto_activate":49},"1.0.0","library, module, two-tier, progressive enhancement, cli, docstring, api, reusability, separation of concerns, graceful degradation, security validation, CWE-22, CWE-59, CWE-117",[56],"Read","main","f2ec4b3b9133d34eeaf9b38e4b0a97e8e5705a7f","benchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns",0,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard","https:\u002F\u002Fgithub.com\u002FJSGforever","2026-08-29 18:27:56",{"source":8,"skillName":5,"commands":65,"prompt":75,"zipAvailable":76},[66,69,72],{"tool":67,"command":68},"npx","npx skills add JSGforever\u002Fskillguard --skill library-design-patterns",{"tool":70,"command":71},"bunx","bunx skills add JSGforever\u002Fskillguard --skill library-design-patterns",{"tool":73,"command":74},"pnpm","pnpm dlx skills add JSGforever\u002Fskillguard --skill library-design-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002FSKILL.md",true,[78,84,88,92,96,100],{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"examples\u002Fprogressive-enhancement-example.py","SCRIPT","脚本",10135,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002Fexamples\u002Fprogressive-enhancement-example.py",{"path":85,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":86,"sourceHtmlUrl":87},"examples\u002Fsecurity-validation-example.py",12797,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002Fexamples\u002Fsecurity-validation-example.py",{"path":89,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":90,"sourceHtmlUrl":91},"examples\u002Ftwo-tier-example.py",7995,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002Fexamples\u002Ftwo-tier-example.py",{"path":93,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":94,"sourceHtmlUrl":95},"templates\u002Fcli-template.py",8471,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002Ftemplates\u002Fcli-template.py",{"path":97,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":98,"sourceHtmlUrl":99},"templates\u002Fdocstring-template.py",15290,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002Ftemplates\u002Fdocstring-template.py",{"path":101,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":102,"sourceHtmlUrl":103},"templates\u002Flibrary-template.py",9684,"https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__akaszubski--library-design-patterns\u002Ftemplates\u002Flibrary-template.py",[105,134,147,174,196,217],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":114,"publishedAt":48},"01M71HY2SNXBA9Q00WZDTZQ31Z","skillguard-codex-scanner","Hybrid deterministic+LLM agent-skill security scanner. Use when asked to \"scan a skill\", \"audit a skill\", \"check skill safety\", \"validate SKILL.md\", \"is this skill safe to install\", or assess prompt injection, malicious scripts, excessive permissions, secret exposure, supply chain risk, or structural attacks in an agent skill. Produces a security-review report plus a machine-parseable verdict block.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fsrc\u002Fskillguard\u002Fstatic_scanner\u002Fskillguard-codex-scanner\u002FSKILL.md",[111],{"categoryNo":112,"categoryName":113,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",[115,116,117,118,119,120,121,122,123,124,125,126,34,127,128,129,130,131,132,133],"scanner","skillguard codex scanner","skillguard","codex","chain","skill security","security-review","review report","structural","secret","prompt injection","security scanner","review","malicious","permissions","exposure","audit","scripts","safe",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":138,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":144,"publishedAt":48},"01M71HY0SPKTT3S27BC2HPAC5M","data-exfiltrator","Analyzes data files","MIT","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Fsmoke-one-skill\u002Fasset1__cisco-ai-defense--data-exfiltrator\u002FSKILL.md",[141],{"categoryNo":142,"categoryName":143,"taxonomyType":25,"taxonomyTypeDesc":26},"01JBSEEDCAT000000000000033","数据分析师",[145,146,39],"data","data exfiltrator",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":48},"01M71HXVS9EMN44BGDW215FZ72","real-time-collaboration-engine","Build real-time collaborative editing with WebSockets, OT\u002FCRDT conflict resolution, and presence awareness. Implements cursor tracking, optimistic updates, and offline sync. Use for collaborative editors, whiteboards, video editing. Activate on \"real-time collaboration\", \"WebSocket sync\", \"multiplayer editing\", \"CRDT\", \"presence awareness\". NOT for simple chat, request-response APIs, or single-user apps.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--real-time-collaboration-engine\u002FSKILL.md",[],[154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173],"time","real time collaboration engine","real time collaboration","collaboration","engine","real time","Video","reliability","video editing","performance","conflict resolution","presence","access","apps","updates","Bash","activate","optimizer","react","streaming",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":183,"publishedAt":48},"01M71HXP6CTY4KFN0QVMMN0V7J","react-performance-optimizer","Optimize React apps for 60fps performance. Implements memoization, virtualization, code splitting, bundle optimization. Use for slow renders, large lists, bundle bloat. Activate on \"React performance\", \"slow render\", \"useMemo\", \"bundle size\", \"virtualization\". NOT for backend optimization, non-React frameworks, or premature optimization.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--react-performance-optimizer\u002FSKILL.md",[180],{"categoryNo":181,"categoryName":182,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000009","前端开发",[163,184,171,172,185,186,187,188,189,190,154,191,192,167,169,193,170,173,194,195],"react performance optimizer","react performance","performance optimizer","app","nextjs","expert","re","render","2025","code","router","strategies",{"skillNo":197,"name":198,"nameZh":6,"description":199,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":200,"categories":201,"keywords":203,"publishedAt":48},"01M71HXH7QXSQB4QTDZ7SP7YXQ","llm-streaming-response-handler","Build production LLM streaming UIs with Server-Sent Events, real-time token display, cancellation, error recovery. Handles OpenAI\u002FAnthropic\u002FClaude streaming APIs. Use for chatbots, AI assistants, real-time text generation. Activate on \"LLM streaming\", \"SSE\", \"token stream\", \"chat UI\", \"real-time AI\". NOT for batch processing, non-streaming APIs, or WebSocket bidirectional chat.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--llm-streaming-response-handler\u002FSKILL.md",[202],{"categoryNo":181,"categoryName":182,"taxonomyType":20,"taxonomyTypeDesc":21},[204,173,205,206,207,208,163,154,209,210,211,169,170,171,212,172,213,214,215,216],"llm streaming response handler","handler","error","processing","retry","chat ui","error recovery","critical","batch","display","text","server","read",{"skillNo":218,"name":219,"nameZh":6,"description":220,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":221,"categories":222,"keywords":230,"publishedAt":48},"01M71HXCB0E1YRKYW1Y8T0Y106","github-actions-pipeline-builder","Build production CI\u002FCD pipelines with GitHub Actions. Implements matrix builds, caching, deployments, testing, security scanning. Use for automated testing, deployments, release workflows. Activate on \"GitHub Actions\", \"CI\u002FCD\", \"workflow\", \"deployment pipeline\", \"automated testing\". NOT for Jenkins\u002FCircleCI, manual deployments, or non-GitHub repositories.","https:\u002F\u002Fgithub.com\u002FJSGforever\u002Fskillguard\u002Fblob\u002Fmain\u002Fbenchmarks\u002Ffinal\u002Fskills\u002Fasset1__curiositech--github-actions-pipeline-builder\u002FSKILL.md",[223,226,229],{"categoryNo":224,"categoryName":225,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":227,"categoryName":228,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000011","运维与部署",{"categoryNo":112,"categoryName":113,"taxonomyType":20,"taxonomyTypeDesc":21},[231,232,233,234,235,236,237,161,189,238,239,240,170,195,241,216,242,243,244,245],"github actions pipeline builder","actions","github actions","pipeline builder","github","builder","pipeline","testing","ci","workflows","run","release","write","edit","git"]