Py tools audit

From leopu00/job-hunter-team · View interactive version

Py tools audit is an AI agent skill from the GitHub repository leopu00/job-hunter-team. Coordinated, team-wide cleanup of Python packages installed under `$JHT_HOME/.local` via `uv pip install --user` (T13 magazzino). Owned by the Dottore. The audit is NOT unilateral — only the Writer / Critic agents know whether a library they imported dynamically still serves them, so the flow is bro

How to use this skill

Skill file

py-tools-audit — clean the shared Python magazzino

$JHT_HOME/.local/lib/python3.x/site-packages/ is the single shared user-base every agent reads from (T13). Any agent can uv pip install --user <pkg> when it needs a library, but agents don't uninstall when they later switch approach — packages pile up. Roughly weekly the magazzino crosses 800 MB and needs a coordinated audit.

The audit is coordinated because a static import grep can miss libraries loaded dynamically at runtime (e.g. a tools/ script the Writer calls only when a JD asks for a specific format). Hence: ask before removing.

Trigger

Two-round flow (because the Dottore is one-shot)

Round N:    audit → broadcast candidates → leave state file
…30 min…
Round N+1:  collect answers → compute keep_set → uninstall → re-audit → report

Each round logs its phase in $JHT_HOME/logs/py-audit-state.json:

{"phase": "broadcast_sent", "round_id": "...", "ts": "ISO-UTC",
 "candidates": ["pymupdf", "pdfminer.six", "reportlab", "..."],
 "broadcast_at": "ISO-UTC"}

When you wake up, check this file first:

Round N — start the audit

1. Threshold check

python3 /app/shared/skills/py_tools_audit.py --threshold-mb 800

2. Broadcast to every agent

Send one [PY-AUDIT] message to each live agent session via jht-tmux-send:

[@dottore -> @<role>] [PY-AUDIT] candidates uninstall: pymupdf,
pdfminer_six, reportlab, weasyprint, pypdf, ...
If you USE one of these, reply within 1h with [KEEP <pkg>].
Silence = consent to uninstall.

The 1h window is enforced by the next round's start, not by a sleep in this round (the Dottore is one-shot). Persist the broadcast time in py-audit-state.json.

3. Persist state and exit the round

{"phase": "broadcast_sent", "round_id": "...",
 "candidates": ["..."], "broadcast_at": "ISO-UTC"}

End of Round N. Self-destruct as usual; the next Dottore (~30 min later) will pick this up.

Round N+1 — collect, uninstall, report

Triggered when py-audit-state.json shows phase=broadcast_sent and ≥1h has passed.

1. Harvest replies

For each broadcasted agent, run tmux capture-pane -t <SESSION> -p -S -200 | grep '\[KEEP ' to find any [KEEP <pkg>] replies. Build the keep_set:

keep_set = (default whitelist) ∪ (every <pkg> in any [KEEP] reply)

Silence on a candidate = consent to uninstall.

2. Uninstall the silent set

python3 /app/shared/skills/py_tools_audit.py --candidates-only --keep <keep_set...> \
  | xargs -r uv pip uninstall --user -y

xargs -r skips the call when nothing to uninstall (empty stdin).

3. Re-audit + report

python3 /app/shared/skills/py_tools_audit.py
du -sh /jht_home/.local

Compute freed_mb = before - after and notify the user via the Captain:

jht-tmux-send CAPITANO "[@dottore -> @capitano] [REPORT] py-audit done: <N> packages removed, <freed_mb> MB freed. Magazzino now <after_mb> MB."

4. Reset state

{"phase": "done", "round_id": "...", "completed_at": "ISO-UTC",
 "removed": ["..."], "freed_mb": 142}

A fresh py-audit-state.json with phase=done lets the next round restart from scratch.

Hard rules

Anti-patterns

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.