Most active commenters

    ←back to thread

    740 points chirau | 12 comments | | HN request time: 0.73s | source | bottom
    1. leonheld ◴[] No.44358181[source]
    I adore the

      uv add <mydependencies> --script mycoolscript.py
    
    And then shoving

      #!/usr/bin/env -S uv run
    
    on top so I can run Python scripts easily. It's great!
    replies(5): >>44358268 #>>44358400 #>>44358419 #>>44358467 #>>44361042 #
    2. intellectronica ◴[] No.44358268[source]
    It's so cool. I now habitually vibe-code little scripts that I can immediately run. So much nicer than having to manage environments and dependencies:

    - https://everything.intellectronica.net/p/the-little-scripter

    - https://www.youtube.com/watch?v=8LB7e2tKWoI

    - https://github.com/intellectronica/ez-mcp

    3. kristjansson ◴[] No.44358400[source]
    e: I misread your example, disregard below irrelevant pattern matching of 'uv add --script' to 'uv add' in the project context!

    ~~That mutates the project/env in your cwd. They have a lot in their docs, but I think you’d like run --with or uv’s PEP723 support a lot more~~

    https://docs.astral.sh/uv/guides/scripts/

    replies(1): >>44358477 #
    4. jsilence ◴[] No.44358419[source]
    Using this trick with Marimo.io notebooks in app-mode.

    Instant reactive reproducible app that can be sent to others with minimal prerequisites (only uv needs to be installed).

    Such a hot combo.

    5. simonw ◴[] No.44358467[source]
    I built a Claude Project with special instructions just teaching it how to do this, which means it can output full scripts for me with inline dependencies based on a single prompt: https://simonwillison.net/2024/Dec/19/one-shot-python-tools/

    Claude 4's training cutoff date is March 2025 though, I just checked and it turns out Claude Sonnet 4 can do this without needing any extra instructions:

      Python script using uv and inline script dependecies
      where I can give it a URL and it scrapes it with httpx
      and beautifulsoup and returns a CSV of all links on
      the page - their URLs and their link text
    
    Here's the output, it did the right thing with regards to those dependencies: https://claude.ai/share/57d5c886-d5d3-4a9b-901f-27a3667a8581
    replies(3): >>44358511 #>>44359003 #>>44364481 #
    6. misnome ◴[] No.44358477[source]
    PEP723 support is exactly what the poster is using?
    replies(1): >>44358567 #
    7. varunneal ◴[] No.44358511[source]
    claude sonnet typically forgets about uv script syntax in my experience. I usually find myself having to paste in the docs every time. By default it wants to use uv project syntax.
    8. kristjansson ◴[] No.44358567{3}[source]
    Ach, missed the --script, thanks.
    9. sunaookami ◴[] No.44359003[source]
    Using your system instructions for uv for every LLM now since first seeing your post last year, thanks! It's insanely helpful just asking e.g. Claude to give me a python script for XYZ and just using "uv run". I also added:

      If you need to run these scripts, use "uv run script-name.py". It will automatically install the dependencies. Stdlibs don't need to be specified in the dependencies array.
    
    since e.g. Cursor often gets confued because the dependencies are not installed and it doesn't know how to start the script. The last sentence is for when LLMs get confused and want to add "json" for example to the dependency array.
    10. oblio ◴[] No.44361042[source]
    What's "mydependencies"? A config file?
    replies(1): >>44364305 #
    11. leonheld ◴[] No.44364305[source]
    My apologies: "mydependencies" are packages from PyPI (https://pypi.org/), as if you did "pip install ...".
    12. bilbo-b-baggins ◴[] No.44364481[source]
    Bro I gotchu

    https://github.com/shakefu/cursor-rules/blob/f4dffbbf04ce99f...