pyproject-dependencies

pyproject-dependencies is a cursor rule for Cursor from wiggitywhitney/mcp-commit-story. It costs 0 tokens per session (872 once invoked), scanned A, original, MIT.

A project rule for declaring Python package requirements in `pyproject.toml`, the standard configuration file used to describe a Python project. It separates production packages from development-only packages.

In plain words
What is it for?
Use it whenever production or test code imports a new external library. It helps decide where to record that library and checks that dependencies are declared before committing changes.
Why use it?
It prevents code from working only on a developer's machine while failing in continuous integration, where packages are installed from the project configuration. It addresses errors such as `ModuleNotFoundError`, which means Python cannot find an imported package.

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/wiggitywhitney/mcp-commit-story/pyproject-dependencies
Clone the repo
git clone --depth 1 https://github.com/wiggitywhitney/mcp-commit-story

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pyproject-dependencies

README.md
[![agentmods](https://agentmods.dev/badge/rules/wiggitywhitney/mcp-commit-story/pyproject-dependencies.svg)](https://agentmods.dev/rules/wiggitywhitney/mcp-commit-story/pyproject-dependencies)
Your own site
<a href="https://agentmods.dev/rules/wiggitywhitney/mcp-commit-story/pyproject-dependencies"><img src="https://agentmods.dev/badge/rules/wiggitywhitney/mcp-commit-story/pyproject-dependencies.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 872 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00000 $0.00872
Opus 5 $0.00000 $0.00436
Sonnet 5 $0.00000 $0.00174
Haiku 4.5 $0.00000 $0.00087

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

Security

Grade A, and why

pyproject-dependencies scanned grade A with 0 findings 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 5d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/pyproject-dependencies.mdc · 82 lines

What it actually says

pyproject.toml Dependency Management

  • Critical Rule: All Production Dependencies Must Be in pyproject.toml

    • CI environment ONLY installs from pyproject.toml main dependencies section
    • Never rely on requirements.txt or other dependency files for production code
    • Dev dependencies go in [project.optional-dependencies.dev] section
  • When to Update pyproject.toml Dependencies:

    • Every time you add a new import statement in production code (src/ directory)
    • When adding new test dependencies that import external packages
    • Before committing code that uses new libraries
    • When CI fails with ModuleNotFoundError but tests pass locally
  • Common CI Failure Pattern Recognition:

    # CI Error Pattern:
    ModuleNotFoundError: No module named 'some_package'
    # But locally: tests pass ✅
    
    # Root Cause: Package installed locally but missing from pyproject.toml
    # Solution: Add to main dependencies section
    
  • Dependency Addition Checklist:

    # ✅ DO: When you add imports like this
    from opentelemetry.exporter.prometheus import PrometheusMetricReader
    from opentelemetry.instrumentation.requests import RequestsInstrumentor
    
    # ✅ DO: Immediately add to pyproject.toml
    dependencies = [
        "opentelemetry-exporter-prometheus>=0.54b0",
        "opentelemetry-instrumentation-requests>=0.41b0",
    ]
    
  • Version Specification Best Practices:

    • Research actual available versions on PyPI before specifying
    • Don't assume version patterns across related packages (e.g., OpenTelemetry packages have different schemes)
    • Check for yanked versions if you get "no matching distribution" errors
    • Use conservative version constraints (>=X.Y.Z) rather than exact pins for libraries
  • Local vs CI Environment Differences:

    • Local development often has extra packages from manual installs, requirements.txt, or previous environments
    • CI is clean and only installs what's explicitly declared in pyproject.toml
    • Always test dependency changes with a clean virtual environment when possible
    • Push dependency updates immediately after adding new imports to catch issues early
  • Error Resolution Workflow:

    1. CI fails with ModuleNotFoundError → Check if package is in pyproject.toml main dependencies
    2. Local tests pass but CI fails → Almost always a missing dependency issue
    3. "No matching distribution found" → Check available versions on PyPI, look for yanked versions
    4. Import works locally → Verify the package name and version in pyproject.toml
  • Prevention Strategy:

    • Add dependencies BEFORE writing the import when possible
    • Use pip install package-name AND update pyproject.toml when adding new packages
    • Review imports in every commit to ensure corresponding dependencies exist
    • Test in clean environments periodically to catch environment drift
  • Examples from This Project:

    # ❌ DON'T: Add imports without updating pyproject.toml
    from opentelemetry.exporter.prometheus import PrometheusMetricReader  # CI will fail!
    
    # ✅ DO: Add import AND update pyproject.toml
    from opentelemetry.exporter.prometheus import PrometheusMetricReader
    # In pyproject.toml: "opentelemetry-exporter-prometheus>=0.54b0"
    
  • Historical Issues Resolved:

    • Auto-instrumentation packages (requests, aiohttp, asyncio, logging instrumentors)
    • Prometheus exporter with version specification corrections
    • Pattern: Code worked locally, CI failed on import, fixed by adding to pyproject.toml

This rule prevents the "works on my machine" problem that has caused multiple CI failures in this project.

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. 5d ago First seen · 82 lines · 0 tokens per session scan A 9ab27a34ddd5

Subscribe to this mod's changes

pyproject-dependencies is a cursor rule published in the GitHub repository wiggitywhitney/mcp-commit-story (15 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 872 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.