Python heredoc
When running multi-line Python code or code with quotes, apostrophes, or f-strings via Bash, always use heredoc syntax instead of python -c to avoid shell quoting issues.From its SKILL.md
npx -y skills add crypdick/pynchy --skill python-heredocAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
3 things to look at
- 10 stars10 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
- runs commandsInstructs the agent to run 2 commands, including `uv run python << 'PYTHON_CODE' import json data = {"name": "it's working", "value": f"{1 + 2}"} print(json.dumps(data, indent=2)) PYTHON_CODE` and 1 more.
- fetches URLsInstructs the agent to fetch 1 URL, including https://api.example.com/data.
SKILL.md
1.1 KB, 248 tokens by cl100k_base, as published. Nobody here has run it
Python Heredoc Pattern
Run Python via Bash? Never python -c "..." beyond trivial one-liners. Shell quoting break on f-strings, apostrophes, nested quotes, escape sequences.
Use heredoc syntax instead
uv run python << 'PYTHON_CODE'
import json
data = {"name": "it's working", "value": f"{1 + 2}"}
print(json.dumps(data, indent=2))
PYTHON_CODE
Single quotes round 'PYTHON_CODE' block shell var expansion. $variables and backticks stay literal Python.
With dependencies
uv run --with requests python << 'PYTHON_CODE'
import requests
resp = requests.get("https://api.example.com/data")
print(resp.json())
PYTHON_CODE
Rules
- Always
uv run python(not barepythonorpython3) - Always quote delimiter:
<< 'PYTHON_CODE'(not<< PYTHON_CODE) - Closing
PYTHON_CODEown line, no leading whitespace - Never
python -cfor code with quotes, f-strings, multiple statements
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.