exomind-team/exomind/m12-lifecycle
Claude Code and agent skill by exomind-team/exomind
- community
Checking that the SKILL.md file is still in the repository.
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 模式
Install
npx vskill@latest install exomind-team/exomind/m12-lifecycleSKILL.md
The same SKILL.md was published earlier as actionbook/rust-skills/m12-lifecycle.
Resource Lifecycle
Layer 2: Design Choices
Core Question
When should this resource be created, used, and cleaned up?
Before implementing lifecycle:
- What's the resource's scope?
- Who owns the cleanup responsibility?
- What happens on error?
Lifecycle Pattern → Implementation
| Pattern | When | Implementation | |
|---|---|---|---|
| RAII | Auto cleanup | Drop trait | |
| Lazy init | Deferred creation | OnceLock, LazyLock | |
| Pool | Reuse expensive resources | r2d2, deadpool | |
| Guard | Scoped access | MutexGuard pattern | |
| Scope | Transaction boundary | Custom struct + Drop |
Thinking Prompt
Before designing lifecycle:
- What's the resource cost?
- Cheap → create per use
- Expensive → pool or cache
- Global → lazy singleton
- What's the scope?
- Function-local → stack allocation
- Request-scoped → passed or extracted
- Application-wide → static or Arc
- What about errors?
- Cleanup must happen → Drop
- Cleanup is optional → explicit close
- Cleanup can fail → Result from close
Trace Up ↑
To domain constraints (Layer 3):
| Question | Trace To | Ask | |
|---|---|---|---|
| Connection pooling | domain-* | What's acceptable latency? | |
| Resource limits | domain-* | What are infra constraints? | |
| Transaction scope | domain-* | What must be atomic? |
Trace Down ↓
To implementation (Layer 1):
Quick Reference
| Pattern | Type | Use Case | |
|---|---|---|---|
| RAII | Drop trait | Auto cleanup on scope exit | |
| Lazy Init | OnceLock, LazyLock | Deferred initialization | |
| Pool | r2d2, deadpool | Connection reuse | |
| Guard | MutexGuard | Scoped lock release | |
| Scope | Custom struct | Transaction boundaries |
Lifecycle Events
| Event | Rust Mechanism | |
|---|---|---|
| Creation | new(), Default | |
| Lazy Init | OnceLock::get_or_init | |
| Usage | &self, &mut self | |
| Cleanup | Drop::drop() |
Pattern Templates
RAII Guard
Lazy Singleton
Common Errors
| Error | Cause | Fix | |
|---|---|---|---|
| Resource leak | Forgot Drop | Implement Drop or RAII wrapper | |
| Double free | Manual memory | Let Rust handle | |
| Use after drop | Dangling reference | Check lifetimes | |
| E0509 move out of Drop | Moving owned field | Option::take() | |
| Pool exhaustion | Not returned | Ensure Drop returns |
Anti-Patterns
| Anti-Pattern | Why Bad | Better | |
|---|---|---|---|
| Manual cleanup | Easy to forget | RAII/Drop | |
lazy_static! | External dep | std::sync::OnceLock | |
| Global mutable state | Thread unsafety | OnceLock or proper sync | |
| Forget to close | Resource leak | Drop impl |
Related Skills
| When | See | |
|---|---|---|
| Smart pointers | m02-resource | |
| Thread-safe init | m07-concurrency | |
| Domain scopes | m09-domain | |
| Error in cleanup | m06-error-handling |
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/m12-lifecycle/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/exomind-team/exomind/m12-lifecycle)