Throwaway python scripts prompt constantly but are unreviewable — make them safe/auditable
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Bắt đầu với standards/CLAUDE.md và so sánh hướng dẫn hiện có về việc “tránh các tệp tạm thời” với đề xuất Python có thể thực thi. Đọc PR #198 và issue #166 để nắm bối cảnh liên quan đến allowlist và enforcement, sau đó xác định xem một hook PreToolUse có nằm trong phạm vi hay không. Hoàn tất khi quyết định về tài liệu đã được ghi lại và, nếu tiếp tục triển khai hook, việc phân loại thận trọng cùng corpus kiểm thử của hook đã được đặc tả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Agents frequently write throwaway python for analysis (parsing transcripts/logs, counting, JSON munging). Each invocation triggers a Bash permission prompt, but the script is usually an inline blob — so the prompt is unreadable in practice and gets rubber-stamped. That defeats the point of the prompt: it provides friction without safety.
Evidence (scan of local transcripts)
415 Bash calls invoke python. Breakdown:
| Form | Calls | Reviewable in the prompt? |
|---|---|---|
inline heredoc (python - <<EOF … EOF) |
100 | ❌ buried in the command |
inline -c (python -c "…") |
223 | ❌ opaque blob |
python file.py |
42 | ✅ file you can read |
- 77% (323) are inline. They are not one-liners: 269 are 6–40+ lines (132 at 6–15, 112 at 16–40, 25 at 40+).
- A 20–40 line python blob in a permission prompt cannot be validated at a glance, so approval is reflexive.
Why the allowlist approach does NOT apply
Unlike read-only git/gh/az reads (allowlisted in #198), python can do anything — write files, delete, network. So python:* can't be allowlisted. The prompt is correctly firing; the problem is that it is unreviewable, so it degrades into a rubber-stamp.
Proposed approaches
1. Standard: executable python is reviewable-by-construction (cheap)
Add to standards/CLAUDE.md, with a boundary against the existing "avoid temp files" rule:
- The existing rule governs text passed to a CLI (
gh --body) → heredoc is fine. - Executable code is different. Any python beyond a true one-liner should be written to a named scratchpad file (via the
Writetool, which renders it as readable content) with a one-line docstring stating read-only intent, then run aspython file.py. The logic becomes reviewable as a file; theBashcommand becomes trivial.
2. Hook: make the prompt meaningful (higher value, the real fix)
A PreToolUse hook that statically classifies the python before it runs:
- No write/network/delete indicators (
open(...,'w'/'a'),subprocess,os.system,os.remove/unlink/rename,shutil,socket,requests/urllib/http) → pure analysis → auto-approve, no prompt. - Any indicator present → prompt as normal, ideally surfacing the flagged lines.
This applies the #198 philosophy to python: don't prompt for provably read-only work; focus human attention only on scripts that touch the world. Converts ~77% opaque rubber-stamps into either silent-safe or a focused prompt. The classifier must be conservative — auto-approve only when clearly side-effect-free; prompt on any doubt — to avoid false negatives.
3. Prefer core tools where they suffice
Some of these scripts do what Grep/Glob already do without a prompt. Reinforce "core tools first" (complex JSON/transcript analysis genuinely needs python, so this only partially helps).
Acceptance criteria
-
standards/CLAUDE.mdstates: executable python beyond a one-liner goes to a named scratchpad file (readable viaWrite) +python file.py, not an inline heredoc; with the text-vs-code boundary against the "avoid temp files" rule made explicit. - Decision recorded on whether to build the read-only-python
PreToolUsehook. - If pursued: hook classifies inline/file python as read-only vs side-effecting; auto-approves only the conservatively-safe set; ships with a test corpus (known read-only and known-mutating scripts) proving no false negatives.
Related
- PR #198 — read-only allowlist (same "don't prompt for provably-safe operations" philosophy; python is the case an allowlist can't cover).
- #166 — standards/context hygiene theme; the hook is the deterministic enforcement tier discussed there.
- Ngôn ngữ chính
- Shell
- Star
- 0
- Fork
- 1
- Merge trung bình
- 3 giờ 19 phút
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TimZander/claude
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Tất cả issue của TimZander/claude
Issue tương tự
-
check-skill-pages: show fixture build errors when a build failsCó thể đã có người làm @ShahadatTest đã nhận hôm nay. Đang mởgood first issue P2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
coco-research/coco#439 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
manaflow-ai/cmux#31387 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ehmpathy/rhachet-roles-ehmpathy#1231 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
nightgauge/nightgauge#2836 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
btclib-org/claude-process#265 ·
Maintainer thường phản hồi trong vòng 1 ngày