python-resource-management Skill for Claude: What It Does and How to Install It
Teaches your assistant to release Python resources reliably with context managers.
- Installs
- 11.2K
- on skills.sh
- Stars
- 42.1K
- on GitHub
- Files
- 1
- besides SKILL.md
- Updated
- Oct 2026
- last repo commit
SKILL.md covers four core concepts (context managers, protocol methods, unconditional cleanup, exception handling) and four patterns: a class-based context manager, an async context manager, the @contextmanager decorator and unconditional release. It ends with a list of 10 best practices.
Its "When to Use" list covers database connections and pools, file handles, custom and async context managers, streaming responses with state and nested cleanup. Five more patterns, including ExitStack and stream metrics, sit in references/details.md. It bundles no scripts.
Good for
- Python developers fixing leaked connections
- Teams managing connection pools
- Anyone writing custom context managers
Install python-resource-management
Claude Code
- 1
Copy this prompt.
Install the python-resource-management skill in Claude Code. Run this command: /plugin marketplace add wshobson/agents /plugin install python-development@claude-code-workflows Then check that it loaded and tell me how to use it.
- 2
Paste it into Claude Code. It shows the change and asks before running it.
Pick one route. The plugin routes install the whole python-development plugin: 3 agents, 1 command and 16 skills (counted from the plugin folder in the repo tree, which has no hooks or MCP config files). The skills-only routes install just this skill, with no agents or commands.
From the project README. Source.
What's in the skill
When it loads
Python resource management with context managers, cleanup patterns, and streaming. Use when managing connections, file handles, implementing cleanup logic, or building streaming responses with accumulated state.
Sections in SKILL.md
- When to Use This Skill
- Core Concepts
- 1. Context Managers
- 2. Protocol Methods
- 3. Unconditional Cleanup
- 4. Exception Handling
- Quick Start
- Fundamental Patterns
- Pattern 1: Class-Based Context Manager
- Pattern 2: Async Context Manager
- Pattern 3: Using @contextmanager Decorator
- Pattern 4: Unconditional Resource Release
- Detailed worked examples and patterns
- Best Practices Summary
Key facts
- Author
- wshobson (repo owner)
- License
- MIT
- Installs on skills.sh
- 11,203 (Nov 2, 2026)
- Last repo commit
- Oct 30, 2026
- What it includes
- 2 files including SKILL.md: references/details.md (no scripts)
What it includes
Context managers, protocol methods, unconditional cleanup and exception handling
Context managers, protocol methods, unconditional cleanup and exception handling.
Core concepts__enter__ and __exit__ for complex resources, such as a database connection
__enter__ and __exit__ for complex resources, such as a database connection.
Pattern 1: Class-based context manager__aenter__ and __aexit__ for an async connection pool
__aenter__ and __aexit__ for an async connection pool.
Pattern 2: Async context managerA timing block and an async transaction with commit and rollback
A timing block and an async transaction with commit and rollback.
Pattern 3: @contextmanager decoratorA file processor that closes files and removes temp files in __exit__
A file processor that closes files and removes temp files in __exit__.
Pattern 4: Unconditional resource releaseTen rules, such as clean up unconditionally and do not suppress exceptions by accident
Ten rules, such as clean up unconditionally and do not suppress exceptions by accident.
Best practices summarySuppress only specific, documented exceptions
Suppress only specific, documented exceptions (in references/details.md)
Pattern 5: Selective exception suppressionKeep chunks and accumulated state while streaming
Keep chunks and accumulated state while streaming (in references/details.md)
Pattern 6: Streaming with accumulated stateList and join instead of repeated concatenation
List and join instead of repeated concatenation (in references/details.md)
Pattern 7: Efficient string accumulationTime to first byte and total streaming time
Time to first byte and total streaming time (in references/details.md)
Pattern 8: Tracking stream metricsManage a dynamic number of resources
Manage a dynamic number of resources (in references/details.md)
Pattern 9: ExitStack
From the official docs
Questions
What does the python-resource-management skill do?
It gives the assistant a resource-cleanup playbook: nine context-manager patterns for connections, files, streams and dynamic sets of resources.
How do I install python-resource-management?
Use the install box at the top of this page. For Claude Code it lists the plugin route (/plugin marketplace add wshobson/agents, then /plugin install python-development@claude-code-workflows) and two skills-only commands: npx skills add wshobson/agents --skill python-resource-management and gh skill install wshobson/agents python-resource-management (GitHub CLI 2.90 or later), which skip the plugin's agents and commands.
Does it need any libraries or keys?
SKILL.md names no API key. Its samples reference psycopg, asyncpg and structlog, so code written in that style needs those packages in your project.
Is it safe?
Its folder holds two Markdown files and no scripts. The samples open files, connect to a database and, in Pattern 4, delete temporary files during cleanup, so review generated cleanup code before you run it on real paths or data.
Should I install the whole python-development plugin?
Only if you want the rest. The README documents a plugin route for Claude Code and Codex. The python-development plugin folder holds 3 agents, 1 command and 16 skills, and its repo tree shows no hooks or MCP config files. The install box offers the plugin and the skills-only commands.
Does it work in Codex or Cursor?
The README documents Codex CLI as a plugin route and a skills-only install. For Cursor it points to a plugin marketplace and its setup docs, which we did not check, so follow the README there.
Is this skill from Anthropic?
No. It is in wshobson/agents, a community collection. The skill sits in the python-development plugin there, alongside other skills.
Information
updated Nov 2, 2026
- Repository
- wshobson/agents
- Folder
plugins/python-development/skills/python-resource-management
Sources
Docs, issue trackers and discussions this page is built from.
Show all 5Hide
- python-resource-management SKILL.md · github.com
- wshobson/agents README · github.com
- python-development plugin.json · github.com
- wshobson/agents marketplace.json · github.com
- details.md · github.com