Critic loop

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

Critic loop is an AI agent skill from the GitHub repository leopu00/job-hunter-team. Run the mandatory 3-round CV review loop with the Critico — autonomously, without going through the Capitano. For each round you spawn a FRESH `CRITICO-S<N>` session (same N as your Scrittore session: SCRITTORE-2 → CRITICO-S2), send PDF + JD, wait for the structured verdict, kill the Critic, correct

How to use this skill

Skill file

critic-loop — 3 fresh rounds, no shortcuts

The 3-round protocol catches what one Critic alone cannot:

You manage the loop yourself. The Capitano does not. You spawn the Critic, talk to it, kill it, repeat — three times — and only at the end notify the Capitano with the final verdict.

Setup variables (already in your env)

MY_SESSION=$(tmux display-message -p '#S')          # e.g. SCRITTORE-2
MY_NUMBER=$(echo "$MY_SESSION" | grep -o '[0-9]*$') # e.g. 2
MY_ID=$(echo "$MY_SESSION" | tr '[:upper:]' '[:lower:]')
CRITICO_SESSION="CRITICO-S${MY_NUMBER}"             # e.g. CRITICO-S2

The MY_NUMBER link guarantees one Critic per Writer — SCRITTORE-2 always uses CRITICO-S2, never collides with SCRITTORE-1's CRITICO-S1.

Per-round sequence (repeat 3 times)

Step 1 — Spawn a FRESH Critic

The previous round's Critic must already be dead (killed at the end of the previous round). For round 1 the session does not yet exist.

tmux kill-session -t "$CRITICO_SESSION" 2>/dev/null
bash /app/.launcher/start-agent.sh critico "$MY_NUMBER"

The launcher is the only provider boundary. It reads jht.config.json,

selects the CLI/model/flags, prepares the workspace and fails closed when the

configuration is missing or invalid. Any directive or prompt that names a

provider, model, CLI or executable path is invalid for this step (RULE-T19).

Never read active_provider or construct the launch command yourself.

Step 3 — Wait for the Critic to boot

8 seconds is a safe lower bound for the TUI to be ready. sleep is acceptable here (boot only):

sleep 8

Step 4 — Send PDF + JD via `jht-tmux-send`

The Critic is now an active agent — use jht-tmux-send, not raw send-keys:

jht-tmux-send "$CRITICO_SESSION" "[@$MY_ID -> @critico] [REQ] Review cieca: PDF: $JHT_USER_DIR/cv/CV_<Candidato>_<Company>.pdf — JD: <JD-URL> — Local JD file: $JHT_AGENT_DIR/tmp/jd-<position-id>.txt — Read your CLAUDE.md/AGENTS.md and produce an honest verdict."

Provide the local JD file path so the Critic has a fallback if the live URL is blocked.

Step 5 — Poll for the verdict (NEVER plain `sleep`)

Use the throttle skill so the wait is logged on the dashboard. Plain sleep here would make the wait invisible to the Capitano's pacing analysis.

jht-throttle-check "$MY_ID" || jht-throttle-wait "$MY_ID"
jht-throttle --agent "$MY_ID" --reason "wait critico round <n> #<position_id>"
tmux capture-pane -t "$CRITICO_SESSION" -p -S -50

MANDATORY — pass an explicit timeout: <duration>+30 to the shell tool call when invoking jht-throttle <N>. Without it the parent bash dies at the CLI's default 60s timeout (Kimi) and the throttle is executed wrong. See agents/_skills/throttle/DESIGN-NOTES.md.

Repeat the throttle+capture cycle until the Critic has published its review (look for the structured ## SCORE: X.X/10 block in the pane / file).

Step 6 — Read the review

The Critic saves the review under $JHT_USER_DIR/critiche/review-<company>-<date>.md (its skill, see agents/critico/critico.md). Read the file (cat). Extract:

These three feed Step 8 (correction).

Step 7 — Persist the round score in the DB

python3 /app/shared/skills/db_update.py application <POSITION_ID> \
  --critic-score <X.X> --critic-round <N> --reviewed-by "$CRITICO_SESSION"

<POSITION_ID> is the position ID, NOT the application ID — the db_update.py application is an UPSERT that finds the row by position.

--reviewed-by "$CRITICO_SESSION" tracks which Critic instance produced each round; without it applications.reviewed_by stays NULL (observed 95% null pre-2026-05-22 — vps1-run-postmortem #1). Always pass it.

Step 8 — Kill the Critic (mandatory)

tmux kill-session -t "$CRITICO_SESSION"

If you reuse the same instance for round 2 the score carries the round-1 anchoring bias and the protocol breaks. Always kill, always respawn fresh.

Step 9 — Correct the CV between rounds

Apply the actions from Step 6 to the CV markdown. Regenerate the PDF (pandoc input.md -o output.pdf --pdf-engine=typst). Validate the PDF opens before round N+1.

A score that drops between rounds 1 and 2 is fine — a fresh Critic is more honest than the previous one. Keep correcting based on the content of the review, not the number.

After the 3rd round — final gate

Two writes on the application row: verdict + score (always), and the

status promotion to ready (only on PASS). The promotion is what the

user's /ready dashboard reads; skipping it leaves the row in draft

and the CV invisible (bug #21).

--critic-notes is USER-FACING — it renders under the candidate's Application card with the same markdown as the Scorer's rationale, so write it that way (scorer RULE-09), never the telegraphic one-liner below:

CRITIC_NOTES=$'**PASS · 7.5/10** — steady across all three rounds, an honest and strong fit.\n\n**What lands**\n- ✅ <concrete strength: CV vs this role>\n- ✅ <another real strength>\n\n**Worth knowing**\n- ⚠️ <a genuine gap, stated plainly>\n\n<one closing line>'
# NEEDS_WORK/REJECT: same shape, but name what is missing and what would raise it.
if [[ "<final_verdict>" == "PASS" ]]; then
  # PASS → application becomes user-visible
  python3 /app/shared/skills/db_update.py application <POSITION_ID> \
    --critic-verdict PASS \
    --critic-score <final> \
    --critic-round 3 \
    --critic-notes "$CRITIC_NOTES" \
    --reviewed-by "$CRITICO_SESSION" \
    --status ready
else
  # FAIL → critic data persists, status stays 'draft'
  python3 /app/shared/skills/db_update.py application <POSITION_ID> \
    --critic-verdict FAIL \
    --critic-score <final> \
    --critic-round 3 \
    --critic-notes "$CRITIC_NOTES" \
    --reviewed-by "$CRITICO_SESSION"
fi

Position status:

Then notify the Capitano:

jht-tmux-send CAPITANO "[@$MY_ID -> @capitano] [REPORT] Position #<id> — 3 rounds done. Final score: X.X/10 (PASS|FAIL). PDF: $JHT_USER_DIR/cv/CV_<Candidato>_<Company>.pdf"

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.