Rule Python

Context Managers

Use with statements for resource management

pythonresourcessafety
CLAUDE.md

Use context managers (with statements) for files, database connections, locks, and any resource that needs cleanup. They guarantee cleanup even when exceptions occur.

Copy this block into your CLAUDE.md or agent config file to enforce it in your workflow.

get crystl