python-env

A project rule that requires Python and package commands to run in the ai-learning-gems conda environment, an isolated setup for project dependencies.

In plain words
What is it for?
Use it whenever project workflows or scripts need Python, pip, or related package commands.
Why use it?
It reduces errors caused by using the wrong Python installation or missing packages.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ai-learning-gems/ai-learning-gems.github.io/python-env
Clone the repo
git clone --depth 1 https://github.com/AI-Learning-Gems/AI-Learning-Gems.github.io

Made for: Cursor.

Per session 386 This file is loaded in full into every session.
When invoked 386 The same file — it is already loaded in full.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00386 $0.00386
Opus 5 $0.00193 $0.00193
Sonnet 5 $0.00077 $0.00077
Haiku 4.5 $0.00039 $0.00039

Measured 2d ago against content hash 3ee296eb6869, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

python-env scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- **ALWAYS** double-quote file paths in `rm` commands to prevent word-splitting on spaces, e.g. `rm -rf "/path/to/folder/"`.
.cursor/rules/python-env.mdc · 33 lines

What it actually says

Python Environment

This project uses a conda environment named ai-learning-gems.

Terminal Commands

PREFERRED: Use the full path to the Python executable. This works reliably in all contexts (interactive shells, IDE subprocesses, subagents, non-interactive scripts):

$(conda info --base)/envs/ai-learning-gems/bin/python script.py

FALLBACK: If you are in an interactive terminal where conda has been initialized, you can activate the env:

conda activate ai-learning-gems

WHY: conda activate requires shell hooks from conda init which are loaded by .zshrc/.bashrc. IDE-spawned subshells (Cursor, Antigravity, Windsurf) often don't source these files, causing CondaError: Run 'conda init' before 'conda activate'. The full path approach bypasses this entirely.

Rules

  • ALWAYS use $(conda info --base)/envs/ai-learning-gems/bin/python when running Python in terminal commands, especially in workflows and subagents.
  • For pip and uv pip, use: $(conda info --base)/envs/ai-learning-gems/bin/pip or activate first if in an interactive shell.
  • NEVER use bare python or pip without the env path or activation.
  • NEVER use the base conda env or system Python.
  • ALWAYS double-quote file paths in rm commands to prevent word-splitting on spaces, e.g. rm -rf "/path/to/folder/".
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 33 lines · 386 tokens per session scan C 3ee296eb6869

Subscribe to this mod's changes

python-env is a cursor rule published in the GitHub repository AI-Learning-Gems/AI-Learning-Gems.github.io (22 stars, last pushed 2mo ago), licensed MIT. It adds 386 tokens to every session, about $0.0019 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.