[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6H6DADNY4KDR9GNG2GSJA98":3,"skill-same:01M6H6DADNY4KDR9GNG2GSJA98":66},{"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":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":50,"ownerDescription":6,"updatedAt":51,"install":52,"resources":65},"01M6H6DADNY4KDR9GNG2GSJA98","m12-lifecycle",null,"Use when designing resource lifecycles. Keywords: RAII, Drop, resource lifecycle, connection pool, lazy initialization, connection pool design, resource cleanup patterns, cleanup, scope, OnceCell, Lazy, once_cell, OnceLock, transaction, session management, when is Drop called, cleanup on error, guard pattern, scope guard, 资源生命周期, 连接池, 惰性初始化, 资源清理, RAII 模式","0xharryriddle\u002Fcodex-field-kit","0xharryriddle","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F100945007?v=4","01M6H686JV0QKZYP2RWG6B2B8T","harryriddle","01M6H686PVZ8JGKWEG7B3GM5PD",3,"MIT","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Farchive\u002Fupstream\u002Fchasebuild-agent-skills\u002Frust\u002Fskills\u002Fm12-lifecycle\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"lifecycle","m12 lifecycle","transaction","initialization","connection","session management","raii","error","scope","初始化","false","cell","design","pattern","drop","use","session","management","guard","cleanup","2026-11-10 10:12:30",false,"---\nname: m12-lifecycle\ndescription: \"Use when designing resource lifecycles. Keywords: RAII, Drop, resource lifecycle, connection pool, lazy initialization, connection pool design, resource cleanup patterns, cleanup, scope, OnceCell, Lazy, once_cell, OnceLock, transaction, session management, when is Drop called, cleanup on error, guard pattern, scope guard, 资源生命周期, 连接池, 惰性初始化, 资源清理, RAII 模式\"\nuser-invocable: false\n---\n\n# Resource Lifecycle\n\n> **Layer 2: Design Choices**\n\n## Core Question\n\n**When should this resource be created, used, and cleaned up?**\n\nBefore implementing lifecycle:\n- What's the resource's scope?\n- Who owns the cleanup responsibility?\n- What happens on error?\n\n---\n\n## Lifecycle Pattern → Implementation\n\n| Pattern | When | Implementation |\n|---------|------|----------------|\n| RAII | Auto cleanup | `Drop` trait |\n| Lazy init | Deferred creation | `OnceLock`, `LazyLock` |\n| Pool | Reuse expensive resources | `r2d2`, `deadpool` |\n| Guard | Scoped access | `MutexGuard` pattern |\n| Scope | Transaction boundary | Custom struct + Drop |\n\n---\n\n## Thinking Prompt\n\nBefore designing lifecycle:\n\n1. **What's the resource cost?**\n   - Cheap → create per use\n   - Expensive → pool or cache\n   - Global → lazy singleton\n\n2. **What's the scope?**\n   - Function-local → stack allocation\n   - Request-scoped → passed or extracted\n   - Application-wide → static or Arc\n\n3. **What about errors?**\n   - Cleanup must happen → Drop\n   - Cleanup is optional → explicit close\n   - Cleanup can fail → Result from close\n\n---\n\n## Trace Up ↑\n\nTo domain constraints (Layer 3):\n\n```\n\"How should I manage database connections?\"\n    ↑ Ask: What's the connection cost?\n    ↑ Check: domain-* (latency requirements)\n    ↑ Check: Infrastructure (connection limits)\n```\n\n| Question | Trace To | Ask |\n|----------|----------|-----|\n| Connection pooling | domain-* | What's acceptable latency? |\n| Resource limits | domain-* | What are infra constraints? |\n| Transaction scope | domain-* | What must be atomic? |\n\n---\n\n## Trace Down ↓\n\nTo implementation (Layer 1):\n\n```\n\"Need automatic cleanup\"\n    ↓ m02-resource: Implement Drop\n    ↓ m01-ownership: Clear owner for cleanup\n\n\"Need lazy initialization\"\n    ↓ m03-mutability: OnceLock for thread-safe\n    ↓ m07-concurrency: LazyLock for sync\n\n\"Need connection pool\"\n    ↓ m07-concurrency: Thread-safe pool\n    ↓ m02-resource: Arc for sharing\n```\n\n---\n\n## Quick Reference\n\n| Pattern | Type | Use Case |\n|---------|------|----------|\n| RAII | `Drop` trait | Auto cleanup on scope exit |\n| Lazy Init | `OnceLock`, `LazyLock` | Deferred initialization |\n| Pool | `r2d2`, `deadpool` | Connection reuse |\n| Guard | `MutexGuard` | Scoped lock release |\n| Scope | Custom struct | Transaction boundaries |\n\n## Lifecycle Events\n\n| Event | Rust Mechanism |\n|-------|----------------|\n| Creation | `new()`, `Default` |\n| Lazy Init | `OnceLock::get_or_init` |\n| Usage | `&self`, `&mut self` |\n| Cleanup | `Drop::drop()` |\n\n## Pattern Templates\n\n### RAII Guard\n\n```rust\nstruct FileGuard {\n    path: PathBuf,\n    _handle: File,\n}\n\nimpl Drop for FileGuard {\n    fn drop(&mut self) {\n        \u002F\u002F Cleanup: remove temp file\n        let _ = std::fs::remove_file(&self.path);\n    }\n}\n```\n\n### Lazy Singleton\n\n```rust\nuse std::sync::OnceLock;\n\nstatic CONFIG: OnceLock\u003CConfig> = OnceLock::new();\n\nfn get_config() -> &'static Config {\n    CONFIG.get_or_init(|| {\n        Config::load().expect(\"config required\")\n    })\n}\n```\n\n---\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| Resource leak | Forgot Drop | Implement Drop or RAII wrapper |\n| Double free | Manual memory | Let Rust handle |\n| Use after drop | Dangling reference | Check lifetimes |\n| E0509 move out of Drop | Moving owned field | `Option::take()` |\n| Pool exhaustion | Not returned | Ensure Drop returns |\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why Bad | Better |\n|--------------|---------|--------|\n| Manual cleanup | Easy to forget | RAII\u002FDrop |\n| `lazy_static!` | External dep | `std::sync::OnceLock` |\n| Global mutable state | Thread unsafety | `OnceLock` or proper sync |\n| Forget to close | Resource leak | Drop impl |\n\n---\n\n## Related Skills\n\n| When | See |\n|------|-----|\n| Smart pointers | m02-resource |\n| Thread-safe init | m07-concurrency |\n| Domain scopes | m09-domain |\n| Error in cleanup | m06-error-handling |\n","# Resource Lifecycle\n\n> **Layer 2: Design Choices**\n\n## Core Question\n\n**When should this resource be created, used, and cleaned up?**\n\nBefore implementing lifecycle:\n- What's the resource's scope?\n- Who owns the cleanup responsibility?\n- What happens on error?\n\n---\n\n## Lifecycle Pattern → Implementation\n\n| Pattern | When | Implementation |\n|---------|------|----------------|\n| RAII | Auto cleanup | `Drop` trait |\n| Lazy init | Deferred creation | `OnceLock`, `LazyLock` |\n| Pool | Reuse expensive resources | `r2d2`, `deadpool` |\n| Guard | Scoped access | `MutexGuard` pattern |\n| Scope | Transaction boundary | Custom struct + Drop |\n\n---\n\n## Thinking Prompt\n\nBefore designing lifecycle:\n\n1. **What's the resource cost?**\n   - Cheap → create per use\n   - Expensive → pool or cache\n   - Global → lazy singleton\n\n2. **What's the scope?**\n   - Function-local → stack allocation\n   - Request-scoped → passed or extracted\n   - Application-wide → static or Arc\n\n3. **What about errors?**\n   - Cleanup must happen → Drop\n   - Cleanup is optional → explicit close\n   - Cleanup can fail → Result from close\n\n---\n\n## Trace Up ↑\n\nTo domain constraints (Layer 3):\n\n```\n\"How should I manage database connections?\"\n    ↑ Ask: What's the connection cost?\n    ↑ Check: domain-* (latency requirements)\n    ↑ Check: Infrastructure (connection limits)\n```\n\n| Question | Trace To | Ask |\n|----------|----------|-----|\n| Connection pooling | domain-* | What's acceptable latency? |\n| Resource limits | domain-* | What are infra constraints? |\n| Transaction scope | domain-* | What must be atomic? |\n\n---\n\n## Trace Down ↓\n\nTo implementation (Layer 1):\n\n```\n\"Need automatic cleanup\"\n    ↓ m02-resource: Implement Drop\n    ↓ m01-ownership: Clear owner for cleanup\n\n\"Need lazy initialization\"\n    ↓ m03-mutability: OnceLock for thread-safe\n    ↓ m07-concurrency: LazyLock for sync\n\n\"Need connection pool\"\n    ↓ m07-concurrency: Thread-safe pool\n    ↓ m02-resource: Arc for sharing\n```\n\n---\n\n## Quick Reference\n\n| Pattern | Type | Use Case |\n|---------|------|----------|\n| RAII | `Drop` trait | Auto cleanup on scope exit |\n| Lazy Init | `OnceLock`, `LazyLock` | Deferred initialization |\n| Pool | `r2d2`, `deadpool` | Connection reuse |\n| Guard | `MutexGuard` | Scoped lock release |\n| Scope | Custom struct | Transaction boundaries |\n\n## Lifecycle Events\n\n| Event | Rust Mechanism |\n|-------|----------------|\n| Creation | `new()`, `Default` |\n| Lazy Init | `OnceLock::get_or_init` |\n| Usage | `&self`, `&mut self` |\n| Cleanup | `Drop::drop()` |\n\n## Pattern Templates\n\n### RAII Guard\n\n```rust\nstruct FileGuard {\n    path: PathBuf,\n    _handle: File,\n}\n\nimpl Drop for FileGuard {\n    fn drop(&mut self) {\n        \u002F\u002F Cleanup: remove temp file\n        let _ = std::fs::remove_file(&self.path);\n    }\n}\n```\n\n### Lazy Singleton\n\n```rust\nuse std::sync::OnceLock;\n\nstatic CONFIG: OnceLock\u003CConfig> = OnceLock::new();\n\nfn get_config() -> &'static Config {\n    CONFIG.get_or_init(|| {\n        Config::load().expect(\"config required\")\n    })\n}\n```\n\n---\n\n## Common Errors\n\n| Error | Cause | Fix |\n|-------|-------|-----|\n| Resource leak | Forgot Drop | Implement Drop or RAII wrapper |\n| Double free | Manual memory | Let Rust handle |\n| Use after drop | Dangling reference | Check lifetimes |\n| E0509 move out of Drop | Moving owned field | `Option::take()` |\n| Pool exhaustion | Not returned | Ensure Drop returns |\n\n---\n\n## Anti-Patterns\n\n| Anti-Pattern | Why Bad | Better |\n|--------------|---------|--------|\n| Manual cleanup | Easy to forget | RAII\u002FDrop |\n| `lazy_static!` | External dep | `std::sync::OnceLock` |\n| Global mutable state | Thread unsafety | `OnceLock` or proper sync |\n| Forget to close | Resource leak | Drop impl |\n\n---\n\n## Related Skills\n\n| When | See |\n|------|-----|\n| Smart pointers | m02-resource |\n| Thread-safe init | m07-concurrency |\n| Domain scopes | m09-domain |\n| Error in cleanup | m06-error-handling |\n",{"name":5,"description":7,"user-invocable":40},"main","6c13f6f4ac5a3bc1e6b78cd2bb1704f122c4a73e","archive\u002Fupstream\u002Fchasebuild-agent-skills\u002Frust\u002Fskills\u002Fm12-lifecycle",0,"https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit","https:\u002F\u002Fgithub.com\u002F0xharryriddle","https:\u002F\u002Fharryriddle.vercel.app","2026-04-11 11:49:51",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add 0xharryriddle\u002Fcodex-field-kit --skill m12-lifecycle",{"tool":58,"command":59},"bunx","bunx skills add 0xharryriddle\u002Fcodex-field-kit --skill m12-lifecycle",{"tool":61,"command":62},"pnpm","pnpm dlx skills add 0xharryriddle\u002Fcodex-field-kit --skill m12-lifecycle","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Farchive\u002Fupstream\u002Fchasebuild-agent-skills\u002Frust\u002Fskills\u002Fm12-lifecycle\u002FSKILL.md",true,[],[67,99,118,128,154,181],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":78,"publishedAt":39},"01M6H7ZKE6MR33HC84QZ1TA6MV","vercel-react-best-practices","React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React\u002FNext.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Fskills\u002Fvercel-react-best-practices\u002FSKILL.md",[73],{"categoryNo":74,"categoryName":75,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000009","前端开发","SCENARIO","使用场景",[79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98],"react best practices","react","vercel react best practices","best practices","vercel","tasks","data fetching","triggers","pages","next","performance optimization","refactoring","Next.js","Optimization","code","guidelines","react components","components","performance","writing",{"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":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":39},"01M6H7ZGC2WK8SEKYHWDNTMDA9","swarm-planner","[EXPLICIT INVOCATION ONLY] Creates dependency-aware implementation plans optimized for parallel multi-agent execution.","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Fskills\u002Fswarm-planner\u002FSKILL.md",[],[106,107,108,109,110,111,112,113,114,115,116,117],"swarm","swarm planner","planner","parallel","multi-agent","only","execution","plans","dependency","for","multi","implementation",{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":39},"01M6H7ZD93853RZCYQWH1D38TM","super-swarm-spark","Only to be triggered by explicit super-swarm-spark commands.","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Fskills\u002Fsuper-swarm-spark\u002FSKILL.md",[],[125,106,126,111,127],"super swarm spark","spark","commands",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":39},"01M6H7Z987QBY49JCCPT953EAZ","role-creator","Create and install Codex custom agent roles in ~\u002F.codex\u002Fconfig.toml, generate role config files, enforce supported keys, and guide users through required role inputs (model, reasoning effort, developer_instructions).","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Fskills\u002Frole-creator\u002FSKILL.md",[],[135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153],"role","creator","role creator","keys","users","roles","toml","enforce","install","guide","instructions","model","developer","reasoning","generate","create","config","codex","files",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":163,"publishedAt":39},"01M6H7Z5TRPMDQ7YSZQXPN1G60","read-github","Read and search GitHub repository documentation via gitmcp.io MCP service.\n\n**WHEN TO USE:**\n- User provides a GitHub URL\n- User mentions a specific repo in owner\u002Frepo format\n- User asks \"what does this repo do?\", \"read the docs for X repo\", or similar\n- User wants to search code or docs within a repo","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Fskills\u002Fread-github\u002FSKILL.md",[160],{"categoryNo":161,"categoryName":162,"taxonomyType":76,"taxonomyTypeDesc":77},"01JBSEEDCAT000000000000023","Skill与智能体开发",[164,165,166,93,167,168,169,170,115,171,172,173,174,175,176,34,177,178,179,180],"github","read github","read","documentation","docs","MCP","search","when to use","URL","via","io","service","do","user","repo","format","repository",{"skillNo":182,"name":108,"nameZh":6,"description":183,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":184,"categories":185,"keywords":186,"publishedAt":39},"01M6H7Z215CTKYJ4Y1X6EQWN6M","Create comprehensive, phased implementation plans with sprints and atomic tasks. Use when user says: \"make a plan\", \"create a plan\", \"plan this out\", \"plan the implementation\", \"help me plan\", \"design a plan\", \"draft a plan\", \"write a plan\", \"outline the steps\", \"break this down into tasks\", \"what's the plan for\", or any similar planning request. Also triggers on explicit \"\u002Fplanner\" or \"\u002Fplan\" commands.","https:\u002F\u002Fgithub.com\u002F0xharryriddle\u002Fcodex-field-kit\u002Fblob\u002Fmain\u002Fskills\u002Fplanner\u002FSKILL.md",[],[108,187,115,188,189,190,86,113,127,191,192,34,193,194,195,196,197,150,84,31],"outline","atomic","with","sprints","draft","me","write","phased implementation","plan","help","planning"]