Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Rules Python?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-rules-python)
---
name: rules-python
description: "ANVIL coding rules for python code (**/*.py, **/test_*.py, **/*_test.py, tests/**/*.py): Python Security, Python, Python Testing."
---
<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->
# ANVIL rules: python
Follow these rules for python code (**/*.py, **/test_*.py, **/*_test.py, tests/**/*.py).
## Python Security
# Python Security
- Never call `pickle.loads`, `yaml.load` (use `yaml.safe_load`), `eval`, or `exec` on untrusted data.
- Invoke OS commands with `subprocess.run([...], shell=False)` using argument lists rather than interpolated shell strings.
- Use parameterized SQL (`cursor.execute("... WHERE id = %s", (id,))`) or ORM bindings; never build queries with f-strings.
- Use `secrets` for tokens and `hmac.compare_digest` for MAC comparison; validate outbound URLs against SSRF and resolve paths within allowed roots.
## Python
# Python
- Type hints on public functions; run the configured type checker.
- Specific exceptions; `raise ... from err` to keep context; no bare `except:`.
- Context managers for files, locks and connections.
- `subprocess.run([...], check=True)` with argument lists; never `shell=True` on untrusted input.
- Format and lint with the project's tools (e.g. ruff, black).
## Python Testing
# Python Testing
- pytest with fixtures; parametrize cases instead of loops.
- No network or real clock in unit tests; use monkeypatch/freezegun-style tools.