m12-lifecycle — Claude Code skill: lifecycle and install
Helps design Rust resource lifecycles, from creation and scope to cleanup and error handling. Useful for connections, transactions, guards, and lazy initialization.
npx skills add actionbook/rust-skills --skill m12-lifecycle -a claude-codeWhat m12-lifecycle does
This skill helps choose how a Rust resource should be created, owned, used, and cleaned up. It maps RAII to Drop, deferred creation to OnceLock and LazyLock, expensive resource reuse to r2d2 or deadpool, and scoped access to the MutexGuard pattern.
It includes design questions about scope and cleanup ownership, lifecycle event tables, RAII guard and lazy singleton templates, plus common failures such as leaks, double free, E0509, and pool exhaustion. Related paths connect the decisions to m02-resource, m03-mutability, m06-error-handling, and m07-concurrency.
When cleanup itself can fail, the skill points to an explicit close that returns Result, so that case deserves a separate design check before relying on Drop. For cleanup at scope exit, it uses Drop with an RAII wrapper.
What it helps with
- choose a resource scope
- design cleanup for error paths
- set up lazy initialization
- select a pool for costly connections
- trace why a resource pool is exhausted
Example prompts for the agent
- Design a Rust lifecycle for database connections, covering creation cost, scope, ownership, and cleanup on errors.
- Compare
Drop,OnceLock,LazyLock, and a connection pool for this resource, then recommend an implementation. - Inspect this resource leak and show where
Dropshould return the resource to the pool.
How to install m12-lifecycle
1Skills CLI (Vercel)
npx skills add actionbook/rust-skills --skill m12-lifecycle -a claude-code2Manually: put the files in place
~/.claude/skills/m12-lifecycle/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/m12-lifecycle/
1Skills CLI (Vercel)
npx skills add actionbook/rust-skills --skill m12-lifecycle -a codex2Manually: put the files in place
.agents/skills/m12-lifecycle/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add actionbook/rust-skills --skill m12-lifecycle -a cursor2Manually: put the files in place
.cursor/skills/m12-lifecycle/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install actionbook/rust-skills m12-lifecycle2Manually: put the files in place
.github/skills/m12-lifecycle/SKILL.md1Skills CLI (Vercel)
npx skills add actionbook/rust-skills --skill m12-lifecycle -a gemini-cli2Platform CLI
gemini skills install https://github.com/actionbook/rust-skills --path skills/m12-lifecycleManually: put the files in place
.devin/skills/m12-lifecycle/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add actionbook/rust-skills --skill m12-lifecycle -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about m12-lifecycle
How do I install m12-lifecycle in Claude Code?
Run npx skills add actionbook/rust-skills --skill m12-lifecycle -a claude-code, then run the same command again: npx skills add actionbook/rust-skills --skill m12-lifecycle -a claude-code. The skill file is at ~/.claude/skills/m12-lifecycle/SKILL.md.
What does m12-lifecycle do?
It helps choose a Rust resource lifecycle pattern: RAII with Drop, lazy initialization, pooling, scoped guards, or transaction boundaries. It also covers cleanup on errors and common ownership mistakes.
Which Rust tools does it use for lazy initialization?
The skill covers OnceLock and LazyLock for deferred creation. Its related guidance connects OnceLock with thread-safe initialization and LazyLock with synchronization.