agentleFS
FranRomFranRom/pupila/.claude/skills/pupila-ai-review/SKILL.md

pupila-ai-review

Skill37 starsChanged 7 months agoMITView on GitHub

How the AI per-job review pipeline works in this repo - generating verdicts via local LLM CLI, parsing markdown-fenced JSON, the candidate brief lever, and the AI Apply tailored-package flow. Use when modifying src/ai-review.ts, src/lib/ai-apply.ts, tuning verdict prompts, debugging review output, editing the candidate brief, or wiring a new LLM provider.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Default: top 20 by fitScore not already reviewed.

    line 36
  2. Very specific:

    Add detection logic (PATH lookup) in detectLlmCli() / SUPPORTED_PROVIDERS.

    line 95
  3. Very specific:

    Add command-line invocation in runLlm() (must support stdin prompt + stdout response), or a dedicated HTTP path like ollama's /api/generate.

    line 96
  4. Very specific:

    Add to the provider enum in ui/src/settings/types.ts (PROVIDERS + PROVIDER_META) so it appears in the LLM picker UI.

    line 97
  5. Distinctive:

    Test via Settings → LLM CLI → "Test connection" (6-token prompt, 30s timeout).

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

pnpm run ai-review is a local-only companion that augments selected jobs with an LLM review via src/lib/llm.ts (auto-detects claude / codex / gemini / opencode / ollama, override PUPILA_LLM). Subscription CLIs use the user's local plan — NOT an API key. Ollama runs a local model via HTTP (UI selection / PUPILA_LLM_MODEL, or the sole pulled model with a warning — no hardcoded default).

The launchd/cron review agent runs daily at 07:15 by default. Without an LLM CLI, run scripts/install-launchd.sh --no-review (or cron equivalent).

Inputs / outputs

InputPathRole
Slim job listdata/jobs.jsonJob metadata, scoring, _signals
Body sidecardata/jobs-bodies.jsonFull body text (regenerated by pnpm run dev)
Existing reviewsdata/ai-reviews.jsonPrior runs (incremental — only review missing IDs)
Candidate briefconfig/candidate-brief.mdThe main tuning lever — natural-language candidate description embedded verbatim in the prompt
OutputPathSchema
Reviewsdata/ai-reviews.jsonRecord<jobId, AiReview>

Each AiReview carries:

  • One-sentence summary
  • 3 bullets each for wants / offers / redFlags
  • verdict ∈ strong-match | match | weak-match | skip
  • One-sentence reason

Writes after every successful review — Ctrl-C or rate-limit kill leaves a partial-but-valid file.

Selection logic

Default: top 20 by fitScore not already reviewed. Reviews for jobs no longer in jobs.json are pruned each run.

Flags:

  • --top=N — change the batch size
  • --force — re-review even if an entry exists
  • --ids=a,b,c — explicit list (overrides --top)

JSON parsing (the fragile part)

The LLM occasionally wraps JSON in markdown fences (```json ... ```). src/ai-review-parse.ts:

  1. Strips fences (recognises ```json and bare ```).
  2. Falls back to safe defaults on parse failure rather than throwing — partial reviews are still useful, don't crash the whole run.
  3. Sanitizes dirty arrays (empty strings, non-string entries).
  4. Validates verdict against the 4-value enum; invalid → coerces to weak-match.

Tests in tests/ai-review-parse.test.ts (9 cases) cover all the failure modes seen in practice. When you add a new format quirk, add a fixture.

The candidate brief

config/candidate-brief.md is the only natural-language config in the repo. Hand-edited, gitignored. Generated via pnpm run setup-brief --file ~/cv.pdf (or via the UI's Profile tab → drop a PDF/DOCX/MD CV). The CLI shells out to whichever local LLM tool is installed (claude / codex / gemini / opencode / ollama — auto-detected; override via PUPILA_LLM=<provider>). For ollama, set the model in Settings / onboarding or PUPILA_LLM_MODEL (no hardcoded default; a sole pulled model is used with a warning).

The brief is embedded verbatim in the review prompt — it's the main lever for tuning match/skip behaviour. To change verdicts at scale, edit the brief; to change individual scores, see the pupila-filters skill.

Template: config/candidate-brief.example.md (committed).

AI Apply (per-job tailored package)

UI rows have an AI Apply ✨ button next to Apply ↗. POSTs /api/ai-apply with { jobId } — runs the LLM CLI on (brief + posting + CV) and writes a tailored package to data/applications/<jobId>.md. Auto-marks as applied.

Architecture:

  • Middleware: aiApplyApiPlugin in ui/vite.config.ts.
  • Core: runAiApplyForJob in src/lib/ai-apply.ts — same function used by:
    • The Vite middleware (single job, synchronous via spawn)
    • The apply-worker (scripts/apply-worker.ts, drains the Jinder swipe queue serially)
  • Validation: isValidJobId from src/lib/apply-queue.ts (sha1 hex) gates every entry point — data/applications/<jobId>.md writes are path-traversal targets otherwise.

Daily workflow

pnpm run daily       # = pnpm run dev && pnpm run ai-review
pnpm run ui          # browse with verdicts + score breakdowns inline
git add data/jobs.json data/feed.xml data/ai-reviews.json JOBS.md
git commit -m "chore: daily run + ai reviews"

Debugging "verdicts feel wrong"

  1. Re-read the brief. Most miscalibration traces to the brief, not the prompt. If you're saying "skip" for things you'd actually take, the brief over-specifies what to avoid.
  2. Check the input. jq '.[\"<jobId>\"]' data/ai-reviews.json — what wants / offers / redFlags did the model extract? Often the body was truncated or boilerplate-heavy.
  3. Check the model. Different providers produce different verdict distributions; claude and codex are the most stable in our experience.
  4. Force-rerun a single job: pnpm run ai-review --force --ids=<jobId> — read the new output, iterate on brief.

Wiring a new LLM provider

src/lib/llm.ts exports detectLlmCli() + runLlm(). To add a new provider:

  1. Add detection logic (PATH lookup) in detectLlmCli() / SUPPORTED_PROVIDERS.
  2. Add command-line invocation in runLlm() (must support stdin prompt + stdout response), or a dedicated HTTP path like ollama's /api/generate.
  3. Add to the provider enum in ui/src/settings/types.ts (PROVIDERS + PROVIDER_META) so it appears in the LLM picker UI.
  4. Test via Settings → LLM CLI → "Test connection" (6-token prompt, 30s timeout).

Ollama notes

  • Provider id: ollama. Detected when the ollama binary is on PATH or a daemon answers GET /api/tags at OLLAMA_HOST (Docker / remote box). A non-loopback host logs a once-per-process warning, since prompts carry the CV + brief.
  • Invoked via POST http://$OLLAMA_HOST/api/generate (default host 127.0.0.1:11434), not ollama run (TTY spinners).
  • Models are listed live from GET /api/tags and shown as selectable radios in onboarding + Settings (stored as preferences.ollamaModel).
  • Resolution order for the model name: request/UI selection / preferences.ollamaModel → PUPILA_LLM_MODEL env → sole pulled generation-capable model (with a console warning) → throw.
  • Context: requests set options.num_ctx from the prompt size, capped at 32768. An explicit PUPILA_OLLAMA_NUM_CTX is honoured as-is (warned above the cap).
  • Truncation: on overflow Ollama keeps ~half the effective window (W - (W - num_keep)/2) and drops the START of the prompt (the brief), keeping the tail. warnIfPromptTruncated warns when prompt_eval_count is < 0.5× the estimate, or sits just above W/2 for W = num_ctx or a power of two below it. Healthy prompts measure ~0.7-1.05× the estimate, so never use a high ratio threshold. KV-cache prefix reuse still reports the full count (verified on 0.35.0).
  • Thinking models (qwen3): requests set think: false so chain-of-thought doesn't break JSON parsers.

Related

  • src/ai-review.ts — selection + orchestration.
  • src/ai-review-parse.ts — JSON-fence stripping.
  • src/lib/ai-apply.ts — per-job tailored package (shared by UI + worker).
  • src/lib/llm.ts — provider-agnostic shell-out.
  • tests/ai-review-parse.test.ts — parse-failure fixtures.
  • config/candidate-brief.example.md — template for the brief.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.