Agent skill

python-resource-management

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.

Seth Hobson38,331★ · +219/wk · 1 repos on radarProfile →
claude-codecodexcopilotcursorMIT
Install
npx skills add wshobson/agents --skill python-resource-management --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 7 KB
Bundled scripts: none
Path: plugins/python-development/skills/python-resource-management/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 38,479 · +148 this week
Language: Python
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Python Resource Management Manage resources deterministically using context managers. Resources like database connections, file handles, and network sockets should be released reliably, even when exceptions occur. ## When to Use This Skill - Managing database connections and connection pools - Working with file handles and I/O - Implementing custom context managers - Building streaming responses with state - Handling nested resource cleanup - Creating async context managers ## Core Concepts ### 1. Context Managers The `with` statement ensures resources are released automatically, even on exceptions. ### 2. Protocol Methods `__enter__`/`__exit__` for sync, `__aenter__`/`__aexit__` for async resource management. ### 3. Unconditional Cleanup `__exit__` always runs, regardless of whether an exception occurred. ### 4. Exception Handling Return `True` from `__exit__` to suppress exceptions, `False` to propagate them. ## Quick Start ```python from contextlib import contextmanager @contextmanager def managed_resource(): resource = acquire_resource() try: yield resource finally: resource.cleanup() with managed_resource() as r: r.do_work() ``` ## Fundamental Patterns ### Pattern 1: Class-B

What's inside
Steps it walks through
  1. When to Use This Skill
  2. Core Concepts
  3. 1. Context Managers
  4. 2. Protocol Methods
  5. 3. Unconditional Cleanup
  6. 4. Exception Handling
  7. Quick Start
  8. Fundamental Patterns
  9. Pattern 1: Class-Based Context Manager
  10. Pattern 2: Async Context Manager
  11. Pattern 3: Using @contextmanager Decorator
  12. Pattern 4: Unconditional Resource Release
  13. Detailed worked examples and patterns
  14. Best Practices Summary
Ships with 1 file
  • references/details.md
More from agents
All skills →
About this skill
What does the python-resource-management skill do?

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.

How do I install it?

Run `npx skills add wshobson/agents --skill python-resource-management --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From wshobson/agents, a repository with 38,479 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going